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

📄 fet440_lcd_03.s43

📁 fet440_wdt_02.s43 - WDT, Toggle P5.1, Interval Overflow ISR, 32kHz ACLK
💻 S43
字号:
;******************************************************************************
;   MSP-FET430P440 Demo - LCD, Display Numbers on a 4-Mux LCD
;
;   Description: 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
;   and the LCD memory values in the LCD memory
;   locations.
;   ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
;   //* An external watch crystal between XIN & XOUT is required 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
;
;   G. Morton / H. Grewal
;   Texas Instruments Inc.
;   Feb 2005
;   Built with IAR Embedded Workbench Version: 3.21A
;******************************************************************************
#include  <msp430x44x.h>

;-----------CPU registers used-------------------------------------------------
;;;;;;;     R13, R14, R15                   ; Used as temporary registers, can
                                            ; be reused
;------------------------------------------------------------------------------
            ORG     0E000h                  ; Program reset
;------------------------------------------------------------------------------
RESET       mov.w   #300h,SP                ; Initialize stack pointer
            call    #Setup                  ; Setup

Mainloop    mov.b   R14,R13                 ; Copy R14 to R13 (save R14)
            call    #ToLCD                  ; Call to display 1st digit
            mov.b   R14,R13                 ; Copy R14 to R13 (save R14)
            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 (save R14)
            call    #ToLCD                  ; Call to display 3rd digit
            mov.b   R14,R13                 ; Copy 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              ;
Xtal_Wait   dec     R15                     ; Delay for 32 kHz crystal to
            jnz     Xtal_Wait		    ; stabilize
SetupLCD    mov.b   #LCDP1+LCDP0+LCD4MUX+LCDON,&LCDCTL
                                            ; 4-Mux LCD, segments S0-S23
SetupIO     bis.b   #0FCh,&P5SEL            ; Set Rxx and COM pins for LCD
SetupBT     mov.b   #BTFRFQ1,&BTCTL         ; Set freqLCD = 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
                                            ; to 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'

;------------------------------------------------------------------------------
;           Interrupt Vectors
;------------------------------------------------------------------------------
            ORG     0FFFEh                  ; RESET Vector
            DW      RESET
            END



⌨️ 快捷键说明

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