LCD1502 Driver

Publisher:caoda143Latest update time:2018-01-16 Source: eefocusKeywords:LCD1502 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

--------------------------------------------------------------------------------
; RAM used by LCD part 0200H~~~~021FH Rn used are R15/R14
; LCD reset subroutine (LCD_REST) ​​does not need to be set in advance and can be called directly
; 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 upper screen
; :MOV.B #0BAH,LCD_PAGE_BRAM
; CALL #LCD display lower screen
; LCDUP_WORD0_BRAM~~~LCDUP_WORD6_RAM is the code register of the upper screen display word, one screen displays 7 words
; LCDDOWN_WORD0_BRAM~~~LCDDOWN_WORD6_RAM is the code register of the lower screen display word, one screen displays 7 words
; Each screen display is based on the middle as the reference to display evenly on both sides The column address of LCD is automatically calculated when calling the half-screen display subroutine
. The screen clearing instruction can be divided into full-screen clear (LCD_CLEAR_ALL) and half-screen clear (LCD_CLEAR)
. Note that the full-screen clearing subroutine can be called directly without an entry, while the half-screen clearing subroutine has the same entry as the half-screen display subroutine before calling.
#include " MSP 430x14x.h"
NAME LCD
MODULE LCD
PUBL IC  LCD
RSEG PROM
;========LCD=====================================
      ; A0=1 is data, A0=0 is command 
#define A0 04H    
#define E1 02H     
#define E2 01H     
#define BIT_OUT P4OUT
#define DATA_BUS P2OUT
;==============LCD____8RAM bit definition================
#define LCD_COM_BRAM 0200H
#define LCD_DATA_BRAM 0201H
#define LCD_LIE_BRAM 0202H
#define LCD_PAGE_BRAM 0203H
;=============LCD_UP_RAM==========================
#define LCDUP_WO RD0_BRAM 0204H
#define LCDUP_WORD1_BRAM 0205H
#define LCDUP_WORD2_BRAM 0206H
#define LCDUP_WORD3_BRAM 0207H
#define LCDUP_WORD4_BRAM 0208H
#define LCDUP_WORD5_BRAM 0209H
#define LCDUP_WORD6_BRAM 020AH
;==========The following RAM is only used in test state=====
#define LCDUP_WORD7_BRAM 020BH
;==============LCD_DOWN_RAM====================
#define LCDDOWN_WORD0_BRAM 020CH
#define LCDDOWN_WORD1_BRAM 020DH
#define LCDDOWN_WORD2_BRAM 020EH
#define LCDDOWN_WORD3_BRAM 020FH
#define LCDDOWN_WORD4_BRAM 0210H
#define LCDDOWN_WORD5_BRAM 0211H
#define LCDDOWN_WORD6_BRAM 0212H
;==========The following RAM is only used in test state=====
#define LCDDOWN_WORD7_BRAM 0213H
;=============LCD_DATA_REGISTER_RAM================
#define LCD_R0_BRAM 0214H 
#define LCD_R1_BRAM 0215H 
;==============LCD____16RAM bit definition==============
#define LCD_COUNT_WRAM 021CH
#define LCD_WORD_WRAM 021EH
;==============LCD____BIT bit definition==============
#define LCD_BIT_RAM 0220H
#define LCD_E1_E2 0000H 
      ; LCD left and right screen selection: BIT=1 selects the left side, BIT=0 selects the right side 
#define LCD_INV 02H 
                                             ; High level displays inverted 
;---------------------------------------------------       
;======================================================== 
LCD_E1_COM
        BIC.B #A0,&BIT_OUT ;Set A0 low as command channel
MOV.B LCD_COM_BRAM,&LCD_BUS ;Output command
BIS.B #E1,&BIT_OUT ;Turn on E1
BIC.B #E1,&BIT_OUT ;Turn off E1
RET ;Return

LCD_E2_COM
BIC.B #A0,&BIT_OUT ;Set A0 low as command channel
MOV.B LCD_COM_BRAM,&LCD_BUS ;Output command
BIS.B #E2,&BIT_OUT ;Turn on E2
BIC.B #E2,&BIT_OUT ;Turn off E2
RET ;Return


