From: ian Date: Sun, 10 Apr 2005 20:37:55 +0000 (+0000) Subject: readout works X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=9a7520fa1c2da04d1a58f6213e2625539f2e0c2e;p=trains.git readout works --- diff --git a/cebpic/panic.asm b/cebpic/panic.asm index 4b034ec..4d885ce 100644 --- a/cebpic/panic.asm +++ b/cebpic/panic.asm @@ -77,47 +77,36 @@ err_SOS equ 0 ; msg 0 = SOS ; endm ;---------------------------------------- -; readout(READOUTREG,GREEN) -; transmits the contents of the chosen byte by flashing LED -; in chosen colour [GREEN=1: green (=blue); GREEN=0: red (=orange)] - -; NB using WREG2 as copy of READOUTREG contents -; using WREG3 as GREEN store -; using WREG4 as counter - - -readout macro ERRCODE, GREEN - movlw GREEN - movwf WREG3,0 ; copy GREEN into WREG3 +readout +; Flashes the per-pic led red and black in a specified pattern. +; The pattern is specified as the state for 8 identically-long time +; periods each as long as a morse `dot', encoded into a byte with +; most significant bit first. +; On entry On exit +; W any undefined +; WREG2 flash pattern preserved +; WREG4 any undefined +; clrf WREG4,0 ; clear loop counter (WREG4) - movff ERRCODE,WREG2 ; copy ERRCODE into WREG2 + rrncf WREG2,1 readout_loop movlw 8 cpfslt WREG4,0 ; if loop counter >=8, return return - rlcf WREG2,1 - bc readout_led_off - bra readout_led_on - -readout_led_on - ifbit0 WREG3,0 ; check desired colour - call led_red - ifbit1 WREG3,0 - call led_green - incf WREG4,1,0 ; increment loop counter - call waiting - goto readout_loop - -readout_led_off + rlncf WREG2,1 ; top bit goes into N flag, ie Negative if 1 + bn readout_if_led_on +readout_if_led_off call led_black + bra readout_endif_led + +readout_if_led_on + call led_red +readout_endif_led incf WREG4,1,0 ; increment loop counter call waiting - goto readout_loop - - endm - + bra readout_loop ;**************************************************************************** @@ -223,7 +212,8 @@ informative_panic clrf BLANK,0 panic_loop ; errmsg err_SOS,0 ; transmit SOS in red - readout TESTFLASH,0 ; transmit contents of SSPCON1 in red + movff TESTFLASH,WREG2 + rcall readout ; readout BLANK,0 ; transmit blank buffer call led_green call waiting