WREG4 equ 02h ; a 4th working reg :-)
BLANK equ 03h ; register full of zeros
TESTFLASH equ 04h ; test LED flash pattern
+MORSE_MSG_LENGTH equ 04h ; lenght of morse messages in bytes
; memory location definitions
ERROR_BUF_PAGE equ 3 ; error codes on flash p3
-F_ERROR_U equ 30h ; upper part of error memory locations
-F_SOS_H equ 00h ; high (middle) part of SOS error memory loc.
+F_ERROR_U equ 00h ; upper part of error memory locations
+F_SOS_H equ 40h ; high (middle) part of SOS error memory loc.
F_SOS_L equ 00h ; lower part of SOS error memory loc.
org 000018h
goto interrupt_low
-;
+
+;****************************************************************************
+;ERROR MSGS
+
+ org 4000h
+ dw 1110111010101000b
+ dw 1010000011100010b
+
+;---------------------------------------------------------------------------
+; Main - go to interrupt
+ goto interrupt_low
+
;****************************************************************************
code
bsf PIE1,5,0 ; enable USART receive interrupt (p85)
;---------------------------------------------------------------------------
-
-; write error code for SOS into flash memory (starting at 30 0000h)
- movlw F_ERROR_H ; set table pointer to point to
- movwf TBLPTRU ; start of flash p3
- movlw F_SOS_H
- movwf TBLPTRH
- movlw F_SOS_L
- movwf TBLPTRL
-
-; write message into memory, incrementing tbl pointer each time
-
- movlw 10101000b
- movwf TABLAT
- tblwt*+
-
- movlw 11101110b
- movwf TABLAT
- tblwt*+
-
- movlw 11100010b
- movwf TABLAT
- tblwt*+
-
- movlw 10100000b
- movwf TABLAT
- tblwt*+
-
;---------------------------------------------------------------------------
-; turn LED green if we have made it this far....
-
- call led_green
-main_loop_led
- goto main_loop_led
-
+; Main - go to interrupt
+ goto interrupt_low
;****************************************************************************
; INTERRUPT SUBROUTINES
clrf INTCON,0 ; disable all interrupts EVER
bcf PORTC,1,0 ; switch off booster
- movlw 10101100b
- movwf TESTFLASH
-
; re-initialise timer0 config
bcf T0CON,6,0 ; p107 Timer0 -> 16bit mode
bsf T0CON,1,0 ; } prescale value 1:16 (13ms x 16)
bsf T0CON,0,0 ; }
- clrf BLANK,0
panic_loop
-; errmsg err_SOS,0 ; transmit SOS in red
- movff TESTFLASH,WREG2
- rcall readout
-; readout BLANK,0 ; transmit blank buffer
- call led_black
call waiting
+ call led_green
call waiting
+ call morse_msg_start ; transmit SOS in red
goto panic_loop
;****************************************************************************
; 8-byte msg
morse_msg_start
- movlw F_ERROR_H ; set table pointer to point to
+ movlw F_ERROR_U ; set table pointer to point to
movwf TBLPTRU ; start of flash p3
movlw F_SOS_H
movwf TBLPTRH
movlw F_SOS_L
movwf TBLPTRL
- clrf WREG3,0 ; clear loop counter (WREG4)
+ clrf WREG3,0 ; clear loop counter (WREG3)
morse_loop
- movlw 8
- cpfslt WREG3,0 ; if loop counter >=8, goto start of msg
- goto morse_msg_start
+ movlw MORSE_MSG_LENGTH
+ cpfslt WREG3,0 ; if loop counter >=MORSE_MSG_LENGTH,
+ ; retun to panic
+ return
tblrd*+
movff TABLAT,WREG2
call readout
- incf WREG3
+ incf WREG3,1,0
goto morse_loop
-
;--------------------------
readout
; Flashes the per-pic led red(0) and green(1) in a specified pattern.
bn readout_if_led_1
readout_if_led_0
- call led_red
+ call led_black
bra readout_endif_led
readout_if_led_1
- call led_green
+ call led_red
readout_endif_led
incf WREG4,1,0 ; increment loop counter
call waiting
- call led_black
- call waiting
bra readout_loop
;****************************************************************************