chiark / gitweb /
morsepanic reading from morse-auto.asm etc.
authorceb <ceb>
Sun, 15 May 2005 23:02:37 +0000 (23:02 +0000)
committerceb <ceb>
Sun, 15 May 2005 23:02:37 +0000 (23:02 +0000)
cebpic/morse-auto.messages
cebpic/morsepanic.asm

index a5aeca40543b51d2865ba6de72fa1e19e666871c..1f34a7160c55d76f316c9fa18470e2bde060fd77 100644 (file)
@@ -25,3 +25,4 @@ SD    SSPCON2                 ; Slave didn't I2C ack data
 # Messages starting with T are temporary entries for testing and development
 TM     PIE1,SSPSTAT,SSPCON1,SSPCON2 ; Master got I2C interrupt
 TS     PIE1,SSPSTAT,SSPCON1,SSPCON2 ; Slave got I2C interrupt
+TF     TESTFLASH                    ; test flash message
index a5d7e7954eda05f91317bf146c9e4db6731bd771..84e9428c52c91072b132142801e3caea9e4550ec 100644 (file)
        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
 
@@ -23,6 +30,20 @@ WREG3                equ     01h     ; a 3rd working reg :-)
 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
 
 
@@ -120,9 +141,9 @@ vector_reset
 ; 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
 
@@ -138,9 +159,31 @@ informative_panic
         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
@@ -164,17 +207,10 @@ morsemsg
 ; (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
 
@@ -225,9 +261,20 @@ morse_readout_endif_led
 ;--------------------------
 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