void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEPE))
;
/* Set up address and Data Registers */
EEAR = uiAddress;
EEDR = ucData;
/* Write logical one to EEMPE */
EECR |= (1<<EEMPE);
/* Start eeprom write by setting EEPE */
EECR |= (1<<EEPE);
/* Enable EEPROM Ready interrupt */
EECR |= (1<<EERIE);
}
unsigned char EEPROM_read(unsigned int uiAddress)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEPE))
;
/* Set up address register */
EEAR = uiAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from Data Register */
return EEDR;
}
bool EEPROM_Ready = false;
void setup()
{
Serial.begin(115200);
Serial.println((char)EEPROM_read(0));
EEPROM_write(0, 'A');
if(EEPROM_Ready == true) Serial.println("EEPROM Ready");
Serial.println((char)EEPROM_read(0));
}
void loop()
{
if(EEPROM_Ready == true) Serial.println("EEPROM Ready");
}
ISR(EE_READY_vect)
{
EEPROM_Ready = true;
EECR &= ~(1<<EERIE);
}
In the above code, we enable the EEPROM ready interrupt after starting the write, and disable it in the interrupt handler. However, it seems like the interrupt handler is never called, as setting the EERIE bit after the fact doesn't trigger the interrupt.
Reproduction:
In the above code, we enable the EEPROM ready interrupt after starting the write, and disable it in the interrupt handler. However, it seems like the interrupt handler is never called, as setting the EERIE bit after the fact doesn't trigger the interrupt.