[En-Nut-Discussion] twi -problem with EEPROM programming
uprinz2 at netscape.net
Sat May 23 21:35:53 CEST 2009
in the 4.9.x or trunk release there are two upgrades to the TWI. One is
a version of a hardware driver that is tested on AT91SAM7X systems.
The second part is at24c.c a driver for EEPROM access to any kind of
paged EEPROMs. You can simply merge it from that release or you modify
your driver to kep an eye on the paging.
EEPROMs are able to write 32 bytes at once ( may vary, have a look into
your EEPROMs datasheet). But you have to keep care, that you do not run
over the end of a page before it is written. To start the write process
in an EEPROM, you have to set a STOP condition on the bus after writing
the data. Only the the EEPROM really writes data. nd for writing it neds
time. A new EEPROM might need around 2ms, if its an older one or it is
to cold or hot, it needs more time. So you have to poll it by sending
START and the EEPROMs address until you get an ACK back from it. Then
you can read or write again.
While reading there is no paging needed. Yust write the first address to
read into the address registers or the EEPROM and then read as much as
you like. For all these mechanisms the new at24c driver for AT91 systems
( other cpus might work, but is not tested) is taking care. Check it out
and report if anything doesn't work.
Some more tips:
It' always not a good idea to start testing at the highest possible
speed. Start with 100kHz and then speed up until it doesn't work
anymore. Then go 20% back and you're safe.
In the latest NutO/S the TWI got two new routines for Registered Access,
so tha means specially for chips, that first need some addresses and
then read or write code. That makes it obsolete to write your own code
for what part is data and what is address and so on.
asif khan wrote:
> hello everyone ,
> let me be more specific about the problem .The code i sent before needs some
> changes sorry about that . When i use EEPROM code which is not based on
> Ehernut am able to read and write fine . But when am using Ethernut i was
> not able to write properly , it was able to write 67 of 200 , rest of them
> am getting data not acknowledged msg. And the adrresses where am able to
> write are not changing they are fixed , am not able to read completely i
> have given a timeout of 500 secs for read as you can see . i have given TWI
> SET SPEED as 400000 in TwInit .
More information about the En-Nut-Discussion