'Table Read Confusion'
I have a stupid (newbish) question about table read using TBLPTRU,
TBLPTRH, and TBLPTRL. I understand what they do and how to use them.
The question is: if I need to read the table in the interrupt, is it a good
idea for me to store the original values of TBLPTRs or should I disable
interrupts when I need to do program flash memory reads/write in the main
loop (like a critical section in x86)?
Also, shouldn't this problem also apply to FSRnH / FSRnL? How come the
manual doesn't mention this at all?
In the example in the PIC18 Reference, the manual only mention to save
~Terry (Seitai) Chen
> The question is: if I need to read the table in the interrupt, is it a good
> idea for me to store the original values of TBLPTRs or should I disable
> interrupts when I need to do program flash memory reads/write in the main
> loop (like a critical section in x86)?
Six of one, half dozen of the other. ANY register which gets may
be changed by an interrupt handler should be dealt with very
carefully by non-interrupt code, since its current value can never
be known during execution of non-interrupt code.
If you need to do table reads and writes in an interrupt, you really
should save and restore the table pointer values. Also note that
fast interrupt context saving doesn't save the table pointer (or FSR)
vaules, so you need to do it manually in your code.
> Also, shouldn't this problem also apply to FSRnH / FSRnL? How come the
> manual doesn't mention this at all?
> In the example in the PIC18 Reference, the manual only mention to save
See above- ANY register which gets changed in the interrupt
handler is a good candidate for backing up, if it's important that
its state be known elsewhere in the code. This includes all
configuration registers, pointers, etc.
Also, remember that the objective of the manual is NOT to
teach you how to program a PIC. The objective of the manual
is to provide explicit definition of the behaviour of the PIC under
certain conditions. They assume the broad strokes, generally,
but attempt to fill in the blanks. I think a better question is, why
do they provide an example of context saving at all?
More... (looser matching)
- Last day of these posts
- In 2005
, 2006 only
- New search...