Paulo Marques wrote:
Quoting Anatoly Sokolov <[EMAIL PROTECTED]>:
Hello.
Hi,
For FLASH memory access for 128KB avr-libc have pgm_read_*_far macros.
These macros modify RAMPZ register and is non-reenterable. Using these
macros in main loop/interrupts code can cause collisions of access to
FLASH
memory.
For solving of this problem I offer save RAMPZ register in interrupt
handler routines for 128KB devices ('avr31' and 'avr51'
architectures). The
'-mno-save-rampz' switch restore old behaviour.
Wouldn't it be better to just disable interrupts / restore interrutps in
the macros themselves? Or maybe just create _atomic variants that do
this, or even just document that if you use pgm_read_*_far macros inside
interrupts you have to make sure that in the main code you do that from
atomic sections or at least with interrupts disabled...
Otherwise you will be paying a latency penalty on every interrupt call
even when you don't need to (and that is probably most of the time).
Disabling and re-enabling interrupts during the pgm_read_*_far macros is
also bad - it would introduce a space and time penalty on every
pgm_read_*_far call. I'd imagine that the use of pgm_read_*_far macros
within interrupt functions is pretty rare - perhaps the best idea is to
use the patch, but make "-mno-save-rampz" the default? Or is there some
practical way to let the interrupt function save rampz if and only if it
is used (or if a function is called), just like the volatile registers?
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list