Hetai MCU Segment LCD Display Program + Circuit Diagram

Publisher:nu23Latest update time:2015-05-13 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Circuit Diagram:



;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

Reference address:Hetai MCU Segment LCD Display Program + Circuit Diagram

Previous article:Hetai MCU PWM output program
Next article:Hetai MCU interrupt nesting

Latest Microcontroller Articles
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号