; re-initialise timer0 config, etc.
call read_pic_no
bra_z panic_setup_if_master
+ ; must be slave:
+
panic_setup_if_slave
- morse_t0setup sclock, (1<<TMR0ON), t0l_count, t0h_count
+ movwf T0CON
+ movlw morse_slave_t0inith
+ movwf t0h_count
+ movlw morse_slave_t0initl
+ movwf t0l_count
+
bra panic_setup_endif_masterslave
panic_setup_if_master
+ movlw (1<<TMR0ON) | morse_master_t0scale
+ movwf T0CON
+ movlw morse_master_t0inith
+ movwf t0h_count
+ movlw morse_master_t0initl
+ movwf t0l_count
+
pin_l p0_booster_userfault
+
mov_lw 0x0b ; AAARGH
bt_f_if1 TXSTA, TXEN
call serial_write_char
- morse_t0setup mclock, (1<<TMR0ON), t0l_count, t0h_count
+;...
panic_setup_endif_masterslave
; get # bytes of morse msg, # registers in panic readout, message start addr.
# 65535 - <name>_{master,slave}_t[13]cycles
# then time to overflow will be specified time
-#morse MS T0ov16 66ms
points MS T3ov 10ms
tick MS T2period 1ms
+
+; we do morse at 18wpm according to the PARIS standard
+; (ie a unit time of 66ms) using timer0 (DS p108)
+morse MS T0ov16 66ms
; for serial port at 9600
; according to table in datasheet top right p186
+ if mclock==32000
+serial_brgh equ (1<<BRGH)
+serial_spbrg equ 207
+ endif
if mclock==20000
serial_brgh equ (1<<BRGH)
serial_spbrg equ 129
; insns per NMRA division
-;----------------------------------------------------------------------
-; for morse at 18wpm according to the PARIS standard
-; (ie a unit time of 66ms) using timer0 (DS p108)
-
-morse_t0setup macro clock, t0con_other, lcount, hcount
- local t0scale
- local t0cycles
- if clock==20000 ; Fosc=20MHz, Fcy=5MHz ie 200ns
-t0scale equ 0010b ; 1:8 => 1.6us
-t0cycles equ 41250 ; * 1.6us = 66ms
- endif
- if clock==5000 ; Fosc=5MHz ie 200ns, Fcy=800ns
-t0scale equ 0000b ; 1:2 => 1.6us
-t0cycles equ 41250 ; * 1.6us = 66ms
- endif
- if clock<=3900
-t0scale equ 1000b ; do not use prescaler ; cycle is 4/clock ms
-t0cycles equ (33 * clock) / 2 ; (4/clock) * (33*clock)/2 = 2*33 = 66ms
- endif
- if t0cycles > 0
- else
- error "unsupported clock speed (t0cycles)"
- endif
- movlw t0con_other | t0scale
- movwf T0CON
- if hcount>=0
- movlw (65535-t0cycles) / 256
- movwf hcount
- endif
- if lcount>=0
- movlw (65535-t0cycles) & 0xff
- movwf lcount
- endif
- endm
-
;----------------------------------------------------------------------
; busy-wait delay loop, originally from flasher.asm
# perpicNUMBER.hex idlocsNUMBER.o config.o
#ASFLAGS= -Dmclock=20000 -Dsclock=20000
-CLOCKS= -Dmclock=20000 -Dsclock=5000
+CLOCKS= -Dmclock=32000 -Dsclock=4000
ASFLAGS= $(CLOCKS)
HEXMERGER= $(CEBPIC)merge-hex