avr: add an initial wait time before starting the node.
This allows for desyncing of nodes to reduce COM collisions.
This commit is contained in:
39
avr/main.asm
39
avr/main.asm
@@ -13,6 +13,10 @@ main:
|
|||||||
out SPL, r16 ; init LSB stack pointer
|
out SPL, r16 ; init LSB stack pointer
|
||||||
|
|
||||||
rcall initModules
|
rcall initModules
|
||||||
|
|
||||||
|
rcall Utils_SetupUid
|
||||||
|
|
||||||
|
rcall initialWait
|
||||||
sei ; Enable interrupts
|
sei ; Enable interrupts
|
||||||
|
|
||||||
rcall onSystemStart
|
rcall onSystemStart
|
||||||
@@ -271,6 +275,41 @@ sendValueMsg_done:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; initialWait
|
||||||
|
;
|
||||||
|
; Initial wait to desync nodes.
|
||||||
|
;
|
||||||
|
; This routine waits for between 10 to 2560 milliseconds (derived from UID)
|
||||||
|
;
|
||||||
|
; IN:
|
||||||
|
; - nothing
|
||||||
|
; OUT:
|
||||||
|
; - nothing
|
||||||
|
; USED: r16, r17, r18, r19, r20, r21, r22, X
|
||||||
|
|
||||||
|
initialWait:
|
||||||
|
; setup initial wait loop
|
||||||
|
rcall Utils_ReadUid ; (R16, X)
|
||||||
|
clr r16
|
||||||
|
eor r16, r18
|
||||||
|
eor r16, r19
|
||||||
|
eor r16, r20
|
||||||
|
eor r16, r21
|
||||||
|
|
||||||
|
initialWait_l1: ; wait R16 x 10 milliseconds
|
||||||
|
ldi r17, 200
|
||||||
|
initialWait_l2: ; wait for 10ms
|
||||||
|
Utils_WaitNanoSecs 50000, 0, r22 ; wait for 50 microseconds
|
||||||
|
dec r17
|
||||||
|
brne initialWait_l2
|
||||||
|
dec r16
|
||||||
|
brne initialWait_l1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
textStatsPacketsIn: .db "In : ", 0
|
textStatsPacketsIn: .db "In : ", 0
|
||||||
textStatsPacketsRecvErr: .db "RecvErr: ", 0
|
textStatsPacketsRecvErr: .db "RecvErr: ", 0
|
||||||
textStatsPacketsOut: .db "Out : ", 0
|
textStatsPacketsOut: .db "Out : ", 0
|
||||||
|
|||||||
Reference in New Issue
Block a user