From: ian Date: Wed, 21 Dec 2005 13:49:16 +0000 (+0000) Subject: switch nmra timer ISR to use FSR2 and reserve FSR2 for it X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=0c836807c1c6488d6d70ecd74ef5f3e5af66aea8;p=trains.git switch nmra timer ISR to use FSR2 and reserve FSR2 for it --- diff --git a/detpic/common.inc b/detpic/common.inc index d842960..663741b 100644 --- a/detpic/common.inc +++ b/detpic/common.inc @@ -33,7 +33,7 @@ clock equ -1 ; PCLATH Low ISR Not used ; t_dolocal Low ISR High ISR ; FSR1 Low ISR High ISR (detect[1]) -; FSR2 Low ISR High ISR (detect[1]) +; FSR2 High ISR (nmra) High ISR (detect[1]) ; ; Trashed May be trashed by any routine anywhere. Saved ; during every ISR entry/exit. @@ -68,7 +68,9 @@ clock equ -1 ; saves that register for the benefit of its callers. ; ; [1] FSR1 and FSR2 on slave pics are reserved exclusively for the -; I2C response and detection code (detect.asm), after det_slave_init. +; I2C response and detection code (detect.asm), after +; detect_slave_init. Likewise FSR2 is reserved exclusively +; for the NMRA output ISR after nmra_init. ; ; General-purpose hardware allocation: ; diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index 6ff993a..695b18d 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -27,7 +27,7 @@ nextaction equ 6 ; bit 6: change polarity on next interrupt y/n ; nmractrl is a bitmask, and only the bits above are used fromserial res 1 ; from-serial buffer location (in buffer bank) -totrack res 1 ; to-track buffer location (in buffer bank) +totrack equ FSR2L ; to-track buffer location (in buffer bank) totrackbit res 1 ; bit location of pointer within byte ; ; buffers are each 16 bytes (this is hardwired) @@ -142,6 +142,7 @@ nmra_init ; initialise buffers (for bank 5, for nmra from-serial/to-track buffers) mov_lw bufferpage + mov_wf FSR2H clr_fa nmractrl ; for bits relevant to control of nmra stream clr_fa fromserial ; for loc'n of write-from-usart ptr in buffers @@ -351,13 +352,8 @@ read_from_buffer ; set na=cb=bit value, advance bit (i.e. rotate transmitbit right), ; check if bit7, if so, advance byte, return - fixme save and restore FSR1 - fixme check other to-be-saved stuff ?? debug 'p' - mov_ff totrack,FSR1L ; set low byte of IND1 pointer - mov_lw bufferpage - mov_wfa FSR1H ; set high byte of IND1 pointer - mov_ff INDF1,WREG + mov_ff INDF2, WREG and_wfwa totrackbit ; select bit to be transmitted bra_z zero_bit_to_track @@ -403,17 +399,14 @@ advance_pointer ; currently on bit 7 of the byte, after having read rest of byte to ; track; check whether it is 1 or 0 - mov_ff totrack,FSR1L - mov_lw bufferpage - mov_wfa FSR1H ; if set, move to next buffer - bt_fa_if1 INDF1,7 + bt_fa_if1 INDF2,7 call advance_read_buffer ; if not set, move to next byte of samebuffer (increment totrack) ; (will be on bit 7 at this point anyway so no need to change totrackbit) - bt_fa_if0 INDF1,7 + bt_fa_if0 INDF2,7 inc_fa totrack return