--- Craig Limber <ffdude@shaw.ca> wrote:
>
> Hi there;
>
> I am not sure how reading and writing the EEPROM
> works using avr-libc.
> I was wondering if anyone could tell me the correct
> method of reading
> and writing byte 0 of the EEPROM? I only want to
> store and recover
> 3 different bytes of information.
>
> Would this work to write "value" to location 0 of
> the EEPROM?
>
> eeprom_write_byte((uint8_t *)0, value);
>
> and would this read it back:
>
> value = eepromt_read_byte((uint8_t *)0);
>
> Thanks, eh.
>
> Craig
>
hi.
it works, but not safe for all addresses of EEPROM's
bcz if address be >255 and device has an EEPROM size
of 256 or more the address of byte must be passed as
<int> value, instead of <uint8_t>. so the only things
you need is to #include <eeprom.h> and for getting a
byte from any address use:
uint8_t value = eeprom_rb( address_of_byte_in_eeprom
);
and for writing:
eeprom_wb( address_of_byte_in_eeprom, value );
good luck.
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/