⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fet410_lcd06.s43

📁 MSP430常用的程序源代码,很全的,一定适合你(初学者)!
💻 S43
字号:
#include    "msp430x41x.h" ;  MSP430x41x Standard Definitions
;*******************************************************************************
;  MSP-FET430P410 Demo - LCD, displays characters on 14 segment 4 multiplex LCD
;
;  Description "FET410_14segLCD": This program displays up to 6 alphanumeric 
;  characters on a 14 segment LCD display driven directly by the MSP430 MCU.
;  The software reads a character string and displays up to 6 characters on
;  the display.  The MSP430 then waits in low power mode 3 while still
;  maintaining the display.  To use the program chose one of the character
;  strings provided in the software or enter a new one of up to 6 characters.
;  Comment out any strings not used. The character ";" is used for blank spaces.
;  Reset the program then press run. The string will be displayed on the LCD.
;  If the user does not have the LCD connected the functioning of the software 
;  can still be followed by single stepping and watching the register values, 
;  the TEMP value in RAM, and the LCD memory values in the LCD memory locations. 
;   ACLK = LFXT1 = 32768, MCLK = SMCLK = DCO = 32xACLK = 1.048576MHz 
;   //*An external watch crystal is required on XIN/XOUT for ACLK*//	  
;  
;  Connections MSP430F413 -> Varitronix 14 segment LCD part # VIM-828-DP-RC-S-LV
;
;                   TI MSP430F413    LCD        TI MSP430F413    LCD           
;                   ------------- | ---------   ------------- | ---------- 
;                          COM3   |  1                 COM0   |  19
;                          NC     |  2                 NC     |  20
;                          NC     |  3                 NC     |  21  
;                          SEG21  |  4                 SEG0   |  22
;                          SEG23  |  5                 SEG2   |  23 
;                          SEG17  |  6                 SEG4   |  24
;                          SEG19  |  7                 SEG6   |  25
;                          SEG13  |  8                 SEG8   |  26
;                          SEG17  |  9                 SEG10  |  27
;                          SEG9   |  10                SEG12  |  28
;                          SEG11  |  11                SEG14  |  29
;                          SEG5   |  12                SEG16  |  30
;                          SEG7   |  13                SEG18  |  31
;                          SEG1   |  14                SEG20  |  32
;                          SEG3   |  15                SEG22  |  33
;                          NC     |  16                NC     |  34
;                          NC     |  17                NC     |  35
;                          COM2   |  18                COM1   |  36
;
;  NOTE 1: MSP430F413 will drive 6 of 8 14-segment characters so only characters
;          2-7 are connected to center the display. The connections can be 
;          changed to add characters or shift display.
;
;  NOTE 2: Pin R03 on the MSP430 must be connected to GND
;
; B. Merritt
; Texas Instruments Inc.
; January 2002
;
;--------CPU registers used------------------------------------------------------
#define   str_pnt  R5  
                                          ;R5 used as pointer within a string 
#define   tbl_pnt  R6
                                          ;R6 used pointer within the character
                                          ;table 

;--------RAM words used for variables-------------------------------------------
TEMP      equ    0200h                    ;temporary storage in LCD routine

;-------------------------------------------------------------------------------
          ORG    0E000h                   ;Program reset
;-------------------------------------------------------------------------------
RESET     mov    #300h,SP                 ;itialize stackpointer          
          call   #Setup                   ;configure MSP430 for application

Mainloop  mov    #string0,str_pnt         ;addr of 1st byte into string pointer
          call   #Static                  ;call routine for static display
          bis    #LPM3,SR                 ;Set SR bits to wait in LPM3
              
;-------------------------------------------------------------------------------
;         Display string on LCD
;-------------------------------------------------------------------------------
Static    mov    #10,R15                  ;results in 6 char loaded to LCD mem
Stat_char mov.b  0(str_pnt),tbl_pnt       ;char pointed to, into table pointer
          add.b  0(str_pnt),tbl_pnt       ;value x 2 since is 2 bytes in table
          tst    tbl_pnt                  ;test value
          jz     Staticend                ;if 0 (= end of string) then jump 
          mov    LCD_tbl-86(tbl_pnt),TEMP ;char word from table to temp location
                                          ;-86 adjusts from 2 x ASCII value 
          mov.b  TEMP,LCDM1(R15)          ;low byte of char to LCD current digit
          swpb   TEMP                     ;swap upper and lower bytes in temp
          mov.b  TEMP,LCDM2(R15)          ;high byte of char to LCD digit 
          inc    str_pnt                  ;increment string pointer to next byte
          decd   R15                      ;double decrement charater index
          jmp    Stat_char                ;loop to get & load next char
Staticend ret

