[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] eeprom problems
From: |
Theodore A. Roth |
Subject: |
Re: [avr-gcc-list] eeprom problems |
Date: |
Mon, 29 Sep 2003 21:38:47 -0700 (PDT) |
On Tue, 30 Sep 2003, Jack Valmadre wrote:
:)Hi,
:)I'm writing a program that writes a lot of information to EEPROM at the start
then accesses it later on in the program.
:)I have used the <avr/eeprom.h> include file.
:)For every line that has an eeprom_write_byte() or and eeprom_read_byte()
command, I get an error saying:
:)warning: passing arg 1 of `eeprom_write_byte' makes pointer from integer
without a cast
:)Here is one example of each command:
:)eeprom_write_byte(10, 6);
:)PORTD = eeprom_read_byte(front_sensors);
:)How can I fix this?
Consider this contrived example:
-- begin example --
#define EEPROM __attribute__((section(".eeprom")))
struct eeprom_map
{
uint8_t id;
uint8_t len;
char name[256];
};
struct eeprom_map ee_map EEPROM;
int
main (void)
{
uint8_t len;
char name[256];
len = eeprom_read_byte (&ee_map.len);
eeprom_read_block (name, ee_map.name, len);
/* Do something interesting with name. */
}
-- end example --
Note that the prototypes of eeprom_{read,write}_byte are given as such:
extern uint8_t eeprom_read_byte (const uint8_t *addr);
extern void eeprom_write_byte (uint8_t *addr, uint8_t val);
While you are using this:
eeprom_write_byte(10, 6);
The number 10 is an integer, you need to make it a pointer to uint8_t. How
to do that is left as an exercise for the reader.
Ted Roth