HT48R50A的 電源掉電模式示例程序
;********************************************
;Function:電源掉電模式示例程序*
;MICroProcessor:HT48R50A-1/28SKDIP-A*
;Author:www.picavr.com*
;Crystal:4MHz*
;********************************************
#INCLUDEHT48R50A-1.INC
LCD_DATAEQUPB
LCD_DATA_CTRLEQUPBC
LCD_CTRLEQUPC
LCD_CTRL_CTRLEQUPCC
EEQU5
RSEQU3
;--------------------------------------------------------------------
DATA.SECTIONAT60H’DATA’
DELAY_COUNTER_1DB?;[60H]
DELAY_COUNTER_2DB?;[61H]
DELAY_COUNTER_3DB?;[62H]
DATADB?;[63H]
COUNTERDB?;[64H]
EXE_INT_FLAGDB?;[65H]
;--------------------------------------------------------------------
CODE.SECTIONAT00H’CODE’
ORG00
JMPSTART
ORG04H
JMPINTERRUPT
ORG0CH
JMPTIMER1
ORG20H
START:
CLRLCD_DATA_CTRL
CLRLCD_CTRL_CTRL
CLRLCD_DATA
CLRLCD_CTRL
CLRPAC
CLREXE_INT_FLAG
CALLLCD_RESET
MOV A,0BH
MOV INTC,A
MOV A,80H
MOV TMR1C,A
SLEEP:
MOV A,OFFSETLCD_MESSAGE_1
MOV TBLP,A
CALLLCD_DISPLAY
HALT
;--------------------------------------------------------------------
SIZEXE_INT_FLAG
JMPPORT_7
JMPSLEEP
PORT_7:
MOV A,OFFSETLCD_MESSAGE_3
MOV TBLP,A
CALLLCD_DISPLAY
MOV A,OFFSETMUSIC_DATA
MOV TBLP,A
MOV A,08H
MOV COUNTER,A
PLAY_MUSIC:
TABRDLDATA
MOV A,DATA
MOV TMR1L,A
INCTBLP
TABRDLDATA
MOV A,DATA
MOV TMR1H,A
INCTBLP
SETTMR1C.4
CALLDELAY
SDZCOUNTER
JMPPLAY_MUSIC
CLRTMR1C.4
JMPSLEEP
RET
;--------------------------------------------------------------------
INTERRUPT:
MOV A,OFFSETLCD_MESSAGE_2
MOV TBLP,A
CALLLCD_DISPLAY
MOV A,10H
MOV COUNTER,A
MOV A,OFFSETSEGMENT_DATA
MOV TBLP,A
LOOP_INT:
TABRDLDATA
MOV A,DATA
MOV PA,A
CALLDELAY
INCTBLP
SDZCOUNTER
JMPLOOP_INT
SETPA
CLRINTC.4
SETEXE_INT_FLAG
RETI
;--------------------------------------------------------------------
TIMER1:
SZPC.2
JMPOUTPUT_0
SETPC.2
JMPOUTPUT_END
OUTPUT_0:
CLRPC.2
OUTPUT_END:
RETI
;--------------------------------------------------------------------
LCD_RESETPROC
MOV A,30H;LCDreset,step1
MOV LCD_DATA,A;
CALLWRITE;
CALLDELAY;LCDreset,step2
MOV A,30H;LCDreset,step3
MOV LCD_DATA,A;
CALLWRITE;
CALLDELAY;LCDreset,step4
MOV A,30H;LCDreset,step5
MOV LCD_DATA,A;
CALLWRITE;
MOV A,38H;LCDsetting,step1
MOV LCD_DATA,A;functionset
CALLWRITE;
MOV A,06H;LCDsetting,step2
MOV LCD_DATA,A;entrymodeset
CALLWRITE;
MOV A,01H;LCDsetting,step3
MOV LCD_DATA,A;displayclear
CALLWRITE;
CALLDELAY;
MOV A,0EH;LCDsetting,step4
MOV LCD_DATA,A;displayturnon
CALLWRITE;
RET
LCD_RESETENDP
;--------------------------------------------------------------------
LCD_DISPLAYPROC
MOV A,01H;LCDsetting,step5
MOV LCD_DATA,A;displayclear
CALLWRITE;
CALLDELAY;
MOV A,80H;LCDsetting,step6
MOV LCD_DATA,A;DDRAMaddresssetting
CALLWRITE;address=00h(firstline)
SETLCD_CTRL.RS;LCDsetting,step7
MOV A,10H;writedatatoDDRAM
MOV COUNTER,A
DISPLAY1:
TABRDLDATA
MOV A,DATA
MOV LCD_DATA,A
CALLWRITE
INCTBLP
SDZCOUNTER
JMPDISPLAY1
CLRLCD_CTRL.RS;
MOV A,0C0H;LCDsetting,step8
MOV LCD_DATA,A;DDRAMaddresssetting
CALLWRITE;address=40h(secondline)
SETLCD_CTRL.RS;LCDsetting,step9
MOV A,10H;writedatatoDDRAM
MOV COUNTER,A
DISPLAY2:
TABRDLDATA
MOV A,DATA
MOV LCD_DATA,A
CALLWRITE
INCTBLP
SDZCOUNTER
JMPDISPLAY2
CLRLCD_CTRL.RS
RET
LCD_DISPLAYENDP
;--------------------------------------------------------------------
WRITEPROC
SETLCD_CTRL.E
CLRLCD_CTRL.E
MOV A,0FFH
MOV DELAY_COUNTER_1,A
WAIT:
SDZDELAY_COUNTER_1
JMPWAIT
RET
WRITEENDP
;--------------------------------------------------------------------
DELAYPROC
MOV A,03H
MOV DELAY_COUNTER_1,A
MOV DELAY_COUNTER_2,A
MOV DELAY_COUNTER_3,A
DELAY_WAIT:
SDZDELAY_COUNTER_3
JMPDELAY_WAIT
SDZDELAY_COUNTER_2
JMPDELAY_WAIT
SDZDELAY_COUNTER_1
JMPDELAY_WAIT
RET
DELAYENDP
;--------------------------------------------------------------------
ORG0F00H
LCD_MESSAGE_1:;[PowerDownmode!]
;[IamsleePINg..!]
DC50H,6FH,77H,65H,72H,20H,44H,6FH
DC77H,6EH,20H,6DH,6FH,64H,65H,21H
DC49H,20H,61H,6DH,20H,73H,6CH,65H
DC65H,70H,69H,6EH,67H,2EH,2EH,21H
LCD_MESSAGE_2:;[INTBwakemeup!]
;[Goodmorningsir]
DC49H,4EH,54H,42H,20H,77H,61H,6BH
DC65H,20H,6DH,65H,20H,75H,70H,21H
DC47H,6FH,6FH,64H,20H,6DH,6FH,72H
DC6EH,69H,6EH,67H,20H,73H,69H,72H
LCD_MESSAGE_3:;[PA.7wakemeup!]
;[Iloveyoubaby]
DC50H,41H,2EH,37H,20H,77H,61H,6BH
DC65H,20H,6DH,65H,20H,75H,70H,21H
DC49H,20H,6CH,6FH,76H,65H,20H,79H
DC6FH,75H,20H,62H,61H,62H,79H,20H
SEGMENT_DATA:;7SEGMENTDATA(COMMONANODE)
DC081H,0CFH,092H,086H;0123
DC0CCH,0A4H,0A0H,08FH;4567
DC080H,084H,088H,0E0H;89AB
DC0B1H,0C2H,0B0H,0B8H;CDEF
MUSIC_DATA:;MUSICDATA
DC043H,0FCH,0B1H,0FCH
DC009H,0FDH,033H,0FDH
DC083H,0FDH,0C7H,0FDH
DC005H,0FEH,023H,0FEH
;--------------------------------------------------------------------
END