From 706a9b599d3c941c0c5a1a746156fcd56419a298 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 19 Dec 2005 15:15:42 +0000 Subject: [PATCH] unattended timeout fixed up --- detpic/detect.asm | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/detpic/detect.asm b/detpic/detect.asm index 5b23980..62263a2 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -61,8 +61,9 @@ max_messages equ 4 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 @@ -138,7 +139,7 @@ detect_slave_init mov_lfsr outbuf, 2 clr_f outmsg_end - goto reset_message_buffer + goto reset_detectread ;---------------------------------------- slave_add_short_message @@ -176,8 +177,14 @@ i2csu_read_another ;---------- 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 @@ -296,9 +303,6 @@ i2csu_read_begin_either_tail set_f scana set_f scand - call led_green - set_f unattended - mov_lfsr message_buffer, 1 msg_copy_loop mov_fw POSTINC1 @@ -308,11 +312,35 @@ msg_copy_loop 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 ;---------- -- 2.30.2