Hi, I am working with the Pico Arduino and I need to initialize the contents of two addresses of the EEprom memory, we know that the Raspberry Pi Pico RP2040 does not have integrated EEprom memory but that the Arduino is using a fragment of the flash memory for this purpose, well I'm using this code but it doesn't seem to work, It seems that with the attribute constructor the EEprom memory is not being written correctly, could someone help me? Here is my code:
#include <EEPROM.h>
#define EEPROM_ADDR_1 12
#define EEPROM_ADDR_2 33
#define PREDEF_VALUE_1 55
#define PREDEF_VALUE_2 88
// Constructor de atributos para inicializar EEPROM
void __attribute__((constructor)) initEEPROM() {
EEPROM.begin(512); // Inicializa la EEPROM Simulada
EEPROM.write(EEPROM_ADDR_1, PREDEF_VALUE_1);
EEPROM.write(EEPROM_ADDR_2, PREDEF_VALUE_2);
}
void setup() {
Serial.begin(115200);
Serial.println("Test EEPROM Pico");
int value1 = EEPROM.read(EEPROM_ADDR_1);
int value2 = EEPROM.read(EEPROM_ADDR_2);
Serial.print("Valor en la dirección ");
Serial.print(EEPROM_ADDR_1);
Serial.print(": ");
Serial.println(value1);
Serial.print("Valor en la dirección ");
Serial.print(EEPROM_ADDR_2);
Serial.print(": ");
Serial.println(value2);
}
void loop() {
}