em78p153 driver 1602 source program

Publisher:快乐的旅程Latest update time:2018-01-27 Source: eefocusKeywords:em78p153 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The chip is EM78P153  
P64, P65 is connected to the crystal oscillator, the oscillation mode is 4MHz crystal oscillator  
watchdog gate, the instruction cycle is 2 CLOCK, P63 is the reset pin  
********************** IO port definition **************************  
PORT6 EQU 0X06  
IOC60 EQU 0X06  


**************Definition of special function registers******************  
TCC EQU 0X01  
PC EQU 0X02  
PSW EQU 0X03  
IOCD0 EQU 0X0D  
IOCE0 EQU 0X0E  
IOCF0 EQU 0X0F  
RF EQU 0X0F  
***************User defined registers*******************  
COUNTER EQU 0X10  
CODE1 EQU 0X11  
CODE2 EQU 0X12  
CODE3 EQU 0X13  
CODE4 EQU 0X14  
LP_CNT0 EQU 0X15  
LP_CNT1 EQU 0X16  
TEMP EQU 0X17  
TEMPCODE EQU 0X18  
REPEAT_COUNTER EQU 0X19  
SEND_DATA EQU 0X1A  
USER_CODE EQU 0X1B  
FLAG EQU 0X1C  
*******************FLAG bit definition*********************  
C EQU 0  
Z EQU 2  
TCIF EQU 0  
LEAD EQU 0  
REPEAT EQU 1  
INPUT EQU 1  
OUTPUT EQU 0  
ORG 0X000  
NOP  
NOP  
NOP  
NOP  
JMP 0X50  
********************Table conversion subroutine program******************  
TABLE_CONVER:  
CLR TEMP  
TABLE_CONVER_1:  
MOV A,TEMP  
CALL TABLE_CONVERSION_IN  
BC PSW,Z  
XOR A,CODE3  
JBC PSW,Z  
JMP EXIT_5  
INC TEMP  
JMP TABLE_CONVER_1  
EXIT_5:  
CALL TABLE_CONVERSION_OUT  
RET  
**********************Table conversion program IN************************  
TABLE_CONVERSION_IN:  
ADD PC,A  
RETL 0XD0 KEY_1  
RETL 0X58 KEY_2  
RETL 0XD8 KEY_3  
RETL 0X90 KEY_4  
RETL 0X18 KEY_5  
RETL 0X98 KEY_6 RETL  
0XE0 KEY_7  
RETL 0X68  
KEY_8 RETL 0XE8 KEY_9  
RETL 0X28 KEY_0  
RETL 0X20 KEY_3D  
RETL 0XA0 KEY_MUTE  
RETL 0X40 KEY_ VOC AL  
RETL 0XE2 KEY_VOL+  
RETL 0XA2 KEY_VOL-  
RETL 0X52 KEY_TUNE FWD  
RETL 0X22 KEY_TUNE REV  
RETL 0X12 KEY_STOP  
RETL 0X80 KEY_<|  
RETL 0X82 KEY_|>  
RETL 0X02 KEY_OK  
RETL 0XF0 KEY_TUNER  
RETL 0X78 KEY_AM/ FM  
RETL 0XF8 KEY_SAVE  
RETL 0X50 KEY_AUDIO  
************************Table conversion program OUT************************  
TABLE_CONVERSION_OUT:  
MOV A,TEMP  
ADD PC,A  
RETL 0X35 KEY_1  
RETL 0X2D KEY_2  
RETL 0X25 KEY_3  
RETL 0X1D KEY_4  
RETL 0X34 KEY_5  
RETL 0X2C KEY_6  
RETL 0X24 KEY_7  
RETL 0X1C KEY_8  
RETL 0X33 KEY_9  
RETL 0X2B KEY_0  
RETL 0X10 KEY_3D  
RETL 0X18 KEY_MUTE  
RETL 0X11 KEY_VOCAL  
RETL 0X16 KEY_VOL+  
RETL 0X15 KEY_VOL-  
RETL 0X28 KEY_TUNE FWD  
RETL 0X2A KEY_TUNE REV  
RETL 0X22 KEY_STOP  
RETL 0X31 KEY_<|  
RETL 0X21 KEY_|>  
RETL 0X29 KEY_OK  
RETL 0X2E KEY _TUNER  
RETL 0X20 KEY_AUX-1  
RETL 0X23 KEY_AUX-2  
RETL 0X17 KEY_DVD  

ORG 0X050  
MAIN:  
*********************Initialization register**********************  
MOV A,@0B00000000  
IOW IOCE0  
MOV A,@0B11111101  
IOW IOCD0  
MOV A,@0B00000010  
IOW IOC60  
MOV A,@0B00000001  
MOV PORT6,A  
MOV A,@0B00000001  
IOW IOCF0  
CLR FLAG  
CLR TEMPCODE  
CLR COUNTER  
CLR CODE1  
CLR CODE2  
CLR CODE3  
CLR CODE4  
MOV A,@0B10010000  
MOV USER_CODE,A  
***** ****************Scan boot code**********************  
S CAN _LEAD_CODE:  
JBC PORT6,INPUT  
JMP SCAN_LEAD_CODE  
CLR FLAG  
CLR REPEAT_COUNTER  
CLR TEMPCODE  
CALL JUDGE_START_CODE  
JBS FLAG,LEAD  
JMP SCAN_LEAD_CODE  
*********************Receive data************ **********   
RECEIVE_DATA_PROCEE:  
CLR TEMPCODE   
CALL RECEIVE_DATA  
MOV A,TEMPCODE  
MOV CODE1,A  

