chiark / gitweb /
support 32MHz clock; do morse clock with make-clocks rather than clockvaries.inc
authorian <ian>
Thu, 29 Dec 2005 13:30:39 +0000 (13:30 +0000)
committerian <ian>
Thu, 29 Dec 2005 13:30:39 +0000 (13:30 +0000)
detpic/panic.asm
detpic/program.clocks
iwjpictest/clockvaries.inc
iwjpictest/copybits.asm
iwjpictest/serialloop.asm
pic.make

index 2e70a5a3684be37e79117455144ac04befc37564..ec1721af2a2dc8fef539883c6531aa33d294e2c2 100644 (file)
@@ -106,16 +106,31 @@ stacksave_loop
 ; 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.
index 3dff1624c8cc223ebddb432f3b6d53743733d157..ae0066e8454096395d1b3eba773d20f4352d6125 100644 (file)
@@ -8,6 +8,9 @@
 #              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
index 2a5cfaaa468d101dfb1985e86c9118132d33ced4..dfefe58b65e46bdb76f11cbee2951366a99a96f0 100644 (file)
@@ -7,6 +7,10 @@
 ; 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
@@ -44,41 +48,6 @@ i2c_sspadd equ (mclock/(50*4)) - 1 ; 50kbit/s
 ; 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
 
index c1c3eb6cfed4cfa50be6c4fbc34282f3a12ea153..444426565d987e4cd3360d786eb8a8fa6e1f3e33 100644 (file)
@@ -18,7 +18,7 @@ ACCSFR                equ             0x0f00
 COUNTINNER     equ             0x00
 COUNTOUTER     equ             0x02
 
- if mclock==20000
+ if mclock>=20000
 OUTEREXP               equ             7       ; 2^7 * 2.6ms = 332ms
  else
  if mclock==1000
index 64a4cd4e048b5c12139dc24d2147523bbb7f9fa2..9b139fc393ea8faa95192c1bf1b98d485dabe350 100644 (file)
@@ -15,7 +15,7 @@
 COUNTINNER     equ             0x00
 COUNTOUTER     equ             0x02
 
- if mclock==20000
+ if mclock>=20000
 OUTEREXP               equ             7       ; 2^7 * 1.4ms = 177ms
  else
  if mclock==1000
index e843dbc1f6a3020f42fba7761d4f31d6a18d7422..e3639eb3bfdea99e8bee344973c4f77ebab0d754 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -15,7 +15,7 @@
 #   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