From: ian Date: Mon, 1 Aug 2005 20:20:00 +0000 (+0000) Subject: nmra-test is not a sensible program - it looks like a copy of reply-serial with some... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=3665ed982250f9ca7d716281cbc2505273b4ab45;p=trains.git nmra-test is not a sensible program - it looks like a copy of reply-serial with some hacking --- diff --git a/cebpic/nmra-test.asm b/cebpic/nmra-test.asm deleted file mode 100644 index d3eee85..0000000 --- a/cebpic/nmra-test.asm +++ /dev/null @@ -1,111 +0,0 @@ - -; general initialisation -; set up serial port -; set up 58us timer loop (actually longer for 1st test version - -; receive bytes from computer -; send when computer has sent complete stream (wait for stop, or for 9x1?) -; -~ - - -; pin 21 (per-pic-led, RD2/PSP2/C1IN) states: high H = green, low L = red, float Z = black - - include /usr/share/gputils/header/p18f458.inc - - org 0 - goto initialise_serial - -; interrupt routine call - this needs to be at 00008h (high priority interrupt) - - org 000008h - goto interrupt_high - -; interrupt routine call - this needs to be at 000018h (low priority interrupt) - - org 000018h - goto interrupt_low - - - code - -initialise_serial - -; globally enable interrupts - p77 - bsf RCON,7,0 ; enable priority levels - bsf INTCON,7,0 ; enable high-priority interrupts - bsf INTCON,6,0 ; enable low-priority interrupts - -; initial config - RCSTA register p182 - bsf RCSTA,7,0 ; serial port enable (p182) - bsf RCSTA,6,0 ; 8-bit reception - bsf RCSTA,4,0 ; enable continuous receive - - bcf TXSTA,4,0 ; asynchronous mode - -; set SPBRG to get correct baud rate according to table top right p186 -; (Tosc = 20MHz, desired baud rate = 9600) - bsf TXSTA,2,0 ; set high baud rate - bsf SPBRG,7,0 - bsf SPBRG,0,0 - -; interrupt set-up for serial receive - bsf PIE1,5,0 ; enable USART receive interrupt (p85) - bsf IPR1,5,0 ; set to low-priority interrupt - - -; LED pin (21) initialisation - bcf TRISE,4,0 ; turn off PSPMODE (Data Sheet p100/101) - - -; timer0 (main loop LED flash) initial config - bcf T0CON,6,0 ; p107 Timer0 -> 16bit mode - bcf T0CON,5,0 ; timer0 use internal clock - bcf INTCON,5,0 ; clear TMR0IE => mask interrupt - bcf T0CON,3,0 ; use prescaler - bcf T0CON,2,0 ; } - bsf T0CON,1,0 ; } prescale value 1:8 (13ms x 8) - bcf T0CON,0,0 ; } - -; timer2 (nmra 58us period) initial config (p115) - - - -main - call led_green - call waiting - call led_black - call waiting - goto main - - -waiting - bcf INTCON,2,0 ; clear timer0 interrupt bit (p109) - clrf TMR0H,0 ; p107 set high bit of timer0 to 0 (buffered, - ; so only actually set when write to tmr0l occurs) - clrf TMR0L,0 ; set low bit o timer0 - timer now set to 0000h -loop - btfss INTCON,2,0 ; check whethr tiomer0 interrupt has been set - - ; skip next instruction if so - bra loop - return - - -interrupt_high -; needed? - -interrupt_low - btfss PIR1,5,0 ; check whether serial receive interrupt bit set - - btfss PIR1,5,0 ; check whether timer interrupt bit set - 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 - retfie -; *** retfie 1 or 0? -; *** also need to clear specific interrupt bits in software - - - end