LCD_E1_DATA
BIS.B #A0,&BIT_OUT ;A0 is set high as command channel
MOV.B LCD_DATA_BRAM,&LCD_BUS ;Output command
BIS.B #E1,&BIT_OUT ;Open E1
BIC.B #E1,&BIT_OUT ;Close E1
RET ;Return

LCD_E2_DATA
BIS.B #A0,&BIT_OUT ;A0 is set high as data channel
MOV.B LCD_DATA_BRAM,&LCD_BUS ;Output command
BIS.B #E2,&BIT_OUT ;Open E2
BIC.B #E2,&BIT_OUT ;Close E2
RET ;Return
;================CLEAR_LCD_DISPALY==============
;You can clear the full screen display by calling the program directly each time without the entry
LCD_CLEAR_ALL
CLR R15
CLR R14
LCD_CLEAR_ALL_1
BIS.B #0B8H,R15
MOV.B R15,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_2
MOV. B #000H,LCD_DATA_BRAM
CALL #LCD_E1_DATA
CALL #LCD_E2_DATA
CLRZ
DEC.B R14
JNZ LCD_CLEAR_ALL_2
INC.B R15
CLRZ
CMP.B #0BCH,R15
JNE LCD_CLEAR_ALL_1
RET
;================CLEAR_LCD_DISPALY==============
; Each time you call the program directly, you can clear half of the screen display   
; Before calling, you must send the page address to LCD_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 display
; :MOV.B #0BAH,LCD_PAGE_BRAM   
; :CALL #LCD_CLEAR is to clear the lower half of the screen display
LCD_CLEAR
CLR R15
MOV.B LCD_PAGE_BRAM,LCD_LIE_BRAM
ADD.B #2D,LCD_LIE_BRAM
LCD_CLEAR_1
BIS.B LCD_PAGE_BRAM,R15  
MOV.B R15,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_2
MOV.B #00H,LCD_DATA_BRAM
CALL #LCD_E1_DATA
CALL #LCD_E2_DATA
CLRZ
DEC.B R14
JNZ LCD_CLEAR_2
INC.B R15
CLRZ
CMP.B LCD_LIE_BRAM,R15
JNZ LCD_CLEAR_1
RET

;===============RESETTING_LCD_MODE=============
;Call this program 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 idle mode
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 setting
CALL #LCD_E1_COM
CALL #LCD_E2_COM

MOV.B #0C0H,LCD_COM_BRAM ; Set the display start line to the first line
CALL #LCD_E1_COM
CALL #LCD_E2_COM

MOV.B #0AFH,LCD_COM_BRAM ; Turn on display setting
CALL #LCD_E1_COM
CALL #LCD_E2_COM
RET

; Check LCD PAGE #0B8H.#0B9H/#0BAH.#0BBH The number of words that need to be displayed on the screen 
; This program has been tested 03-3-12 9:55
;R15/R14/R13
LCD_CHK
CLR LCD_COUNT_RAM
MOV.B #8,LCD_R0_RAM ; Check the number of words that need to be displayed on the screen. A screen can display up to 7 16X16
CLR.B LCD_LIE_BRAM ; Clear the screen check result register
MOV LCD_WORD_RAM,R14 ; Put the first 16-bit address of the word to be checked into R14.LCD_WORD_RAM
      ​​; It must be a 16-bit address when defined
LCD_CHK_0
DEC.B LCD_R0_RAM
JZ LCD_CHK_1 ; Test completed and exit
CLRZ 
MOV.B @R14+,LCD_COUNT_RAM
TST.B LCD_COUNT_RAM ;Test each word register to see if it is zero
JZ LCD_CHK_0 ;When it is zero, transfer to
INC.B LCD_LIE_BRAM ;If it is greater than zero, check the result register and add one
JMP LCD_CHK_0 ;Return test
LCD_CHK_1 
        CLR LCD_COUNT_RAM
        MOV.B LCD_LIE_BRAM,LCD_COUNT_RAM
MOV LCD_COUNT_RAM,&MPY ;Multiply the test result by 16
MOV #16D,&OP2
MOV &RESLO,LCD_COUNT_RAM ;Put the multiplication result back into the register
MOV.B LCD_COUNT_RAM,LCD_LIE_BRAM
RRA.B LCD_LIE_BRAM ;Divide the result by 2 and put it into the register of the upper screen page
MOV.B #61D,LCD_COUNT_RAM
SUB.B LCD_LIE_BRAM,LCD_COUNT_RAM
MOV.B LCD_COUNT_RAM,LCD_LIE_BRAM
RET
;Before calling, the address of the first word to be displayed on the screen must be placed in R15 
; Column: MOV #LCDUP_WORD0_BRAM,LCD_WORD_RAM
       ​​;MOV #LCDDOWN_WORD0_BRAM,LCD_WORD_RAM 
       ​​;Registers used R15/R14