MOV A,@0 Determine if the user code is 00  
BC PSW,Z  
XOR A,CODE1  
JBS PSW,Z  
JMP SCAN_LEAD_CODE  


CLR TEMPCODE  
CALL RECEIVE_DATA  
MOV A,TEMPCODE  
MOV CODE2,A  

MOV A, @0XFF Determine if the user code is FF  
BC PSW,Z  
XOR A,CODE2  
JBS PSW,Z  
JMP SCAN_LEAD_CODE  

CLR TEMPCODE  
CALL RECEIVE_DATA  
MOV A,TEMPCODE  
MOV CODE3,A  

CLR TEMPCODE  
CALL RECEIVE_DATA  
MOV A,TEMPCODE  
MOV CODE4,A  
CLR FLAG  
** *******************Send data***********************  
SEND_DATA_PROCEE:  
JBS USER_CODE,6 ST The second highest bit of the code is inverted  
JMP COM_1 =0  
JMP COM_2 =1  
COM_1:  
BS USER_CODE,6  
JMP VVV  
COM_2:  
BC USER_CODE,6  
JMP VVV  
VVV:  
CALL TABLE_CONVER Call table conversion subroutine  
MOV CODE3,A  
REP:  
CALL TRANSMIT_DATA  
BS PORT6,OUTPUT  
CALL JUDGE_REPEAT_CODE Scan the boot code to see if Repeating?  
JBS FLAG,LEAD  
JMP SCAN_LEAD_CODE  
JBC FLAG,REPEAT  
JMP REP The lead code is repeated, continue scanning  
JMP RECEIVE_DATA_PROCEE Boot code is not repeated, go to receive new data   
**************** Boot code detection subroutine********************  
JUDGE_START_CODE:  
CLR COUNTER Clear counter  
JUDGE_START_CODE_0:  
JBC PORT6,INPUT  
JMP NO_HIGH  
CALL DELAY0.5MS  
JBC PORT6,INPUT  
JMP NO_HIGH  
INC COUNTER  
JMP JUDGE_START_CODE_0  
NO_HIGH:  
MOV A,COUNTER  
BC PSW,C  
SUB A,@20 20-A  
JBS PSW,C  
JMP EXIT_0 C=1,COUNTER>20  
MOV A,COUNTER  
BC PSW,C  
SUB A,@16 16-A  
JBC PSW,C  
JMP EXIT_0 C=0,COUNTER<16  
BS FLAG,LEAD  
EXIT_0:  
JBC PORT6,INPUT  
JMP EXIT_0  
INC REPEAT_COUNTER  
RET  
****************Receive data subroutine**********************  
RECEIVE_DATA:   
MOV A,@8  
MOV COUNTER,A  
MOV A,@0B00100000  
CONTW Stop counting  
CONTINUE_1:  
JBS PORT6,INPUT  
JMP CONTINUE_1  
CLR TCC  
MOV A,@0B00000100  
CONTW TCC Start counting  
CONTINUE_2:  
MOV A,TCC  
MOV TEMP,A  
BC PSW,C  
SUB A,@250  
JBS PSW,C  
JMP SCAN_LEAD_CODE C=0,TCC>250  

JBC PORT6,INPUT  
JMP CONTINUE_2  
MOV A,TCC  
MOV TEMP,A  
BC PSW,C  
SUB A,@60142  
JBC PSW,C  
JMP X1 C=1,TCC<60  
JMP X2 C=0,TCC>60  
X1:  
BC TEMPCODE,0  
JMP EXIT_1  
X2:  
BS TEMPCODE,0  
JMP EXIT_1  
EXIT_1:  
DJZ COUNTER  
JMP HH  
MOV A,@0B00100000  
CONTW Stop counting  
RET  
HH:  
BC PSW,C  
RLC TEMPCODE  
JMP CONTINUE_1  

****************Send data subroutine***********************  
TRANSMIT_DATA:  
MOV A,@4  
MOV COUNTER,A  
MOV A,USER_CODE @0B10010000 Send user code of ST  
MOV SEND_DATA,A  
CYCLE_1:  
JBS SEND_DATA,7  
JMP SEND_P_0  
JMP SEND_P_1  
SEND_P_1:  
CALL SEND_CODE_1  
JMP EXIT_3  
SEND_P_0:  
CALL SEND_CODE_0  
JMP EXIT_3  
EXIT_3:  
RLC SEND_DATA  
DJZ COUNTER  
JMP CYCLE_1  

