fet410_lcd_06.s43
来自「MSP430的汇编开发例子」· S43 代码 · 共 202 行
S43
202 行
;******************************************************************************
; MSP-FET430P410 Demo - LCD, Display Characters on 14 Segment 4-Mux LCD
;
; Description: 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 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
; //* An external watch crystal between XIN & XOUT is required 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
;
; G. Morton
; Texas Instruments Inc.
; Feb 2005
; Built with IAR Embedded Workbench Version: 3.21A
;******************************************************************************
#include <msp430x41x.h>
;-----------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 ; Initialize stack pointer
call #Setup ; Setup
Mainloop mov #string0,str_pnt ; Addr of 1st byte into string
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 ; Load R15 with LCD mem index
Stat_char mov.b 0(str_pnt),tbl_pnt ; Load char into LCD table pointer
add.b 0(str_pnt),tbl_pnt ; Double (2xASCII value)
tst tbl_pnt ; Test for end of string
jz StaticEnd ; If 0 (end of string) then jump
mov LCD_tbl-86(tbl_pnt),TEMP ; Load LCD table value into TEMP
; -86 adjusts 2xASCII value to
; LCD table offset
mov.b TEMP,LCDM1(R15) ; Low byte to LCD current digit
swpb TEMP ; Swap upper and lower bytes
mov.b TEMP,LCDM2(R15) ; High byte to LCD digit
inc str_pnt ; Increment string pointer
decd R15 ; Double decrement LCD mem index
jmp Stat_char ; 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 ;
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
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
; 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 character string to display (';' displays 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
; desired character then adjusts the offset to find the correct
; table member. The punctuation characters (ASCII 3Ah-40h) are
; used to define other desired characters. Use the corresponding
; ASCII character to get the desired character on the display.
;------------------------------------------------------------------------------
EVEN ; Align words on even boundry
LCD_tbl DW 05A00h ; Displays '+' ASCII 2Bh (43)
DW 0AAAAh ; Undefined
DW 04200h ; Displays '-'
DW 00008h ; Displays '.'
DW 02400h ; Displays '/' ASCII 2Fh (47)
;******************************************************************
DW 024E7h ; Displays '0' ASCII 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' ASCII 39h (57)
;******************************************************************
DW 01800h ; Displays ':' ASCII 3Ah (58)
DW 00000h ; Displays ' ' ';' mapped to ' '
DW 000C4h ; Displays 'u' '<' mapped to 'u'
DW 0AAAAh ; Undefined
DW 0AAAAh ; Undefined
DW 0AAAAh ; Undefined
DW 042A7h ; Displays 'o' ASCII 40h (64)
;******************************************************************
DW 04267h ; Displays 'A' ASCII 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 5Ah (90)
;------------------------------------------------------------------------------
; Interrupt Vectors
;------------------------------------------------------------------------------
ORG 0FFFEh ; RESET Vector
DW RESET
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?