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

📄 fet440_lcd03.s43

📁 msp430f440的头程序
💻 S43
字号:
#include    "msp430x44x.h" ;  MSP430x44x Standard Definitions
;*******************************************************************************
;  MSP-FET430P440 Demo - LCD, displays numbers on 4 multiplex rate LCD
;
;  Description "FET440_4muxLCD": This program displays digits stored in regiser
;  R14 on a 4 mux LCD, then waits in low power mode 3. To use the program
;  enter a 4 digit BCD number (digits 0-9) in R14 and press enter.  Reset and
;  run the program.  The value in R14 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 LCDTEMP
;  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*//	  
;
;  NOTE: The code is written such that single digits can be passed to the 
;        display routine.  The routine to shift bytes in the mainloop could be
;        moved to the display routine if passing of multiple digits is preferred
;  
;                                 Connections MSP430 -> LCD
;                                 -------------------------
;
;                                T.I.                  T.I.
;                           MSP430x4xx MCU   STK/EVK 6.5 digit 4 mux LCD
;                                                    #T218010
;                           ---------------       --------------
;                          |          COM3 |-----|2    COM4     |
;                          |          COM2 |-----|1    COM3     |
;                          |          COM1 |-----|3    COM2     | 
;                          |          COM0 |-----|4,20 COM1     |
;                          |          SEG0 |-----|19            |
;                          |          SEG1 |-----|18            |
;                          |          SEG2 |-----|17            |
;                          |          SEG3 |-----|16            |  
;                          |          SEG4 |-----|15            |
;                          |          SEG5 |-----|14            |
;                          |          SEG6 |-----|13            |
;                          |          SEG7 |-----|12            |
;                          |          SEG8 |-----|11            | 
;                          |          SEG9 |-----|10            |
;                          |          SEG10|-----|9             |
;                          |          SEG11|-----|8             |
;                          |          SEG12|-----|7             | 
;                          |          SEG13|-----|6             |
;                          |          SEG14|-----|5 (bits C,E,H |
;                          |               |     |   of digit 7)|
;                          |               |      --------------
;                          |               | 
;                           ---------------  
;
;                   NOTE: Pin R03 on the MSP430 must be connected to GND
;
; B. Merritt
; Texas Instruments Inc.
; January 2002
;
;--------CPU register used------------------------------------------------------
;;;;;;;       R13, R14, R15                    ;used as temporary registers, can
                                               ;be reused 

;--------RAM words used for variables-------------------------------------------
CDTEMP       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.b  R14,R13                   ;copy R14 to R13, so R14 saved
              call   #ToLCD                    ;call to display 1st digit
              mov.b  R14,R13                   ;recopy R14 to R13, so R14 saved
              rra.b  R13                       ;right shift R13 4 times to 
              rra.b  R13                       ;move 2nd nibble to lower 4 bits
              rra.b  R13                       ;
              rra.b  R13                       ;
              call   #ToLCD                    ;call to display 2nd digit
              swpb   R14                       ;swap bytes in R14    
              mov.b  R14,R13                   ;copy R14 to R13, so R14 saved
              call   #ToLCD                    ;call to display 3rd digit
              mov.b  R14,R13                   ;recopy R14 to R13
              rra.b  R13                       ;right shift R13 4 times to 
              rra.b  R13                       ;move 2nd nibble to lower 4 bits
              rra.b  R13                       ;
              rra.b  R13                       ;
              call   #ToLCD                    ;call to display 4th digit 
              bis    #LPM3,SR                  ;Set SR bits to wait in LPM3
              
;-------------------------------------------------------------------------------
;             Display 1 digit on 4 mux LCD. CPU Registers R13 & R15 used
;             temporarily
;-------------------------------------------------------------------------------
ToLCD         and    #000Fh,R13                ;blank upper 12 bits
              mov.b  LCD_Tab(R13),0(R15)       ;byte from table LCD memory
              inc    R15                       ;increment pointer by 1 to next
                                               ;LCD memory byte
EndLCD        ret                              ;return from call

;-------------------------------------------------------------------------------
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  #03Dh,&LCDCTL             ;4mux LCD, segs16-23 = outputs
              bis.b  #0FCh,&P5SEL              ;set Rxx and COM pins for LCD
SetupBT       mov.b  #00h+BTFRFQ1,&BTCTL       ;set LCD frame freq = ACLK / 128
SetupPorts    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,&P5DIR              ;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 characters for T218010 = 6.5 digit 4 mux LCD
;----------------------------------------------------------------------------- 
a             equ     01h	 
b             equ     02h
c             equ     10h
d             equ     04h
e             equ     80h
f             equ     20h
g             equ     08h
h             equ     40h

LCD_Tab       DB      a+b+c+d+e+f             ;displays "0"
              DB      b+c                     ;displays "1"
              DB      a+b+d+e+g               ;displays "2"
              DB      a+b+c+d+g               ;displays "3"
              DB      b+c+f+g                 ;displays "4"
              DB      a+c+d+f+g               ;displays "5"
              DB      a+c+d+e+f+g             ;displays "6"
              DB      a+b+c                   ;displays "7"
              DB      a+b+c+d+e+f+g           ;displays "8"
              DB      a+b+c+d+f+g             ;displays "9"

;----------------------------------------------------------------------------- 
;             4xx Interrupt vectors
;----------------------------------------------------------------------------- 
              ORG     0FFFEh                  ;RESET Vector
              DW      RESET
              END



⌨️ 快捷键说明

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