;Content: 5-bit LCD segment LCD display
; LCD connection SEG0-PD0...SEG7-PD7,SEG8-PE.0
;COM0-PC0, COM1-PC1, COM2-PC6, COM3-PC7
;Full source code download: http://www.51hei.com/f/htbdlcd.rar
include HT66F50.inc
ds .section 'data'
COM0 EQU PC.0 ;COM0 pin definition
COM1 EQU PC.1 ;COM0 pin definition
COM2 EQU PC.6 ;COM0 pin definition
COM3 EQU PC.7 ;COM0 pin definition
SEG EQU PD ;SEG pin definition
SEG9 EQU PE.0 ;seg8 pin definition
SEG01 EQU [90H] ;SEG0 and seg1 pin data register
SEG23 EQU [91H] ; SEG2 and seg3 pin data register
SEG45 EQU [92H] ; SEG4 and seg5 pin data register
SEG67 EQU [93H] ; SEG6 and seg7 pin data register
SEG8 EQU [94H] ; SEG8 pin data register
SEG_0 EQU [95H] ; SEG pin data processing temporary register
LCD1 EQU [9AH] ; 1st LCD display data register
LCD2 EQU [9BH] ; 2nd LCD display data register
LCD3 EQU [9CH] ; 3rd LCD display data register
LCD4 EQU [9DH] ; 4th LCD display data register
LCD5 EQU [9EH] ; 5th LCD display data register
cs .section 'code'
ORG 0000H
JMP A1
Q1:
DC 06FH ; 0
DC 00AH ; 1
DC 073H ; 2
DC 03BH ; 3
DC 01EH ; 4
DC 03DH ; 5
DC 07DH ; 6
DC 00BH ; 7
DC 07FH ; 8
DC 03FH ; 9
DC 05FH ; A
DC 07CH ; B
DC 065H ; C
DC 07AH ; D
DC 075H ; E
DC 055H ; F
A1:
MOV A,08H ;
MOV CP0C,A ; Set the pin not as comparator input port
MOV CP1C,A ;
MOV A,7FH ;
MOV SCOMC,A ; Set PC.0.1.6.7 as COM port and enable
CLR PCC ;Set PC port as output port
CLR PDC ;Set PD port as output port
CLR PEC.0 ;Set PE.0 as output port
MOV A,1 ;
MOV LCD1,A ;LCD1 displays data
MOV A,2 ;
MOV LCD2,A ;LCD2 displays data
MOV A,3 ;
MOV LCD3,A ;LCD3 displays data
MOV A,4 ;
MOV LCD4,A ;LCD4 displays data
A2:
MOV A,LOW Q1 ;Data table address low 8 bits
MOV TBLP,A
MOV A,HIGH Q1 ;Data table address high 8 bits
MOV TBHP,A ;
MOV A,LCD1 ;Display data address code
ADDM A,TBLP ;Find data table location
TABRD SEG01 ;Look up table and store data in SEG01
MOV A,LOW Q1 ;
MOV TBLP,A MOV
A,HIGH Q1 ;
MOV TBHP,A ;
MOV A,LCD2 ;
ADDM A,TBLP ;
TABRD SEG23 ; Look up the table and store the data in SEG23
MOV A,LOW Q1 ;
MOV TBLP,A
MOV A,HIGH Q1 ;
MOV TBHP,A ;
MOV A,LCD3 ;[page]
ADDM A,TBLP ;
TABRD SEG45 ; Look up the table and store the data in SEG45
MOV A,LOW Q1 ;
MOV TBLP,A
MOV A,HIGH Q1 ;
MOV TBHP,A ;
MOV A,LCD4 ;
ADDM A,TBLP ;
TABRD SEG67 ; Look up the table and store the data in SEG67
MOV A,LOW Q1 ;
MOV TBLP,A ;
MOV A,HIGH Q1 ;
MOV TBHP,A ;
MOV A,LCD5 ;
ADDM A,TBLP ;
TABRD SEG8 ; Look up the table and store the data in SEG8
CLR COM0EN ;set pin to PC.0
CLR COM0 ;output low level
CALL RR0 ;call seg pin data processing program
MOV A,SEG_0 ;
MOV SEG,A ;output processed data from seg connector
CLR SEG9
CALL M001 ;delay
SET COM0 ;output high level
CPL SEG_0 ;invert pin data
MOV A,SEG_0 ;
MOV SEG,A ;output data from seg pin
SET SEG9
CALL M001 ;delay
SET COM0EN ;set pin to com0 port output VDD/2 voltage
CALL M001 ;delay
clr COM1EN ;set pin to PC.1
clr com1 ;output low level
CALL RR0 ;call seg pin data processing program
MOV A,SEG_0 ;
MOV SEG,A ;output processed data from seg connector
CLR SEG9
CALL M001 ;delay
SET COM1 ;output high level
CPL SEG_0 ;invert the pin data
MOV A,SEG_0 ;
MOV SEG,A ;data output from seg pin
SET SEG9
CALL M001 ;delay
SET COM1EN ;set the pin to output VDD/2 voltage
CALL M001 ;delay
clr COM2EN ;set the pin to PC.6
clr com2 ;output low level
CALL RR0 ;call seg pin data processing program
MOV A,SEG_0 ;
MOV SEG,A ;output the processed data from seg connector
CLR SEG9
CALL M001 ;delay
SET COM2 ;output high level
CPL SEG_0 ;invert the pin data
MOV A,SEG_0 ;
MOV SEG,A ;data output from seg pin
SET SEG9
CALL M001 ;Delay
SET COM2EN ;Set the pin to com2 port to output VDD/2 voltage
CALL M001 ;Delay
clr COM3EN ;Set the pin to PC.7
clr com3 ;Output low level
CALL RR0 ;Call seg pin data processing program
MOV A,SEG_0 ;
MOV SEG,A ;Output the processed data from the seg connector
CLR SEG9
CALL M001 ;Delay
SET COM3 ;Output high level
CPL SEG_0 ;Invert the pin data
MOV A,SEG_0 ;
MOV SEG,A ;Output the processed data from the seg connector
SET SEG9
CALL M001 ;
SET COM3EN ;Set the pin to com3 port to output VDD/2 voltage
CALL M001 ;Delay
JMP A2
;************************************************************
;********seg data processing subroutine********************************
;************************************************************
;SEG01 is the first bit of the code to be displayed. SEG0 and SEG1 control
; SEG23--SEG8 control the corresponding codes respectively
; When scanning COM0, SEG (0-7) outputs the 0th and 1st bits
; When scanning COM1, SEG (0-7) outputs the 2nd and 3rd bits
; When scanning COM2, SEG (0-7) outputs the 4th and 5th bits
; When scanning COM3, SEG (0-7) outputs the 6th and 7th bits
;**************************************************************
RR0: RRC SEG01 ; Move the 0th bit of SEG01 to the seg_0 register
RRC SEG_0
with carry C ;
RRC SEG01 ; Move the 1st bit of SEG01 to the seg_0 register
RRC SEG_0 with carry C;
RRC SEG23 ;Move the 0th bit of SEG23 to the seg_0 register with carry C
RRC SEG_0 ;
RRC SEG23 ;Move the 1st bit of SEG23 to the seg_0 register with carry C
RRC SEG_0 ;
RRC SEG45 ;Move the 0th bit of SEG45 to the seg_0 register with carry C
RRC SEG_0 ;
RRC SEG45 ;Move the 1st bit of SEG45 to the seg_0 register with carry C
RRC SEG_0 ;
RRC SEG67 ;Move the 0th bit of SEG67 to the seg_0 register with carry C
RRC SEG_0 ;
RRC SEG67 ;Move the 1st bit of SEG67 to the seg_0 register with carry C
RRC SEG_0 ;When the shift is completed, the SEG_0 register is the seg port required for scanning COM
RET ;Output status
;************************************************************
; Delay subroutine
;********************************************************
M001:
MOV A,4
MOV [8AH],A
M002:
MOV A,250
MOV [8BH],A
SDZ [8BH]
JMP $-1
SDZ [8AH]
JMP M002
RET
END
Previous article:Hetai MCU PWM output program
Next article:Hetai MCU interrupt nesting
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- NXP Rapid IoT Review】+④NXP Rapid IoT Operation Time Synchronization
- [Evaluation of EVAL-M3-TS6-665PN development board] 1. Hardware circuit
- What issues should be paid attention to when designing MCU for low power consumption
- AM335X GPIO Register Operation
- Overview of IoT Communication Technologies
- ESD Request Assistance
- How to compensate for the unbalanced output of a strain gauge bridge?
- MSP430G2553 State Machine Modeling
- The variable occasionally has a very large value
- USB matching resistor