; ********************************************
; Function : 基于HT48R50A的 93C46示例程序 *
; MICroProcessor : HT48R50A-1/28SKDIP-A *
; Author: www.picavr.com *
; Crystal : 4MHz *
; ********************************************
#INCLUDE HT48R50A-1.INC
LCD_DATA EQU PA
LCD_DATA_CTRL EQUPAC
LCD_CTRL EQU PC
LCD_CTRL_CTRL EQU PCC
E EQU 1
RS EQU 0
KEYIN_ERROR EQU 0AAH
EEPROM EQU PC
CS EQU 5
SK EQU 4
DI EQU 3
DO EQU 2
;------------------------------------------------------
DATA .SECTION AT 60H 'DATA'
DELAY_COUNTER_1 DB ? ;[60H]
DELAY_COUNTER_2 DB ? ;[61H]
COUNTER DB ? ;[62H]
COUNTER_1 DB ? ;[63H]
DATA DB ? ;[64H]
ADDRESS_BUFFER DB 3 DUP(?)
DATA_BUFFER DB 4 DUP(?)
DISPLAY_BUFFER DB 32 DUP(?)
;------------------------------------------------------
DATA_W MACRO M_DATA
SET LCD_CTRL.RS
MOV A,M_DATA
MOV LCD_DATA,A
CALL WRITE
ENDM
;------------------------------------------------------
INS_W MACRO M_INS
CLR LCD_CTRL.RS
MOV A,M_INS
MOV LCD_DATA,A
CALL WRITE
ENDM
;------------------------------------------------------
LCD_BUFFER MACRO
LOCAL BUFFER_1,BUFFER_2
MOV TBLP,A
MOV A,OFFSET DISPLAY_BUFFER
MOV MP0,A
MOV A,10H
MOV COUNTER,A
BUFFER_1:
TABRDC R0
INC TBLP
INC MP0
SDZ COUNTER
JMP BUFFER_1
MOV A,10H
MOV COUNTER,A
BUFFER_2:
TABRDC R0
INC MP0
INC TBLP
SDZ COUNTER
JMP BUFFER_2
CALL LCD_DISPLAY
ENDM
;------------------------------------------------------
CODE .SECTION AT 00H 'CODE'
ORG 00H
JMP START
START:
CLR LCD_DATA_CTRL
CLR LCD_DATA
MOV A,00000100B
MOV LCD_CTRL_CTRL,A
CLR LCD_CTRL
MOV A,00101111B
MOV PBC,A
CLR PB.4
;------------------------------------------------------
CALL DELAY
INS_W 00110000B ;LCD RESET
CALL DELAY
INS_W 00110000B ;LCD_RESET
CALL DELAY
INS_W 00111000B ;FUNCTION SET
INS_W 00000110B ;ENTRY MODE SET
INS_W 00000001B ;DISPLAY CLEAN
CALL DELAY ;DELAY SOME TIME
INS_W 00001111B ;DISPLAY TURN ON
;------------------------------------------------------
CALL MESSAGE_01
CALL GET_KEY
MANUAL_PAGE_1:
CALL MESSAGE_02
INS_W 11001111B
CHOOSE_1:
CALL GET_KEY
SUB A,01H
SZ ACC
JMP CHOOSE_2
JMP FUNCTION_1
CHOOSE_2:
MOV A,DATA
SUB A,02H
SZ ACC
JMP CURSOR_DOWN_1
JMP FUNCTION_2
CURSOR_DOWN_1:
MOV A,DATA
SUB A,0DH
SZ ACC
JMP CHOOSE_1
MANUAL_PAGE_2:
CALL MESSAGE_03
INS_W 11001111B
CHOOSE_3:
CALL GET_KEY
SUB A,03H
SZ ACC
JMP CHOOSE_4
JMP FUNCTION_3
CHOOSE_4:
MOV A,DATA
SUB A,04H
SZ ACC
JMP CURSOR_UP_2
JMP FUNCTION_4
CURSOR_UP_2:
MOV A,DATA
SUB A,0CH
SZ ACC
JMP CURSOR_DOWN_2
JMP MANUAL_PAGE_1
CURSOR_DOWN_2:
MOV A,DATA
SUB A,0DH
SZ ACC
JMP CHOOSE_3
MANUAL_PAGE_3:
CALL MESSAGE_04
INS_W 11001111B
CHOOSE_5:
CALL GET_KEY
SUB A,05H
SZ ACC
JMP CHOOSE_6
JMP FUNCTION_5
CHOOSE_6:
MOV A,DATA
SUB A,06H
SZ ACC
JMP CURSOR_UP_3
JMP FUNCTION_6
CURSOR_UP_3:
MOV A,DATA
SUB A,0CH
SZ ACC
JMP CURSOR_DOWN_3
JMP MANUAL_PAGE_2
CURSOR_DOWN_3:
MOV A,DATA
SUB A,0DH
SZ ACC
JMP CHOOSE_5
MANUAL_PAGE_4:
CALL MESSAGE_05
INS_W 11001111B
CHOOSE_7:
CALL GET_KEY
SUB A,07H
SZ ACC
JMP CURSOR_UP_4
JMP FUNCTION_7
CURSOR_UP_4:
MOV A,DATA
SUB A,0CH
SZ ACC
JMP CHOOSE_7
JMP MANUAL_PAGE_3
RET
;------------------------------------------------------
FUNCTION_1:
CALL MESSAGE_06
INS_W 11000100B
CALL ENTER_ADDRESS
MOV A,DATA
SUB A,KEYIN_ERROR
SZ ACC
JMP FUN_NEXT_1
JMP FUN_END_1
FUN_NEXT_1:
CALL HT93LC46_READ
CALL MESSAGE_08