;-------------------------------------------------------------------------------
Setup     ;Configure modules and control registers 
;-------------------------------------------------------------------------------
StopWDT   mov    #WDTPW+WDTHOLD,&WDTCTL    ;stop Watchdog Timer
SetupFLL2 bis.b  #XCAP18PF,&FLL_CTL0       ;set load capacitance for xtal
          mov    #10000,R15
FLL_Wait  dec    R15                       ;delay for FLL to lock
          jnz    FLL_Wait	

SetupLCD  mov.b  #07Dh,&LCDCTL             ;4mux LCD, segs = 0-23
          bis.b  #0FCh,&P5SEL              ;set Rxx and COM pins for LCD
SetupBT   mov.b  #00h+BTFRFQ1,&BTCTL       ;set fLCD = ACLK / 128
SetPorts  mov.b  #0FFh,&P1DIR              ;set port to outputs
SetupPx   mov.b  #0FFh,&P2DIR              ;set port to outputs
          mov.b  #0FFh,&P3DIR              ;set port to outputs
          mov.b  #0FFh,&P4DIR              ;set port to outputs
          mov.b  #0FFh,&P6DIR              ;set port to outputs

ClearLCD  mov    #15,R15                   ;15 LCD memory bytes to clear
Clear1    mov.b  #0,LCDM1(R15)             ;write zeros in LCD RAM locations
                                           ;so clear display
          dec    R15                       ;all LCD mem clear?
          jc     Clear1                    ;more LCD mem to clear go, use JC
                                           ;to get memory location 0
          mov.b  #LCDM1,R15;               ;R15 points to first LCD location
          ret

;-------------------------------------------------------------------------------
;         Define character string to display.  The ";" character = blank space
;-------------------------------------------------------------------------------
string0   DB "MSP430"
;string0   DB ";;HI;;"
;string0   DB "BUY;TI"

;-------------------------------------------------------------------------------
;        The following table defines the LCD segements to be displayed for each 
;        character.  Software reads the ASCII value of the character desired
;        then adjusts the offset to find the correct table member. The 
;        punctuation characters (ASCII 39h-40h) are used to define other desired
;        characters. Use the corresponding ASCII character to get the desired 
;        character on the display.
;-------------------------------------------------------------------------------
         EVEN
LCD_tbl  DW  05A00h     ;displays +                            ASCII hex=2Bh=43 
         DW  0AAAAh     ;undefined display is meaningless
         DW  04200h     ;displays -
         DW  00008h     ;displays . decimal point not period
         DW  02400h     ;displays /
         ;*********************************************************************          
         DW  024E7h     ;displays 0                            ASCII hex=30h=48
         DW  00006h     ;displays 1
         DW  042C3h     ;displays 2
         DW  04287h     ;displays 3
         DW  04226h     ;displays 4
         DW  042A5h     ;displays 5          
         DW  042E5h     ;displays 6
         DW  00007h     ;displays 7
         DW  042E7h     ;displays 8
         DW  042A7h     ;displays 9
         ;*********************************************************************
         DW  01800h     ;displays ":" vertical bars(ASCII ":") ASCII hex=39h=58 
         DW  00000h     ;displays " " blank space (ASCII ";")
         DW  000C4h     ;displays "u" used as the micro symbol 'mu' (ASCII "<")
         DW  0AAAAh     ;undefined display is meaningless
         DW  0AAAAh     ;undefined display is meaningless
         DW  0AAAAh     ;undefined display is meaningless
         DW  042A7h     ;displays "o" symbol for temperature (ASCII "@")
         ;*********************************************************************
         DW  04267h     ;displays A                            ASCII hex=41h=65
         DW  05887h     ;displays B
         DW  000E1h     ;displays C
         DW  01887h     ;displays D
         DW  042E1h     ;displays E
         DW  04261h     ;displays F
         DW  040E5h     ;displays G
         DW  04266h     ;displays H
         DW  01881h     ;displays I
         DW  000C6h     ;displays J          
         DW  0A260h     ;displays K
         DW  000E0h     ;displays L
         DW  02166h     ;displays M
         DW  08166h     ;displays N
         DW  000E7h     ;displays O
         DW  04263h     ;displays P
         DW  080E7h     ;displays Q
         DW  0C263h     ;displays R
         DW  042A5h     ;displays S
         DW  01801h     ;displays T
         DW  000E6h     ;displays U
         DW  02460h     ;displays V
         DW  08466h     ;displays W
         DW  0A500h     ;displays X
         DW  04A22h     ;displays Y
         DW  02481h     ;displays Z                            ASCII hex=5Ah=90
          
;-------------------------------------------------------------------------------
;        41x Interrupt vectors
;------------------------------------------------------------------------------- 
         ORG     0FFFEh                  ;RESET Vector
         DW      RESET
         END



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -