cancel
Showing results for 
Search instead for 
Did you mean: 

Read EEPROM

ah
Associate

Hi.

I want to read the EEPROM but i don't see any function for this. i write my data in eeprom by hal_flashex_dataeeprom_program() function and i want transmit eeprom's data with uart to pc. how can i do this?

2 REPLIES 2

You just read it as if any other const data array in the flash memory. If you want a function then you could write something like this to read from it:

int read_from_eeprom(uint8_t *destination, unsigned int position, unsigned int len)
{
    const unsigned int eeprom_length = DATA_EEPROM_END - DATA_EEPROM_BASE + 1;
    unsigned int i;
 
    if (position + len > eeprom_length) {
        return -1;
    }
 
    for (i = 0; i < len; i++) {
        destination[i] = *((volatile uint8_t *)(DATA_EEPROM_BASE + position + i));
    }
 
    return 0;
}

ah
Associate

Thank you @After Forever​