avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Save RAMPZ register in interrupt handler routines


From: David Brown
Subject: Re: [avr-gcc-list] Save RAMPZ register in interrupt handler routines
Date: Sun, 27 Jan 2008 20:57:54 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Paulo Marques wrote:
Quoting Anatoly Sokolov <address@hidden>:

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?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]