On 2010-11-29 01:12, David Duffy (AVD) wrote: > Jan-Erik Soderholm wrote: >> On 2010-11-28 23:59, David Duffy (AVD) wrote: >> >>> Olin Lathrop wrote: >>> >>>> David Duffy (AVD) wrote: >>>> >>>> >>>>> I am using INDF0 for reading the receive buffer. It is the same code >>>>> I've used countless times before. >>>>> >>>>> >>>> Are you doing this in the interrupt routine and forgot to save/restore= the >>>> FSR? >>>> >>> I am using INDF0 in the serial receive ISR, as well as in tasks >>> triggered by flags in the main loop. >>> >>> I'm not saving / restoring them in the ISR, as I understand this >>> particular chip does that by itself. >>> David... >>> >>> >> >> They are. But of course you have to re-init them at each >> entry to the ISR, they are not preserved between two interrupts. >> You didn't say you don't, but just to clearify. >> >> B.t.w, this is what the PIC16F193X/LF193X datasheet says : >> >> Upon entering an interrupt, the return PC address is >> saved on the stack. Additionally, the following registers >> are automatically saved in the shadow registers: >> =95 W register >> =95 STATUS register (except for TO and PD) >> =95 BSR register >> =95 FSR registers >> =95 PCLATH register >> Upon exit from the Interrupt Service Routine, these registers >> are automatically restored. Any modifications to >> these registers during the ISR will be lost. Depending >> on the user=92s application, other registers may also need >> to be saved. >> >> >> What I do not understand is why you don't read the receive >> buffer (RCREG) directly. Why go through the index registers ? >> The reading will always be from the same fixed address (RCREG) >> so I do not see the need for any "indexing" here !? >> > > To clarify, I use INDF0 to store the incoming byte into my RAM receive > buffer. > > Also, the use of INDF0 in the ISR& main routines is separate. That is, > they operate on the same buffer, but the pointers are separate variables. > David... > OK. That is clearer. :-) Then maybe "I am using INDF0 for reading the receive buffer." should have been saying "...writing into the receive buffer". :-) And it should be OK as long as you re-load INDF0 at each entry of the ISR with the proper receive-position in the buffer. The read-position in the buffer will be saved and restored by the context save/restore the hardware does at an interrupt. No further questions. :-) Jan-Erik. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .