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

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

[avr-libc-dev] New eeprom library. Comments please


From: Nigel Winterbottom
Subject: [avr-libc-dev] New eeprom library. Comments please
Date: Thu, 21 Jul 2005 16:41:22 +0100

Hello All,

I am aware of 3 problems with the eeprom support in avr-libc. 

1. The SFR addresses are wrong for mega48, mega169, mega329 and the like. 
2. eeprom_write_block takes a very long time even for small blocks. (56-Bytes 
takes approx 0.5s) 
3. A topic on AvrFreaks 
http://www.avrfreaks.com/index.php?name=PNphpBB2&file=viewtopic&t=21371 
discussed the fact that the eeprom_read functions are not atomic. I.e. An 
interrupt could potentially mess up EEARL & EEARH. 


I have taken the avr-libc source "eeprom.S" and heavily modified it to create 
"eeprom1.S" and I've made 2 libraries as follows: 

1. libee1C.a for EECR at 0x1C (for Mega128 etc) 
2. libee1F.a for EECR at 0x1F (for Mega169, Mega48 etc) 

No 2 is improved by first reading the eeprom location and skipping the write if 
not necessary. Generaly when writing a block of data, usually contained in a 
structure, only a few bytes have been changed. This mod made a huge difference 
to my application

No 3 was a trivial fix. Just protecting the read was necessary, the write was 
already protected.

To use this I include the correct library in my Makefile using "LDFLAGS += 
libee1F.a" for the mega169 example. This library overrides the avr-libc 
functions of the same name. 

A zip file (libee.zip) is attached which contains the source, libraries and the 
Makefile used to build the libraries. 

To solve 1 properly is somewhat more difficult.
Let's assume that creating separate builds of avr-libc specific to each micro 
is not on the cards.
Could then, the eeprom modules be stripped out of the standard "core dependant" 
builds of avr-libc and be provided as separate "SFR Location" based builds. We 
might only need the above 2 to start with:

It is then the users responsibility to include the correct library in his 
Makefile as I did above. 
Much better still is that the linker script that invokes the correct avr-libc 
for each micro could also invoke the correct libeeXX.a. 

What do people think ?

Nigel Winterbottom




reply via email to

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