"; Ram0200h ~ ~ ~ 021fh used in LCD part and RN used in R15 / R14
; LCD reset subroutine (LCD)_ Rest) can be called directly without setting in advance
; The half screen display subroutine (LCD) must be sent to the page address before calling, for example: mov. B #0b8h, LCD_ PAGE_ BRAM
; Call#lcd display on screen
;: MOV.B #0BAH,LCD_ PAGE_ BRAM
; Call#lcd display lower screen
; LCDUP_ WORD0_ BRAM~~~LCDUP_ WORD6_ Ram is the code register of words displayed on the screen, and 7 words are displayed on one screen
; LCDDOWN_ WORD0_ BRAM~~~LCDDOWN_ WORD6_ Ram is the code register of words displayed on the next screen, and 7 words are displayed on one screen
; Each screen is displayed evenly to both sides based on the middle. When calling the half screen display subroutine, the column address of LCD has been calculated automatically
; The screen clearing command can be divided into full screen clearing (LCD)_ CLEAR_ All) and half screen clear (LCD)_ CLEAR)
; Note: the full screen clearing subroutine does not need to be called directly by the entry, while the entry of the half screen clearing subroutine is the same as that of the half screen display subroutine before calling
#i nclude“MSP430x14x.h”
NAME LCD
MODULE LCD
PUBLICLCD
RSEG PROM
;========= LCD==================================
; A0 = 1 is data and A0 = 0 is command
#defineA004H
#defineE102H
#defineE201H
#defineBIT_ OUTP4OUT
#defineDATA_ BUSP2OUT
;============= LCD____ Bit definition of 8ram===============
#defineLCD_ COM_ BRAM0200H
#defineLCD_ DATA_ BRAM0201H
#defineLCD_ LIE_ BRAM0202H
#defineLCD_ PAGE_ BRAM0203H
;============= LCD_ UP_ RAM============================
#defineLCDUP_ WORD0_ BRAM 0204H
#defineLCDUP_ WORD1_ BRAM 0205H
#defineLCDUP_ WORD2_ BRAM 0206H
#defineLCDUP_ WORD3_ BRAM 0207H
#defineLCDUP_ WORD4_ BRAM 0208H
#defineLCDUP_ WORD5_ BRAM 0209H
#defineLCDUP_ WORD6_ BRAM 020AH
;========== The following ram is only used in the test state=====
#defineLCDUP_ WORD7_ BRAM 020BH
;============= LCD_ DOWN_ RAM=====================
#defineLCDDOWN_ WORD0_ BRAM 020CH
#defineLCDDOWN_ WORD1_ BRAM 020DH
#defineLCDDOWN_ WORD2_ BRAM 020EH
#defineLCDDOWN_ WORD3_ BRAM 020FH
#defineLCDDOWN_ WORD4_ BRAM 0210H
#defineLCDDOWN_ WORD5_ BRAM 0211H
#defineLCDDOWN_ WORD6_ BRAM 0212H
;========== The following ram is only used in the test state=====
#defineLCDDOWN_ WORD7_ BRAM 0213H
;============= LCD_ Data register_ RAM=================
#defineLCD_ R0_ BRAM0214H
#defineLCD_ R1_ BRAM0215H
;============= LCD____ Bit definition of 16ram===============
#defineLCD_ COUNT_ WRAM021CH
#defineLCD_ WORD_ WRAM021EH
;============= LCD____ Bit definition of bit===============
#defineLCD_ BIT_ RAM0220H
#defineLCD_ E1_ E20000H
; Yes, select bit = 1 on the left and bit = 0 on the right of the LCD left and right screens
#defineLCD_ INV02H
; Display backlight at high level
;---------------------------------------------------
;===========================================================
LCD_ E1_ COM
BIC.B#A0,&BIT_ OUT; A0 set low as command channel
MOV.BLCD_ COM_ BRAM,&LCD_ BUS ; Output command
BIS.B#E1,&BIT_ OUT ; Open E1
BIC.B#E1,&BIT_ OUT ; Off E1
RET; Reverse return
LCD_ E2_ COM
BIC.B#A0,&BIT_ OUT ; A0 set low as command channel
MOV.BLCD_ COM_ BRAM,&LCD_ BUS ; Output command
BIS.B#E2,&BIT_ OUT ; Open E2
BIC.B#E2,&BIT_ OUT ; Off E2
RET; Reverse return
LCD_ E1_ DATA
BIS.B#A0,&BIT_ OUT ; A0 set high as command channel
MOV.BLCD_ DATA_ BRAM,&LCD_ BUS ; Output command
BIS.B#E1,&BIT_ OUT ; Open E1
BIC.B#E1,&BIT_ OUT ; Off E1
RET; Reverse return
LCD_ E2_ DATA
BIS.B#A0,&BIT_ OUT ; A0 set high as data channel
MOV.BLCD_ DATA_ BRAM,&LCD_ BUS ; Output command
BIS.B#E2,&BIT_ OUT ; Open E2
BIC.B#E2,&BIT_ OUT ; Off E2
RET; Reverse return
;================ CLEAR_ LCD_ DISPALY==============
; Every time you call the program directly, you can clear the full screen display without entry
LCD_ CLEAR_ ALL
CLRR15
CLRR14
LCD_ CLEAR_ ALL_ one
BIS.B#0B8H,R15
MOV.BR15,LCD_ COM_ BRAM
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#00H,LCD_ COM_ BRAM
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#61D,R14
LCD_ CLEAR_ ALL_ two
MOV.B#000H,LCD_ DATA_ BRAM
CALL#LCD_ E1_ DATA
CALL#LCD_ E2_ DATA
CLRZ
DEC.BR14
JNZLCD_ CLEAR_ ALL_ two
INC.BR15
CLRZ
CMP.B#0BCH,R15
JNELCD_ CLEAR_ ALL_ one
RET
;================ CLEAR_ LCD_ DISPALY=============
; Every time you call the program directly, you can clear the half screen display
; The page address must be sent to the LCD before calling_ PAGE_ RAM (page address register)
; For example: mov. B #0b8h, LCD_ PAGE_ BRAM
;: CALL #LCD_ Clear is to clear the upper half of the screen
;: MOV.B #0BAH,LCD_ PAGE_ BRAM
;: CALL #LCD_ Clear is to clear the lower half of the screen
LCD_ CLEAR
CLRR15
MOV.BLCD_ PAGE_ BRAM,LCD_ LIE_ BRAM
ADD.B#2D,LCD_ LIE_ BRAM
LCD_ CLEAR_ one
BIS.BLCD_ PAGE_ BRAM,R15
MOV.BR15,LCD_ COM_ BRAM
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#00H,LCD_ COM_ BRAM
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV#61D,R14
LCD_ CLEAR_ two
MOV.B#00H,LCD_ DATA_ BRAM
CALL#LCD_ E1_ DATA
CALL#LCD_ E2_ DATA
CLRZ
DEC.BR14
JNZLCD_ CLEAR_ two
INC.BR15
CLRZ
CMP.BLCD_ LIE_ BRAM,R15
JNZLCD_ CLEAR_ one
RET
;=============== RESETTING_ LCD_ MODE=============
; Calling this program is to reset the LCD and enter the working state
LCD_ REST
MOV.B#0E2H,LCD_ COM_ BRAM ; reset
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#0A4H,LCD_ COM_ BRAM ; Turn off leisure status
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#0A9H,LCD_ COM_ BRAM ; Set 1 / 32 duty cycle
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#0A0H,LCD_ COM_ BRAM ; Forward sort settings
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#0C0H,LCD_ COM_ BRAM ; Set the first line of the display start behavior
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
MOV.B#0AFH,LCD_ COM_ BRAM ; On display settings
CALL#LCD_ E1_ COM
CALL#LCD_ E2_ COM
RET
; Check the number to be displayed on the LCD page #0b8h. #0b9h / #0bah. #0bbh
; This procedure has been tested 03-3-12 9:55
; R15/R14/R13
LCD_ CHK
CLRLCD_ COUNT_ RAM
MOV.B#8,LCD_ R0_ RAM; Check the number to be displayed on the screen. A screen can display up to 7 16x16
CLR.BLCD_ LIE_ BRAM; Clear screen search result register
MOVLCD_ WORD_ RAM,R14 ; Put the first 16 bit address of the word to be checked into r14.lcd_ WORD_ RAM
; Must be a 16 bit address when defined
LCD_ CHK_ 0
DEC.BLCD_ R0_ RAM
JZLCD_ CHK_ 1; Test complete exit
CLRZ
MOV. B@R14+ ,LCD_ COUNT_ RAM
TST.BLCD_ COUNT_ RAM; Test whether each word register is zero
JZLCD_ CHK_ 0 Turn when it is zero
INC.BLCD_ LIE_ BRAM; If it is greater than zero, the result register is incremented by one
JMPLCD_ CHK_ 0 Reverse test
LCD_ CHK_ one
CLRLCD_ COUNT_ RAM
MOV.BLCD_ LIE_ BRAM,LCD_ COUNT_ RAM
MOVLCD_ COUNT_ RAM,&MPY ; Multiply the test results by 16
MOV#16D,&OP2
MOV&RESLO,LCD_ COUNT_ RAM ; The result of the multiplication is put back into the register
MOV.BLCD_ COUNT_ RAM,LCD_ LIE_ BRAM
RRA.BLCD_ LIE_ BRAM; The result is divided by 2. The register placed on the previous screen page
MOV.B#61D,LCD_ COUNT_ RAM
SUB.BLCD_ LIE_ BRAM,LCD_ COUNT_ RAM
MOV.BLCD_ COUNT_ RAM,LCD_ LIE_ BRA
Our other product: