Skip to content

Commit

Permalink
Implemented start bit detection noise filter
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Sep 16, 2019
1 parent 9c37e25 commit e2db5f9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions com.serial.spin
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ entry mov t1,par 'get structure address
if_z_ne_c or outa,txmask
if_z or dira,txmask

test rxtxmode,#%001 wz 'wait for idle rx line
test rxmask,ina wc
if_z_ne_c jmp #$-2

mov txcode,#transmit 'initialize ping-pong multitasking

idle jmpret rxcode,txcode 'run chunk of tx code, then return

test rxtxmode,#%001 wz 'wait for idle rx line
test rxmask,ina wc
if_z_ne_c jmp #idle


receive jmpret rxcode,txcode 'run chunk of tx code, then return
Expand All @@ -187,6 +188,17 @@ receive jmpret rxcode,txcode 'run chunk of tx code, the
shr rxcnt,#1
add rxcnt,cnt

:start jmpret rxcode,txcode 'run chunk of tx code, then return

test rxtxmode,#%001 wz 'check start bit on rx pin
test rxmask,ina wc
if_z_eq_c jmp #receive

mov t1,rxcnt 'check if bit receive period done
sub t1,cnt
cmps t1,#0 wc
if_nc jmp #:start

:bit add rxcnt,bitticks 'ready next bit period

:wait jmpret rxcode,txcode 'run chunk of tx code, then return
Expand All @@ -213,7 +225,7 @@ receive jmpret rxcode,txcode 'run chunk of tx code, the
and t2,#BUFFER_MASK
wrlong t2,par

jmp #receive 'byte done, receive next byte
jmp #idle 'byte done, receive next byte



Expand All @@ -225,6 +237,7 @@ transmit jmpret txcode,rxcode 'run chunk of rx code, the
add t1,#1 << 2
rdlong t3,t1
cmp t2,t3 wz

if_z jmp #transmit

add t3,txbuff 'get byte and inc tail
Expand Down

0 comments on commit e2db5f9

Please sign in to comment.