1 ; program writes SOS msg into flash then turns LED green
2 ; when serial interrupt received, turns off interrupts, turns off
3 ; power, transmits contents of SSPCON1 by flashing LED red, repeats
4 ; (next version will transmit SOS code first, then contents of
8 ; to start, need to write into flash, starting at 30 0000h:
9 ; 10 10 10 00 | 1110 1110 | 1110 00 10 | 10 10
17 extern informative_panic
20 ;---------------------------------------------------------------------------
21 ; reserved access bank locations
23 WREG2 equ 00h ; a 2nd working reg :-)
24 WREG3 equ 01h ; a 3rd working reg :-)
25 WREG4 equ 02h ; a 4th working reg :-)
26 BLANK equ 03h ; register full of zeros
27 TESTFLASH equ 04h ; test LED flash pattern
31 ;---------------------------------------------------------------------------
32 ; memory location definitions
34 ERROR_BUF_PAGE equ 3 ; error codes on flash p3
35 F_ERROR_U equ 30h ; upper part of error memory locations
36 F_SOS_H equ 00h ; high (middle) part of SOS error memory loc.
37 F_SOS_L equ 00h ; lower part of SOS error memory loc.
40 ;---------------------------------------------------------------------------
43 err_SOS equ 0 ; msg 0 = SOS
45 ;****************************************************************************
48 ;****************************************************************************
50 ;----------------------------------------
52 ; Flashes the per-pic led red and black in a specified pattern.
53 ; The pattern is specified as the state for 8 identically-long time
54 ; periods each as long as a morse `dot', encoded into a byte with
55 ; most significant bit first.
58 ; WREG2 flash pattern preserved
61 clrf WREG4,0 ; clear loop counter (WREG4)
66 cpfslt WREG4,0 ; if loop counter >=8, return
69 rlncf WREG2,1 ; top bit goes into N flag, ie Negative if 1
78 incf WREG4,1,0 ; increment loop counter
83 ;****************************************************************************
84 ; this is what happens when we panic
87 ; switch off interrupts and power
88 ; reconfigure timer0 for writing diagnostic msg to the LED
90 clrf INTCON,0 ; disable all interrupts EVER
91 bcf PORTC,1,0 ; switch off booster
97 ; re-initialise timer0 config
98 bcf T0CON,6,0 ; p107 Timer0 -> 16bit mode
99 bcf T0CON,5,0 ; timer0 use internal clock
100 bcf T0CON,3,0 ; use prescaler
102 bcf T0CON,1,0 ; } prescale value 1:32 (13ms x 32)
107 ; errmsg err_SOS,0 ; transmit SOS in red
108 movff TESTFLASH,WREG2
110 ; readout BLANK,0 ; transmit blank buffer
115 ;****************************************************************************
116 ; GENERAL SUBROUTINES
118 ;----------------------------------------
120 ; waits for a fixed interval, depending on the configuration of TMR0
122 bcf INTCON,2,0 ; clear timer0 interrupt bit (p109)
123 clrf TMR0H,0 ; p107 set high byte of timer0 to 0 (buffered,
124 ; only actually set when write to tmr0l occurs)
125 clrf TMR0L,0 ; set timer0 low byte - timer now set to 0000h
127 btfss INTCON,2,0 ; check whether timer0 interrupt has been set -
128 ; skip next instruction if so
133 ;****************************************************************************