udata_acs
-unattended res 1 ; counts down once for each det loop
- ; and if it reaches 0, led is set to red
+unattendedl res 1 ; counts up; each det loop it is
+unattendedh res 1 ; incremented by no. of bytes of pc in
+unattendedu res 1 ; det loop; if it overflows, led is set to red
scana res 1 ; see bit-twiddling below
scanb res 1
mov_lfsr outbuf, 2
clr_f outmsg_end
- goto reset_message_buffer
+ goto reset_detectread
;----------------------------------------
slave_add_short_message
;----------
backgroundloop_again macro backgroundloop_whatever
- dec_f_ifnz unattended
+ local branchposition
+ inc_f_ifnz unattendedl
bra backgroundloop_whatever
+ mov_lw branchposition - backgroundloop_whatever
+branchposition
+ add_wff unattendedh
+ bra_nc backgroundloop_whatever
+ inc_f_ifz unattendedu
call led_red
bra backgroundloop_whatever
endm
set_f scana
set_f scand
- call led_green
- set_f unattended
-
mov_lfsr message_buffer, 1
msg_copy_loop
mov_fw POSTINC1
mov_ff FSR2L, outmsg_end
mov_ff buf0_startval, buf0
-reset_message_buffer
+reset_detectread
; FSR1/buf0/message_buffer any set to empty
+; unattended* any reset
+; Per-PIC LED any black
; may be called from High ISR or during init
mov_lfsr message_buffer, 1
clr_f INDF1
+
+ call led_black
+
+unattended_timeout equ 100 ; ms
+ set_f unattendedl
+ ; Fosc = sclock [kHz]
+ ; Fcy = sclock / 4 [kHz]
+ ; program counter advance rate = 2 * sclock / 4 [bytes/ms]
+ ; unattendedh increment rate = pc advance rate / 256
+ ; = 2 * sclock / (4 * 256) [counts/ms]
+ ; count needed before show unattended = uah rate * ua timeout
+ ; = (2 * sclock / (4 * 256) [counts/ms])
+ ; * (unattended_timeout [ms])
+ ; = (2 * sclock / (4 * 256)) * unattended_timeout [counts]
+ ; = sclock * unattended_timeout / 512 [counts]
+ ; we count up until overflow, so
+unattended_init equ 65535 - (sclock * unattended_timeout / 512)
+ mov_lw unattended_init / 256
+ mov_wf unattendedu
+ mov_lw unattended_init & 255
+ mov_wf unattendedh
+
return
;----------