LCD
CLRZ
CMP.B #0B8H,LCD_PAGE_BRAM
JNE LCD_1
MOV #LCDUP_WORD0_BRAM,LCD_WORD_RAM
​​JMP LCD_0
LCD_1 MOV #LCDDOWN_WORD0_BRAM,LCD_WORD_RAM
​​LCD_0 CALL #LCD_CHK
BIS.B #BIT0,LCD_BIT_RAM
MOV.B #7D,LCD_R1_RAM  
;Each call displays 7 16X16 words in succession. When encountering a word register,
MOV LCD_WORD_RAM,R15 ;Zero is returned because there is no zero in the word table
LCD_DISPALY
CLR R14
        MOV.B @R15+,R14
TST R14 ;R15 is the first address register of the display word, which is used for indirect addressing
JZ LCD_RET ;If the word register is zero, return it
MOV #32D,&MPY ;Look up the table and send the result to the register
MOV R14,&OP2
MOV &RESLO,LCD_COUNT_RAM
ADD #LCD_DB,LCD_COUNT_RAM
MOV LCD_COUNT_RAM,R14
MOV.B #32D,LCD_R0_RAM ;R14 is used to store the number of calculated search data
LCD_PAGE 
MOV.B LCD_PAGE_BRAM,LCD_COM_BRAM;Send the page address to the command register
CLRZ
BIT.B #BIT0,LCD_BIT_RAM
;When BIT0 of LCD_BIT_RAM=LCD_E1_E2 is high, go to E1 to send, the first is E2
JZ LCD_PAGE_E2 ;If Z is zero, go to E2, otherwise work downward
LCD_PAGE_E1 
CALL #LCD_E1_COM ;Send page address to E1
JMP LCD_LIE ;Jump to column to send
LCD_PAGE_E2 
CALL #LCD_E2_COM ;Send page address to E2
LCD_LIE 
MOV.B LCD_LIE_BRAM,LCD_COM_BRAM;Send column address to command register
CLRZ
BIT.B #BIT0,LCD_BIT_RAM
;When LCD_BIT_RAM is high, go to E1 to send, the first is E2
JZ LCD_LIE_E2 ;If Z is zero, go to E2, otherwise work downward
LCD_LIE_E1 
CALL #LCD_E1_COM ;Send column address to E1
JMP LCD_DATA
LCD_LIE_E2 
CALL #LCD_E2_COM ;Send column address to E2
LCD_DATA
CALL #LCD_FIND_DATA ;Call data sending command
CLRZ
BIT.B #BIT0,LCD_PAGE_BRAM ;Test BIT0 of page register
JNZ LCD_PAGE_0 ;If it is greater than zero (i.e. BIT0=1), transfer to
BIS.B #BIT0,LCD_PAGE_BRAM ;Set BIT0 of page register high (originally low #0B8H/#0BAH)
JMP LCD_RETURN  
LCD_PAGE_0 
BIC.B #BIT0,LCD_PAGE_BRAM ;Set BIT0 of page register low (originally high #0B9H/#0BBH)
INC.B LCD_LIE_BRAM ;Add column address to one
CLRZ
CMP.B #61D,LCD_LIE_BRAM ;Check if there are more than 61 columns
JNZ LCD_RETURN ;If Z is greater than zero, transfer If it is equal to zero, work downward
CLR.B LCD_LIE_BRAM; clear register
CLRZ 
BIT.B #BIT0, LCD_BIT_RAM; test LCD_BIT_RAM bit, if it is E1, switch to E2, if it is E2, immediately return 
JNZ LCD_PAGE_1; if Z is zero, switch to E2, otherwise work downward
JMP LCD_RET; switch to subroutine and return command
LCD_PAGE_1 
BIC.B #BIT0, LCD_BIT_RAM; set LCD_BIT_RAM bit low and set it to E2 display state
JMP LCD_PAGE; return page transfer command address
LCD_RETURN 
CLRZ 
DEC.B LCD_R0_RAM; find the number of data register minus 1
JNZ LCD_PAGE; if R14 is greater than zero, switch back to page transfer command address
CLRZ
DEC.B LCD_R1_RAM; decrease the number of words register by 1
BIC.B #BIT0, LCD_PAGE_BRAM
JNZ LCD_DISPALY ;Return to main display calling program
LCD_RET
RET ;Return to main program

