Datasheet
Jon Waddington
49
The code below is written in PASM and decodes RC5 codes received at the Propellers
input pin.
DAT
org 0
go mov addr, PAR
mov outmask, dira 'backup dira in outmask
xor outmask, rxmask 'xor rx pin with outmask
and dira, outmask 'and' 'xor'ed outmask with dira
detect mov rxcode, #0
mov count, cnt
add count, delay
waitcnt count, 0
waitpne rxmask, rxmask 'Wait for start bit
mov start, cnt 'time start bit pulse
waitpeq rxmask, rxmask
mov half, cnt
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 'short delay
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










