chiark / gitweb /
small process editing
authorceb <ceb>
Sun, 7 Nov 2004 19:28:56 +0000 (19:28 +0000)
committerceb <ceb>
Sun, 7 Nov 2004 19:28:56 +0000 (19:28 +0000)
cebpic/nmra-stream.asm
detpic/nmra-stream.asm

index 005a6f7b4c76d068c8d37f73c99989bb3b1e8529..07da1c3ec03dca288fed4c250eb140ebc6afcfd9 100644 (file)
@@ -50,10 +50,10 @@ initialise
 ; LED pin (21) initialisation
         bcf     TRISE,4,0       ; turn off PSPMODE (Data Sheet p100/101)
 
+; *** check relevant pin is set as output
 
-; timer0 initial config
-; *** might need to change parameters to make this the right length of time, 
-; or maybe use a different timer?
+
+; timer0 initial config for led flash
         bcf     T0CON,6,0       ; p107 Timer0 -> 16bit mode
         bcf     T0CON,5,0       ; timer0 use internal clock
        bcf     INTCON,5,0      ; clear TMR0IE => mask interrupt
@@ -62,38 +62,57 @@ initialise
         bsf     T0CON,1,0       ; } prescale value 1:8 (13ms x 8)
         bcf     T0CON,0,0       ; }
 
+; *** timer for nmra bits
+
 
 ; 00h = data present to read byte
 ; 01h = next write location byte
-; 10h-13h = 4 rolling registers (check this is in the right buffer range)
+; 10h-1Fh 
+; 20h-2Fh
+; 30h-3Fh
+; 40h-4Fh = 4 rolling registers (check this is in the right buffer range)
 
-main
-; poll data present byte
-; if 1, call subroutine to transmit NMRA stream on pin ??
+main_loop
+; flash led
+       goto main_loop
 
 
 
-transmit_nmra
-; start at top of register
-; read bit ?6, transmit (extra timer loop of nmra-0)
-; go to next bit
-; repeat until done bit = ?0
-; check 1st bit of byte
-; if =/= 1, goto next byte
-; clear register
-; clear register full bit
+timer_interrupt
+; 
+; clear interrupt
+; retfie
+       
 
 
 
-receive_serial
-; *** rewrite
+check_last_byte
+; shift L
+; read C; if 0 then call call nmra_transmit, if 1 then branch to nmra_transmit
+; move to next byte
+
+
+nmra_transmit
+; shift L
+; read C, transmit (extra timer loop of nmra-0)
+; repeat for bits 5-0
+; clear byte
+
+
+
+interrupt_low
+; *** check which interrupt. Branch to receive_serial or timer or return
+
         btfss   PIR1,5,0        ; check whether serial receive interrupt bit set
         retfie                  ; return from interrupt to main if spurious interrupt
-        call    led_red
-        clrf    WREG            ; clear working register
-        movff   RCREG,WREG      ; read data out of serial receive buffer -> WREG
-        incf    WREG            ; increment WREG
-        movff   WREG,TXREG      ; write data out of WREG -> serial transmit buffer
+
+receive_serial
+; *** 
+; check buffer to write to
+; check byte to write to
+; read from serial to this buffer/byte
+; check top bit. if 0, add 1 to byte. if 1, add 1 to buffer and set byte to 0 and mark buffer full
+; clear interrupt
         retfie ; needs # ?
 
 
@@ -102,6 +121,7 @@ receive_serial
 
 
 
+
 waiting
 ; *** change to me the right length (58us eventually, slower first)
         bcf     INTCON,2,0      ; clear timer0 interrupt bit (p109)
index 005a6f7b4c76d068c8d37f73c99989bb3b1e8529..07da1c3ec03dca288fed4c250eb140ebc6afcfd9 100644 (file)
@@ -50,10 +50,10 @@ initialise
 ; LED pin (21) initialisation
         bcf     TRISE,4,0       ; turn off PSPMODE (Data Sheet p100/101)
 
+; *** check relevant pin is set as output
 
-; timer0 initial config
-; *** might need to change parameters to make this the right length of time, 
-; or maybe use a different timer?
+
+; timer0 initial config for led flash
         bcf     T0CON,6,0       ; p107 Timer0 -> 16bit mode
         bcf     T0CON,5,0       ; timer0 use internal clock
        bcf     INTCON,5,0      ; clear TMR0IE => mask interrupt
@@ -62,38 +62,57 @@ initialise
         bsf     T0CON,1,0       ; } prescale value 1:8 (13ms x 8)
         bcf     T0CON,0,0       ; }
 
+; *** timer for nmra bits
+
 
 ; 00h = data present to read byte
 ; 01h = next write location byte
-; 10h-13h = 4 rolling registers (check this is in the right buffer range)
+; 10h-1Fh 
+; 20h-2Fh
+; 30h-3Fh
+; 40h-4Fh = 4 rolling registers (check this is in the right buffer range)
 
-main
-; poll data present byte
-; if 1, call subroutine to transmit NMRA stream on pin ??
+main_loop
+; flash led
+       goto main_loop
 
 
 
-transmit_nmra
-; start at top of register
-; read bit ?6, transmit (extra timer loop of nmra-0)
-; go to next bit
-; repeat until done bit = ?0
-; check 1st bit of byte
-; if =/= 1, goto next byte
-; clear register
-; clear register full bit
+timer_interrupt
+; 
+; clear interrupt
+; retfie
+       
 
 
 
-receive_serial
-; *** rewrite
+check_last_byte
+; shift L
+; read C; if 0 then call call nmra_transmit, if 1 then branch to nmra_transmit
+; move to next byte
+
+
+nmra_transmit
+; shift L
+; read C, transmit (extra timer loop of nmra-0)
+; repeat for bits 5-0
+; clear byte
+
+
+
+interrupt_low
+; *** check which interrupt. Branch to receive_serial or timer or return
+
         btfss   PIR1,5,0        ; check whether serial receive interrupt bit set
         retfie                  ; return from interrupt to main if spurious interrupt
-        call    led_red
-        clrf    WREG            ; clear working register
-        movff   RCREG,WREG      ; read data out of serial receive buffer -> WREG
-        incf    WREG            ; increment WREG
-        movff   WREG,TXREG      ; write data out of WREG -> serial transmit buffer
+
+receive_serial
+; *** 
+; check buffer to write to
+; check byte to write to
+; read from serial to this buffer/byte
+; check top bit. if 0, add 1 to byte. if 1, add 1 to buffer and set byte to 0 and mark buffer full
+; clear interrupt
         retfie ; needs # ?
 
 
@@ -102,6 +121,7 @@ receive_serial
 
 
 
+
 waiting
 ; *** change to me the right length (58us eventually, slower first)
         bcf     INTCON,2,0      ; clear timer0 interrupt bit (p109)