[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] read write eeprom WINAVR20050214
From: |
Royce & Sharal Pereira |
Subject: |
Re: [avr-gcc-list] read write eeprom WINAVR20050214 |
Date: |
Sat, 19 Feb 2005 09:07:55 +0530 |
User-agent: |
Opera M2(BETA1)/8.00 (Win32, build 7401) |
Hi,
On Sat, 19 Feb 2005 09:05:40 +0700, andi
<address@hidden> wrote:
i declare variable in eeprom like this:
unsigned char Eeprom_Value __attribute__ ((section(".eeprom"))) = 30;
and when i read and write :
eeprom_read_byte((unsigned)&Eeprom_Value);
eeprom_write_byte((unsigned)&Eeprom_Value);
---------------------------------------------
GCC has no idea of different address spaces. So your '&' option will not
work here.
Even if it did, your 'write' function is missing the byte to be written.
Here's what I do:
//Define eeprom addresses :-
enum {BYTE1_AD, BYTE2_AD, WORD1_AD, WORD2_AD=WORD1_AD+2};
char x,y; int w,z;
//now call the functions in your code...
//Read..
y = eeprom_read_byte(BYTE1_AD);
z = eeprom_read_word(WORD1_AD);
//write..
eeprom_write_byte(BYTE1_AD, x);
eeprom_write_word(WORD2_AD, y);
BTW have you gone thru the avrlibc docs? If you had you would have found
the answers to many of your recent queries. Please do so now. It will save
you time & frustration (wait till you try putting strings / arrays in
flash or defining pointers in flash.... :) ).
--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
- [avr-gcc-list] read write eeprom WINAVR20050214, andi, 2005/02/17
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, Royce & Sharal Pereira, 2005/02/17
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, Julius Luukko, 2005/02/18
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, Royce & Sharal Pereira, 2005/02/18
- RE: [avr-gcc-list] read write eeprom WINAVR20050214, Eivind Sivertsen, 2005/02/18
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, E. Weddington, 2005/02/18
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, andi, 2005/02/18
- Re: [avr-gcc-list] read write eeprom WINAVR20050214,
Royce & Sharal Pereira <=
- Re: [avr-gcc-list] read write eeprom WINAVR20050214, Joerg Wunsch, 2005/02/19
Re: [avr-gcc-list] read write eeprom WINAVR20050214, Dave Hansen, 2005/02/18
Re: [avr-gcc-list] read write eeprom WINAVR20050214, Paul Colin Gloster, 2005/02/22