来源:中国一卡通网 作者:张敏 发布时间:2005-05-19 17:13:07 字体:[大 中 小]
关键字:关于非接触式IC智能(射频)卡及其读写设备内核技术的研究与应用开发(连载10)
摘 要:关于非接触式IC智能(射频)卡及其读写设备内核技术的研究与应用开发(连载10)
ACALL DISPLAYD500US:
D500US_LOOP1:
MOV R6,#05H
D500US_LOOP2:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DJNZ R6,D500US_LOOP2
DJNZ R7,D500US_LOOP1
RET
;----------------------------------------------------
D500MS:
setb psw.3
setb psw.4
MOV R3,#19H
LOOP_1: MOV R4,#32H
LOOP_2: MOV R5,#64H
LOOP_3: DJNZ R5,LOOP_3
DJNZ R4,LOOP_2
DJNZ R3,LOOP_1
clr psw.3
clr psw.4
RET
;--------------------------
D2S:
setb psw.3
setb psw.4
MOV R6,#06H
LOOP: ACALL D500MS
DJNZ R6,LOOP
clr psw.3
clr psw.4
RET
;--------------------------
SPK_ON:
setb psw.3
setb psw.4
CLR P2.7
ACALL D500MS
SETB P2.7
clr psw.3
clr psw.4
RET
;--------------------------
DISPLAY:
SETB PSW.3
SETB PSW.4
CLR P2.2 ;SELECT MC14499'S -ENB
MOV R0,#36H ;DISPLAY BUF FIRST ADDRESS
MOV R1,#05H ;R1 AS A COUNTER
NEXT_CHAR: MOV A , @R0
SWAP A
ACALL DISP_ONE
INC R0
DJNZ R1,NEXT_CHAR
SETB P2.2 ;RELEASE MC14499'S -ENB
CLR PSW.3
CLR PSW.4
RET
;--------------------------
DISP_ONE:
MOV R2,#04H
NEXT_BIT:SETB P2.1 ;SELECT MC14499'S CLK=1
RLC A ;ONE BIT MOVE TO PSW.C
MOV P2.0, C
CLR P2.1 ;CLK=0
DJNZ R2, NEXT_BIT
RET
;--------------------------
H_DISPLAY:
SETB PSW.3
SETB PSW.4
CLR P2.3 ; -ENB
MOV R0,#31H
MOV R1,#05H
NOP
NOP
H_NEXT_CHAR: MOV A, @R0
SWAP A
ACALL H_DISP_ONE
INC R0
DJNZ R1,H_NEXT_CHAR
SETB P2.3 ; -ENB
CLR PSW.3
CLR PSW.4
RET
;----------------------------
H_DISP_ONE:
MOV R2,#04H
H_NEXT_BIT: SETB P2.1 ; CLK
RLC A
MOV P2.0, C ; DATA
CLR P2.1 ; CLK
DJNZ R2, H_NEXT_BIT
RET
;===========================
INIT_DISP_BUF:
SETB PSW.3
SETB PSW.4
MOV R0,#0AH
MOV R1,#31H
INIT_AGAIN: MOV @R1,#00H ;SET 31H--40H UNITS AS 00H
INC R1
DJNZ R0, INIT_AGAIN
CLR PSW.3
CLR PSW.4
RET
;--------------------------
SEND_TO_BUF01:
SETB PSW.3
SETB PSW.4
MOV B,A
MOV 3AH,A ;(3AH)
SWAP A
MOV 39H,A ;(39H)
MOV A,B
CLR PSW.3
CLR PSW.4
RET
;--------------------------
SEND_TO_BUF23:
SETB PSW.3
SETB PSW.4
MOV B,A
MOV 38H,A ;(38H)
SWAP A
MOV 37H,A ;(37H)
MOV A,B
CLR PSW.3
CLR PSW.4
RET
;--------------------------
SET_POINT0:
SETB PSW.4
SETB PSW.3
MOV R1,#36H ;(36H)
MOV @R1,#01H
MOV R1,#31H ;(31H)
MOV @R1,#02H
CLR PSW.3
CLR PSW.4
RET
;--------------------------
INDICATE:
CLR P2.6 ;INDICATE P2.6 AS 0-1-0
SETB P2.6
ACALL D500MS
CLR P2.6
RET
;-----------------------------
;====================MCM REQUEST OPERATION====================
request:
RET
;--------------------------------------------------------------------
;===============MCM ANTICOLLISION OPERTION=============
anticollision:
RET
;--------------------------------------------------------------------
;====================MCM SELECT OPERATION=====================
select:
RET
;--------------------------------------------------------------------
;========================= AUTHENTICATION ========================
authentication:
RET
;--------------------------------------------------------------------
;========================= LOAD KEY =========================
LOAD_KEY:
RET
;--------------------------------------------------------------------
;====================MCM WRITE OPERATION=====================
write:
RET
;--------------------------------------------------------------------
;====================MCM read OPERATION=====================
read:
RET
;--------------------------------------------------------------------
;========================= HALT OPERATION==============================
halt:
MOV A,#10H
MOV R0,#03H
MOVX @R0,A
MOV A,#04H
MOV R0,#04H
MOVX @R0,A
MOV A,#50H
MOV R0,#00H
MOVX @R0,A
MOV A,#00H
MOV R0,#00H
MOVX @R0,A
;------------------------- SET TOC()= 0AH --------------------------
MOV A,#0AH
MOV R0,#06H
MOVX @R0,A ;TOC() = 0AH
;--------------------------- READ STACON() -------------------------
HALT_RD_STACON_AGAIN:
MOV R0,#01H
MOVX A,@R0 ;READ STACON()
;-------------------JUDGE DV FLAG ----------------------------------
JNB ACC.7,HALT_RD_STACON_AGAIN
;------------------- CLOSE TOC() -----------------------------------
MOV B,A
MOV A,#00AH
MOV R0,#06H
MOVX @R0,A ;TOC() = 00H
MOV A,B
;-------------------------JUDG ANY ERRORS --------------------------
JB ACC.6, HALT_OK_EXIT ;TE=1 IS HALT OK FLAG
;-----------------------HAVE ANY ERRORS ----------------------------
MOV B,#06H
LJMP HALT_ERR_EXIT
;-------------------------- EXIT -----------------------------------
HALT_OK_EXIT:
MOV B,#66H ;“ok”disp_flag
SETB P2.6 ;OK LAMP NOW WORKING P2.3
ACALL SPK_ON ;if ok then spk on
HALT_ERR_EXIT:
MOV A,B
ACALL SEND_TO_BUF01 ;SEND RETURN_VALE TO DISP_BUF_LOW
RET
;========================= End of MCM HALT OPERATION =======================
;-------------------- DISPLY READ BLOCK VALUE(16 BYTES) ---------------
DISP_RD_BLK:
MOV R0,#50H
MOV R7,#04H
DISP_RD_BLK_LOOP:
MOV A,@R0
LCALL H_SEND_TO_BUF23 ;SEND RETURN_VALE TO DISP_BUF_LOW
INC R0
MOV A,@R0
LCALL H_SEND_TO_BUF01 ;SEND RETURN_VALE TO DISP_BUF_HIGH
INC R0
MOV A,@R0
LCALL SEND_TO_BUF23 ;SEND RETURN_VALE TO H_DISP_BUF_LOW
INC R0
MOV A,@R0
LCALL SEND_TO_BUF01 ;SEND RETURN_VALE TO H_DISP_BUF_HIGH
INC R0
LCALL DISPLAY
LCALL H_DISPLAY
LCALL D500MS
LCALL D500MS
DJNZ R7,DISP_RD_BLK_LOOP
RET
;-------------CLEAR DISPLY_READ_BLOCK VALUE(16 BYTES) IN CPU RAM ----------
CLEAR_DISP_RD_BLK_IN_CPU:
MOV R0,#50H
MOV R7,#10H
CLEAR_DISP_RD_BLK_LOOP:
MOV @R0,#11H ;SEND #11H TO DISP_RD_BLK_IN_CPU
INC R0
DJNZ R7,CLEAR_DISP_RD_BLK_LOOP
RET
;---------------------KB SCANNING ----------------------------
KB_SCAN:
MOV A,#11110000B
mov p1,a ;send line value:0000 <---P1.0~~P1.3
CLR P2.0 ;enable KB scan function
mov a,p1 ;if there is a key_pad pressing?
orl a,#00001111b ;if no keypressing, A should be = 1111 1111b
cpl a
jz KB_nothing ;if A = 00h, then no key is pressed
lcall kb_look_pad ;if A <> 00h,then one key is pressed
SETB P2.6
LCALL SPK_ON
KB_nothing:
setb p2.0
RET
;========================= KB LOOK ONE PAD ========================