MOV A,@8  
MOV COUNTER,A  
MOV A,CODE3  
MOV SEND_DATA,A  
RLC SEND_DATA  
CYCLE_2:  
JBS SEND_DATA,7  
JMP SEND_Q_0  
JMP SEND_Q_1  
SEND_Q_1:  
CALL SEND_CODE_1  
J MP EXIT_4  
SEND_Q_0:  
CALL SEND_CODE_0  
JMP EXIT_4  
EXIT_4:  
RLC SEND_DATA  
DJZ COUNTER  
JMP CYCLE_2  
RET  
***************Send data 1 subroutine **************************  
SEND_CODE_1:  
MOV A,@0B00100000  
CONTW Stop counting  
MOV A,@0B00000001 Enable TCC interrupt  
IOW IOCF0  
MOV A,@35 Preset value of guide pulse  
MOV TCC,A  
MOV A,@0B00000001 Select prescaler ratio as 1:4  
CONTW  
BC PORT6,OUTPUT  
WAIT_1:  
JBS RF,TCIF  
JMP WAIT_1  
MOV A,@0B00100000  
CONTW Stop counting  
BC RF,TCIF  
MOV A,@32 Preset value of code 1  
MOV TCC,A  
MOV A,@0B00000101 Select the prescaler ratio to be 1:64  
CONTW  
BS PORT6,OUTPUT  
WAIT_2:  
JBS RF,TCIF  
JMP WAIT_2  
BC RF,TCIF  
MOV A,@0B00100000  
CONTW Stop counting  
RET  
******************Send data 0 subroutine********************  
SEND_CODE_0:  
MOV A,@0B00100000  
CONTW Stop counting  
MOV A,@0B00000001 Enable TCC interrupt  
IOW IOCF0  
MOV A,@35 Preset value of guide pulse  
MOV TCC,A  
MOV A,@0B00000001 Select the prescaler ratio to be 1:4  
CONTW  
BC PORT6,OUTPUT  
WAIT_3:  
JBS RF,TCIF  
JMP WAIT_3  
MOV A,@0B00100000  
CONTW Stop counting  
BC RF,TCIF  

MOV A,@114 Preset value of code 0  
MOV TCC,A  
MOV A,@0B00000101 Select prescaler ratio as 1:64  
CONTW  
BS PORT6,OUTPUT  
WAIT_4:  
JBS RF,TCIF  
JMP WAIT_4  
NOP  
BC RF,TCIF  
MOV A,@0B00100000  
CONTW Stop counting  
RET  
****************Repeat code detection subroutine******************  
JUDGE_REPEAT_CODE:  
CLR COUNTER Clear counter  
CLR FLAG  
JUDGE_REPEAT_CODE_0:  
JBC PORT6,INPUT  
JMP JUDGE_REPEAT_CODE_0  
SS:  
JBC PORT6,INPUT  
JMP JUDGE_REPEAT_CODE_1  
CALL DELAY0.5MS  
JBC PORT6,INPUT  
JMP JUDGE_REPEAT_CODE_1  
INC COUNTER  
JMP SS  
JUDGE_REPEAT_CODE_1:  
MOV A,COUNTER  
BC PSW,C  
SUB A,@20 20-A  
JBS PSW,C  
JMP EXIT_2 C=1,COUNTER>20  
MOV A,COUNTER  
BC PSW,C  
SUB A,@16 16-A  
JBC PSW,C  
JMP EXIT_2 C=0,COUNTER<16  
BS FLAG,LEAD  
JMP JUDGE_REPEAT_CODE_2  
EXIT_2:  
RET  
JUDGE_REPEAT_CODE_2:  
CLR COUNTER clear counter  
JUDGE_REPEAT_CODE_3:  
JBS PORT6,INPUT  
JMP JUDGE_REPEAT_CODE_4  
CALL DELAY0.5MS  
JBS PORT6,INPUT  
JMP JUDGE_REPEAT_CODE_4  
INC COUNTER  
JMP JUDGE_REPEAT_CODE_3  
JUDGE_REPEAT_CODE_4:  
MOV A,COUNTER  
BC PSW,C  
SUB A,@7 7-A  
JBS PSW,C  
JMP NO_REPEAT C=0,COUNTER>7  
JMP YES_REPEAT C=1,COUNTER<7  
NO_REPEAT:  
BC FLAG,REPEAT  
CLR REPEAT_COUNTER  
RET  
YES_REPEAT:  
BS FLAG,REPEAT  
INC REPEAT_COUNTER  
RET  
****************延时0.5mS子程序*********************  
DELAY0.5MS:  
MOV A,@2  
MOV LP_CNT0,A  
DELAY0.5MS_1:  
MOV A,@82  
MOV LP_CNT1,A  
DELAY0.5MS_2:  
NOP  
NOP  
NOP  
DJZ LP_CNT1  
JMP DELAY0.5MS_2  
DJZ LP_CNT0  
JMP DELAY0.5MS_1  
RET  


Keywords:em78p153 Reference address:em78p153 driver 1602 source program

Previous article:Motor drive and control of electric car
Next article:Macro definition of EMC microcontroller EM78P260

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号