; panicing which would be bad because we might forget to panic).
mov_wf panic_address
-
+ clr_f STKPTR ; avoids stack overruns
; re-initialise timer0 config
- bc_f T0CON,6 ; p107 Timer0 -> 16bit mode
- bc_f T0CON,5 ; timer0 use internal clock
- bc_f T0CON,3 ; use prescaler
- bc_f T0CON,2 ; }
- bs_f T0CON,1 ; } prescale value 1:8 (13ms x 8)
- bc_f T0CON,0 ; }
+ mov_lw (1<<TMR0ON) | 011b ; Enable, 16-bit, timer, prescaler 1:16
+ mov_wf T0CON ; => PSout is 312.5kHz or 3.2us per period (DS p108)
+ ; We want to wait 66ms (morse at 18wpm according to the PARIS standard
+ ; is a unit time of 66ms), or 20,833 PSout cycles:
+waiting_t0cycles equ 20833 ; see by `waiting', below
; get # bytes of morse msg, # registers in panic readout, message start addr.
; back from condensed message start addr. stored in panic_address
swap_f panic_regs ; panic_regs now contains # registers to read
call led_black
- call waiting
- call waiting
- call waiting
- call waiting
- call waiting
- call waiting
- call waiting
- call waiting
+ call waiting16
call morsemsg ; transmit morse in red
call led_black
- call waiting
- call waiting
- call waiting
- call waiting
+ call waiting8
+ call waiting4
call registermsg ; transmit contents of registers in
; red(=low) and blue(=high)
+ call waiting16
goto panic_loop
;****************************************************************************
inc_f register_counter ;increment loop counter
- call waiting
- call waiting
+ call waiting8
goto register_loop
;--------------------------
cmp_fw_ifne bit_counter ; if loop counter !=4 (nybble length),
; skip insertion of extra black space
goto not_nybble_boundary
- call waiting
+ call waiting4
not_nybble_boundary
rl_f flash_pattern ; top bit goes into N flag,
; GENERAL SUBROUTINES
;----------------------------------------
+waiting16 rcall waiting8
+waiting8 rcall waiting4
+waiting4 rcall waiting2
+waiting2 rcall waiting
waiting
; waits for a fixed interval, depending on the configuration of TMR0
bc_f INTCON,2 ; clear timer0 interrupt bit (p109)
- clr_f TMR0H ; p107 set high byte of timer0 to 0 (buffered,
+; Interrupt happens on overflow. So start at 65535-waiting_t0cycles:
+ mov_lw (65535-waiting_t0cycles) / 256
+ mov_wf TMR0H ; p107 set high byte of timer0 (buffered,
; only actually set when write to tmr0l occurs)
- clr_f TMR0L ; set timer0 low byte - timer now set to 0000h
+ mov_lw (65535-waiting_t0cycles) & 0xff
+ mov_wf TMR0L ; set timer0 low byte - timer now set
waiting_loop
bt_f_if0 INTCON,TMR0IF
bra waiting_loop ; wait for timer0 interrupt