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
13 ;---------------------------------------------------------------------------
14 ; reserved access bank locations
16 WREG2 equ 00h ; a 2nd working reg :-)
17 WREG3 equ 01h ; a 3rd working reg :-)
18 WREG4 equ 02h ; a 4th working reg :-)
19 BLANK equ 03h ; register full of zeros
20 TESTFLASH equ 04h ; test LED flash pattern
24 ;---------------------------------------------------------------------------
25 ; memory location definitions
27 ERROR_BUF_PAGE equ 3 ; error codes on flash p3
28 F_ERROR_U equ 30h ; upper part of error memory locations
29 F_SOS_H equ 00h ; high (middle) part of SOS error memory loc.
30 F_SOS_L equ 00h ; lower part of SOS error memory loc.
33 ;---------------------------------------------------------------------------
36 err_SOS equ 0 ; msg 0 = SOS
38 ;****************************************************************************
41 ;****************************************************************************
43 ;----------------------------------------
45 ; Flashes the per-pic led red and black in a specified pattern.
46 ; The pattern is specified as the state for 8 identically-long time
47 ; periods each as long as a morse `dot', encoded into a byte with
48 ; most significant bit first.
51 ; WREG2 flash pattern preserved
54 clrf WREG4,0 ; clear loop counter (WREG4)
59 cpfslt WREG4,0 ; if loop counter >=8, return
62 rlncf WREG2,1 ; top bit goes into N flag, ie Negative if 1
71 incf WREG4,1,0 ; increment loop counter
76 ;****************************************************************************
77 ; this is what happens when we panic
80 ; switch off interrupts and power
81 ; reconfigure timer0 for writing diagnostic msg to the LED
83 clrf INTCON,0 ; disable all interrupts EVER
84 bcf PORTC,1,0 ; switch off booster
90 ; re-initialise timer0 config
91 bcf T0CON,6,0 ; p107 Timer0 -> 16bit mode
92 bcf T0CON,5,0 ; timer0 use internal clock
93 bcf T0CON,3,0 ; use prescaler
95 bcf T0CON,1,0 ; } prescale value 1:32 (13ms x 32)
100 ; errmsg err_SOS,0 ; transmit SOS in red
101 movff TESTFLASH,WREG2
103 ; readout BLANK,0 ; transmit blank buffer
108 ;****************************************************************************
109 ; GENERAL SUBROUTINES
111 ;----------------------------------------
113 ; waits for a fixed interval, depending on the configuration of TMR0
115 bcf INTCON,2,0 ; clear timer0 interrupt bit (p109)
116 clrf TMR0H,0 ; p107 set high byte of timer0 to 0 (buffered,
117 ; only actually set when write to tmr0l occurs)
118 clrf TMR0L,0 ; set timer0 low byte - timer now set to 0000h
120 btfss INTCON,2,0 ; check whether timer0 interrupt has been set -
121 ; skip next instruction if so
126 ;****************************************************************************