Dear All,
Here is the code I use to read and write to the EEPROM:
1 | unsigned char eeprom_read_byte(const unsigned int addr)
|
2 | {
|
3 | while(EECR & (1<<EEWE));
|
4 | #asm("cli");
|
5 |
|
6 | EEARH = ((addr & 0xFF00) >> 8);
|
7 | EEARL = ( addr & 0x00FF );
|
8 |
|
9 | EECR |= (1 << EERE); // start read access
|
10 |
|
11 | #asm("sei");
|
12 | return EEDR;
|
13 | }
|
14 |
|
15 | void eeprom_write_byte(unsigned int addr, unsigned char val)
|
16 | {
|
17 | while(EECR & (1<<EEWE));
|
18 | #asm("cli");
|
19 |
|
20 | EEARH = ((addr & 0xFF00) >> 8);
|
21 | EEARL = ( addr & 0x00FF );
|
22 |
|
23 | EEDR = val;
|
24 |
|
25 | EECR = 0x04;
|
26 | EECR = 0x02;
|
27 |
|
28 | while(EECR & (1<<EEWE));
|
29 | #asm("sei");
|
30 |
|
31 | }
|
I don't really see the point of sending it since as I already told you -
it works. As for the endianness it just depends where I write the first
byte of the 4-byte long chunk of memory -> in
or
.
@Lupin:
I still haven't checked your proposition out.
Probably I didn't make it clear enough, though -> I am using two debug
platforms for the two chips which comprise my system. The ATA6286 is the
slave. This means that the float values are written down into the EEPROM
bytewise externally, and then read out by the ATA6286. This means that
line will not be applicable for my case since this variable declaration
should appear within the code for the other chip and is thus not visible
for the ATA6286. Nevertheless, I got the idea and will try it out right
away. I will write back to provide feedback.
Best regards,
Borislav