px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2

How to write to and read from EEPROM.

File(s):

0xAB is written to EEPROM address 0x000C, read back and reported over UART at 115200 BAUD, 8 Data Bits, No Parity and 1 Stop Bit.

<avr/eeprom.h> can also be used. It is not neccessary to use an explicit EEPROM address. The compiler will allocate a unique address if the EEMEM prefix is used. For example:

#include <stdint.h>
#include <avr/eeprom.h>
EEMEM uint16_t ee_setting;
int main(void)
{
uint16_t value;
// Load value from EEPROM
value = eeprom_read_word(&ee_setting);
// Modify value
value += 1;
// Commit new value to EEPROM
eeprom_write_word(&ee_setting, value);
eeprom_busy_wait();
}