Hello
Today I was using the eeprom using the native library of avrlibc #include <avr/eeprom.h>
The function in documentation is:
uint8_t eeprom_read_byte ( const uint8_t * __p )
Read one byte from EEPROM address __p.
it return a byte and needs as argument a pointer to an adress
So far so good, my problem starts now when I use the function passing the address of the position.
int adress = 0;//I want position 0
int readValue = eeprom_read_byte(&i);//It wount work as expected don´t understand why
int readValue = eeprom_read_byte((uint8_t *)i);//Doing a cast work's well but why ?
uint8_t adress = 0;//I want position 0
uint8_t readValue = eeprom_read_byte(&adress);//It wount work as expected don´t understand why
uint8_t readValue = eeprom_read_byte((uint8_t *)adress);//Doing a cast work's well but why ?
But not the address of the variable that holds the address. Making that function take a pointer was probably not the brightest move. But, you know how to pass it what it wants, so quit worrying about why that works. Just accept that it does.
But not the address of the variable that holds the address
Uhmm I was thinking that passing the address of the variable was in fact making the functions "looks" to the value 0 which was the eeprom address I want.
Perhaps you are right, time to move on and just use the cast.