Application Note
RF Link Using the Z86E08
AN005801-Z8X0500
28
RF_WAIT: ld RCV_STATUS,#BIT1 ; RCV_STATUS = RF_DATA_WAIT
call TIMEOUT1 ; (causes s/w to skip preamble test)
ld IMR,#RFTMR0_IMR ; enable IRQ0 and IRQ4
clr IRQ ; clear interrupts
iret ; return to MAIN loop
RF_VERIFY: cp TOFROM,#0h ; if TOFROM = 0, message is a
jr z,PACK_VERIFY ; 'BROADCAST' message
ld rftofrom,TOFROM ; else verify TO Address
swap rftofrom ;
and rftofrom,#0fh ;
cp rftofrom,MY_ADDR ; exit if address not equal to
jr nz,RF_EXIT ; MY_ADDR
PACK_VERIFY:cp PACKET,#8h ; verify Valid Packet #
jr gt,RF_EXIT ; if 1 <= PACKET <=8
cp PACKET,#1h ; else PACKET # is invalid
jr lt,RF_EXIT ; and module is exited
call FCS ; verify FCS (checksum)
cp FCSHI,EFCSHI ; compare calclated (FCSHI/LO)
jr nz,RF_EXIT ; to the received (EFCSHI/LO)
cp FCSLO,EFCSLO ; exit if FCS fails
jr nz,RF_EXIT ;
call RF_ACK ; Send 'ACK' to PC if FCS is okay
call PC_XMT_DATA ; transmit Message to PC
cp TOFROM,#0h ; Check if message is a 'BROADCAST'
jr z,DELAY1200 ; if 'BROADCAST', Delay 1.2ms
jr RF_EXIT ; then exit module
RF_FAIL: tm RCV_STATUS,#BIT5 ; if RCV_STATUS = RF_ECHO_WAIT
jr z,RF_EXIT ; exit module
clr BYTECNT ;
jp RF_RETRY ; else RETRY
RF_EXIT: clr BYTECNT ; clear global variables
clr RCV_STATUS ;
ld IMR,#PCRF_IMR ; enable IRQ0 and IRQ2
clr IRQ ; clear interrupts
iret ; return to MAIN loop
DELAY1200: ld r12,#240 ; 1200ms delay loop
D1200_LOOP: call DELAY5MS ; perform 240 5ms delay loops
djnz r12,D1200_LOOP ;
jr RF_EXIT ;
;*****************************************************************************
; RF_SAMPLE: (CALL)
; Entry: Enter module from RF_RCV
; INPUT: Serial Data on P32
; OUTPUT: 'result' (local variable)
; Definition: Module sample P32 input 11 times. P32 is masked and
; a running sum is calculated in the 'result' register. This 'result'
; is used to determine whether the average sample was a '1' or '0' by
; comparing the value to 16h (22).
;*****************************************************************************
RF_SAMPLE: