📄 fet440_lcd_04.s43
字号:
;*******************************************************************************
; MSP-FET430P440 Demo - LCD, Display Numbers on a 3-Mux LCD
;
; Description: This program displays a 4 digit BCD value
; stored in register R14 on a 3 mux rate LCD then waits in low power mode 3.
; To use the program enter a 4 digit BCD (characters 0-9) number in R14 and
; press enter. Reset the program then press run. 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 locations change as the software is executed.
; ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
; //* An external watch crystal between XIN & XOUT is required for ACLK *//
;
; Connections MSP430 -> LCD
; -------------------------
;
; T.I. Varitronix
; MSP430x4xx MCU 4.5 digit, 3 mux LCD
; # VIM-503-DP-FC-S-LV
; --------------- --------------
; | COM2 |-----|15 COM3 |
; | COM1 |-----|14 COM2 |
; | COM0 |-----|13 COM1 |
; | SEG0 |-----|10 |
; | SEG1 |-----|12 |
; | SEG2 |-----|11 |
; | SEG3 |-----|7 |
; | SEG4 |-----|9 |
; | SEG5 |-----|8 |
; | SEG6 |-----|4 |
; | SEG7 |-----|6 |
; | SEG8 |-----|5 |
; | SEG9 |-----|1 |
; | SEG10|-----|3 |
; | SEG11|-----|2 |
; | | --------------
; | |
; ---------------
;
; NOTE: Pin R03 on the MSP430 must be connected to GND
;
; G. Morton
; 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
;-----------RAM words used for variables---------------------------------------
LCDTEMP EQU 0200h ; Temporary storage in LCD routine
;------------------------------------------------------------------------------
ORG 0E000h ; Program reset
;------------------------------------------------------------------------------
RESET mov #300h,SP ; Initialize stack pointer
call #Setup ; Setup
Mainloop call #OutLCD ; Call routine to display lower
; 2 BCD digits entered into R14
swpb R14 ; Swap bytes in R14
call #OutLCD ; Call routine to display upper
; 2 BCD digits just moved to lower
; byte of R14
bis #LPM3,SR ; Set SR bits to wait in LPM3
;------------------------------------------------------------------------------
; Display 2 digits on 3 mux rate LCD. CPU Registers R15, R14 and R13
; used temporarily
;------------------------------------------------------------------------------
OutLCD mov R14,R13 ; Copy R14 to R13 (save R14)
and #000Fh,R13 ; Blank upper 12 bits, only low
; nibble now in R13
add R13,R13 ; Double R13 since is word data
; where addresses = 2 bytes apart
mov LCD_Tab(R13),LCDTEMP ; 16 bit segment info into temp
; LCDTEMP = 0000 0bch 0agd 0yfe
mov.b LCDTEMP,0(R15) ; Segments 'dga_ef' of low digit
; to LCD memory
swpb LCDTEMP ; Swap bytes in temp
bis.b LCDTEMP,1(R15) ; Segments 'bch' of low digit
; to LCD memory
mov.b R14,R13 ; Copy lower byte of BCD value in
; R14 to R13
rra.b R13 ; Right shift R13 4 times to
rra.b R13 ; Move high nibble to lower 4 bits
rra.b R13 ;
rra.b R13 ;
and #000Fh,R13 ; Blank upper 4 bits, only
; High nibble of BCD now in R13
add R13,R13 ; Double R13 since is word data
; where addresses = 2 bytes apart
mov LCD_Tab(R13),LCDTEMP ; 16-bit segment info into temp
; LCDTEMP = 0000 0bch 0agd 0yfe
rla LCDTEMP ; LCDTEMP = 0000 bch0 agd0 yfe0
rla LCDTEMP ; LCDTEMP = 000b ch0a gd0y fe00
rla LCDTEMP ; LCDTEMP = 00bc h0ag d0yf e000
rla LCDTEMP ; LCDTEMP = 0bch 0agd 0yfe 0000
bis.b LCDTEMP,1(R15) ; Segments 'yfe' of high digit
swpb LCDTEMP ; LCDTEMP = 0yfe 0000 0bch 0agd
mov.b LCDTEMP,2(R15) ; Segments 'bchagd' of high digit
add #3,R15 ; Increase R15 (LCD mem pointer)
; by 3 since 1.5 bytes per digit
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 ;
Xtal_Wait dec R15 ; Delay for 32 kHz crystal to
jnz Xtal_Wait ; stabilize
SetupLCD mov.b #LCDP0+LCD3MUX+LCDON,&LCDCTL
; 3-Mux LCD, segments S0-S15
SetupIO bis.b #0ECh,&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
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
; to clear display
dec R15 ; All LCD mem clear?
jc Clear1 ; More LCD mem to clear, use JC
; to get memory location 0
mov.b #LCDM1,R15; ; R15 points to first LCD location
ret
;------------------------------------------------------------------------------
; Define characters for VIM-503 4.5 digit 3 mux LCD
;------------------------------------------------------------------------------
f EQU 0001h
e EQU 0002h
h EQU 0004h
a EQU 0010h
g EQU 0020h
d EQU 0040h
b EQU 0100h
c EQU 0200h
y EQU 0400h
EVEN ; Align words on even boundry
LCD_Tab DW a+b+c+d+e+f ; Displays '0'
DW b+c ; Displays '1'
DW a+b+d+e+g ; Displays '2'
DW a+b+c+d+g ; Displays '3'
DW b+c+f+g ; Displays '4'
DW a+c+d+f+g ; Displays '5'
DW a+c+d+e+f+g ; Displays '6'
DW a+b+c ; Displays '7'
DW a+b+c+d+e+f+g ; Displays '8'
DW a+b+c+d+f+g ; Displays '9'
DW g ; Displays '-'
;------------------------------------------------------------------------------
; Interrupt Vectors
;------------------------------------------------------------------------------
ORG 0FFFEh ; RESET Vector
DW RESET
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -