extern led_red
extern led_black
+;---------------------------------------------------------------------------
+panic macro message
+ movlw (message - morse_messages_start)/4
+ movwf PANIC_ADDRESS
+ goto panic_routine
+ endm
+
;---------------------------------------------------------------------------
; reserved access bank locations
WREG4 equ 02h ; a 4th working reg :-)
BLANK equ 03h ; register full of zeros
TESTFLASH equ 04h ; test LED flash pattern
+
+; used in panic macro for temporary storage
+PANIC_MORSE equ 05h ; stores # bytes of morse msg in panic readout
+PANIC_REGS equ 06h ; stores # registers in panic readout
+PANIC_ADDRESS equ 07h ; stores condensed form of message start addr.
+
+
+
+
+
+
+
+; constants
+
MORSE_MSG_LENGTH equ 04h ; lenght of morse messages in bytes
; INTERRUPT SUBROUTINES
interrupt_low
- goto informative_panic
+ panic morse_TF
-informative_panic
+panic_routine
; switch off interrupts and power
; reconfigure timer0 for writing diagnostic msg to the LED
bsf T0CON,1,0 ; } prescale value 1:16 (13ms x 16)
bsf T0CON,0,0 ; }
+; get # bytes of morse msg, # registers in panic readout, message start addr.
+; back from condensed message start addr. stored in PANIC_ADDRESS
+
+ movlw 4
+ mulwf PANIC_ADDRESS
+ movff PRODL,TBLPTRL
+ movff PRODU,WREG
+ add_lw (morse_messages_start)/256
+ movwf TBLPTRH
+ clr_f TBLPTRU
+
+ tblrd *+ ; read 1st byte of error message
+ ; (gives # bytes morse, # bytes registers)
+
+ movff TABLAT,PANIC_MORSE
+ movlw 00001111b
+ and_wff PANIC_MORSE ; PANIC_MORSE now contains # bytes of morse msgs
+
+ movff TABLAT,PANIC_REGS
+ movlw 01110000b
+ and_wff PANIC_REGS
+ swap_f PANIC_REGS ; PANIC_REGS now contains # registers to read
+
+
panic_loop
- mov_lw 0x5a
- mov_wf TESTFLASH
call led_black
call waiting
call waiting
; (currently 4-byte) morse msg
morse_msg_start
- movlw F_ERROR_U ; set table pointer to point to
- movwf TBLPTRU ; start of msg
- movlw F_SOS_H
- movwf TBLPTRH
- movlw F_SOS_L
- movwf TBLPTRL
-
clrf WREG3,0 ; clear loop counter (WREG3)
morse_loop
- mov_lw MORSE_MSG_LENGTH
+ mov_lw PANIC_MORSE
cmp_fw_ifge WREG3 ; if loop counter >=MORSE_MSG_LENGTH,
return ; return to panic
;--------------------------
registermsg
- mov_ff TESTFLASH,WREG2
- call register_readout
- return
+register_msg_start
+ clrf WREG3,0 ; clear loop counter (WREG3)
+
+register_loop
+ mov_lw PANIC_REGS
+ cmp_fw_ifge WREG3 ; if loop counter >=MORSE_MSG_LENGTH,
+ return ; return to panic
+
+ tblrd *+
+ mov_ff TABLAT,WREG2
+ call register_readout
+ inc_f WREG3
+ goto register_loop
+
;--------------------------
register_readout