;==================================================== 
LCD_FIND_DATA  
MOV.B @R14+,LCD_DATA_BRAM 
CLRZ
BIT.B #INV_BIT,LCD_BIT_RAM
JZ NO_INV
INV.B LCD_DATA_BRAM
NO_INV CLRZ
BIT.B #BIT0,LCD_BIT_RAM ;Test LCD_BIT_RAM bit If it is E1, it will turn to E2. If it is E2, it will return to
JZ immediately LCD_FIND_E2 ;If Z is zero, it will turn to E2, otherwise it will work downward
CALL #LCD_E1_DATA ;Call E1 data sending subroutine
JMP LCD_FIND_DATA_RET
LCD_FIND_E2 
CALL #LCD_E2_DATA ;Call E2 data sending subroutine
LCD_FIND_DATA_RET 
RET
END LCD

Keywords:LCD1502 Reference address:LCD1502 Driver

Previous article:51 MCU Chinese character LCD subroutine LCD screen is divided into 4 rows * 12 columns of Chinese characters
Next article:Water pump timing control experiment

Recommended ReadingLatest update time:2024-11-16 14:59

Selection and three topology designs of portable LED drivers
High-brightness LEDs are used as flash sources in mobile phones and digital cameras. These applications require optimized driver solutions that extend battery life and reduce printed circuit board (PCB) area and height. In these application areas, common LED driver solutions involve different topologies such as linear
[Microcontroller]
Selection and three topology designs of portable LED drivers
What are the servo drive control modes?
The servo drive is one of the indispensable key components in the field of modern industrial automation. It achieves precise control of the mechanical system by precisely controlling the speed, position and torque of the motor. There are many control modes for servo drives, and different control modes are suitable f
[Embedded]
Analysis of DM9000 driver on mini2440 (Part 1)
First of all, let me ask a question: I have seen some network cards connected to the ISA bus or PCI bus, but on the mini2440, the DM9000 and the CPU are directly connected. What kind of bus is this? I don't understand this question. The first is to register and unregister the platform device.  static int __init dm
[Microcontroller]
Mini2440 Norflash driver transplantation process
I don't know whether the kernel of Friendlylinux2.6.32 supports norflash of mini2440, so I will personally enable norflash support for mini2440 here. The transplantation process is shared as follows: 1. Add configuration items 1. Modify the drivers/mtd/maps/Kconfig file, and add the following content under
[Microcontroller]
Analysis of the servo program using 51 single-chip microcomputer
A servo, also known as a servo motor, is an electromechanical structure with a closed-loop control system. A servo is mainly composed of a housing, a circuit board, a coreless motor, gears, and a position detector. Its working principle is that the controller sends a PWM (pulse width modulation) signal to the servo, w
[Microcontroller]
Design of high brightness LED driver power supply without electrolytic capacitor based on MIP553
  Challenges of LED Power Supply   As a new type of electric light source, LED has obvious advantages in making large luminous three-dimensional characters and luminous signs. It has low control voltage, low cost and high reliability. Although LED products have an increasingly strong development trend in the domesti
[Power Management]
Design of high brightness LED driver power supply without electrolytic capacitor based on MIP553
How to choose servo motors and stepper motors correctly? How to ground the drive and system?
The general structure of the electric servo system of industrial robots is three closed-loop control, namely the current loop, speed loop and position loop. Generally speaking, for AC servo drives, multiple functions such as position control, speed control, torque control, etc. can be achieved by manually setting th
[Embedded]
High-speed piezoelectric ceramic driver
Piezoelectric ceramics have a series of characteristics such as small size, high resolution, fast response, and large thrust. Piezoelectric ceramic drivers made of it are widely used in micro-displacement output devices, force generating devices, robots, impact motors, optical scanning and other fields. Therefore, the
[Power Management]
High-speed piezoelectric ceramic driver
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号