Datasheet

Jon Waddington
103
sub half, start 'half - start = start pulse length, should be about 71120 (80MHz * 889us)
cmp lh, half wz, wc 'check that the half value is between the upper and lower limits
if_nc jmp #detect
cmp uh, half wz, wc
if_z_or_c jmp #detect
Sb2 mov count, cnt 'wait 3T/4 to detect second start bit
add count, tquart
waitcnt count, 0
test rxmask, ina wz 'check second start bit
if_nz jmp #detect 'jump to detect if zero not detected
mov _l, #12 'set up loop iteration
mov count, cnt 'begin receiving rc5 code
add count, full 'wait full time period
loop waitcnt count, full 'wait full time period
test rxmask, ina wc 'test rx
if_nc add rxcode, #1 'add 1 if rx is low
shl rxcode, #1 'shift rxcode left
djnz _l, #loop 'loop until full code is received
shr rxcode, #1
wrlong rxcode, addr 'write rxcode to hub
mov time, cnt
add time, delay
waitcnt time, 0 'wait a bit
jmp #detect 'go back to detect next code
rxmask long 0 'IR input pin
lh long 70000 'lower threshold of half bit time
uh long 75000 'upper threshold of half bit time
thalf long 0 'calculated half bit time
quart long 0 'calculated 1/4 bit time
tquart long 0 'calculated 3/4 bit time
full long 0 'calculated full bit time
_l long 0
delay long 5_000_000
half long 0 'timed half bit time
outmask res 1
time res 1
start res 1
addr res 1 'PAR address
rxcode res 1
count res 1
frame res 1