# Miscellaneous
E ; `expected'; we were told to panic
+
+# Regarding communications from the host
HX ::t ; host sent unknown command
HW ::t ; host sent message which was too long
HO ; host RS232 read overrun
HF ; host RS232 framing error
+HN ; host sent too much NMRA - buffers full
# Problematic interrupts
IH INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.)
serial_receive_done
intrl_handled_nostack
-receive_message_too_long
- panic morse_HW
- fixme reviewed up to here for inclusion in bigger program
+receive_too_much_nmra panic morse_HW
+receive_message_too_long panic morse_HW
; *** I *think* the interrupt bit is cleared by reading out of RCREG
; but this may be something to try in debugging if stuff doesn't work
debug '5'
mov_fw fromserial ; W = 00BB0000
add_lw 0x10 ; W = 0?CC0000
- bc_w 6 ; W = 00CC0000
- mov_wf fromserial ; where BB is this buffer
+ mov_wf t ; t = 0?CC0000
+ ; where BB is this buffer
; and CC is next buffer
- fixme check for overruns ie if we caught up with totrack
+
+ ; we have to check our proposed new value for fromserial
+ ; against totrack before we store it in fromserial;
+ ; otherwise there's the possibility that we will store
+ ; the new value, and then the high-priority ISR will
+ ; interrupt us and advance totrack onto the buffer we've
+ ; just filled, fooling us into thinking we've overrun.
+ xor_wfw totrack ; W = 0?DD????
+ and_lw 0x30 ; ..DD....
+ bra_z receive_too_much_nmra ; where DD is (fromserial buffer)
+ ; xor (totrack buffer)
+
+ mov_wf t ; W = 0?CC0000
+ bc_w 6 ; W = 00CC0000
+ mov_fw fromserial
bra serial_receive_done
bra serial_receive_done
;****************************************************************************
+ fixme reviewed up to here for inclusion in bigger program
nmra_interrupt_timer
bt_f_if0 INTCON,2,0 ; check whether timer0 interrupt set