avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] eeproms and interrupts


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] eeproms and interrupts
Date: Tue, 9 Aug 2005 15:28:22 +0200
User-agent: Mutt/1.4.2.1i

As Bernard Fouché wrote:

> ("brberie" showing that reads/writes to eeprom can be perturbated by
> interrupts) and the current state of
> eeprom_{read|write}_{byte|block} in avr-libc-1.2.5, is there
> something to change in avr-libc eeprom management routines to be
> sure that no interrupt can make eeprom accesses to fail?

I think mainly the current behaviour should be documented.  Writes are
protected as the timing is critical in order for being allowed to
start the write at all.  Read operations are not protected, but then,
neither would the remainder of the library claim to be safe against
interrupts.

IMHO, it should simply be documented that if you have any interrupt
service accessing EEPROM functions, then the code outside the ISR
needs to be protected from interrupts while accessing the EEPROM.  If
your only EEPROM access is outside of interrupt routines, there's no
problem at all, as the only remaining timing-critical section (right
before starting the write to an EEPROM cell) is protected.

I don't think it makes sense starting to protect the entire library
against people who might use certain functions from within interrupts.
We might have to considere each and any internal 16-bit variable
otherwise.  In general, I'd consider calling (any) library functions
from within ISRs poor design, but that's something you might not be
able to explain to Mr. brberie. ;-)  I don't think the code penalty
of adding interrupt-safety is warranted given that anyone with a good
interrupt design would have to pay it, only for those who don't know
how to minimalize their ISRs.

I'd even go so far to write it in the preamble that unless explicitly
stated, none of the library functions claims interrupt-safety.

Any opinions about that?

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

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