From: ceb Date: Sun, 7 Nov 2004 19:28:56 +0000 (+0000) Subject: small process editing X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=1d4bdebe38a46d8330c9a3a120e1f4b61cd5dbdb;p=trains.git small process editing --- diff --git a/cebpic/nmra-stream.asm b/cebpic/nmra-stream.asm index 005a6f7..07da1c3 100644 --- a/cebpic/nmra-stream.asm +++ b/cebpic/nmra-stream.asm @@ -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) diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index 005a6f7..07da1c3 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -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)