Forum breadcrumbs - You are here:ForumGeneral: Report BugsPIC eeprom interrupt
You need to log in to create posts and topics.

PIC eeprom interrupt

Hello,

Maybe strange question, since one would want to globally disable interruption before a write to eeprom, but does the pic simulator generates an interrupt + flag at the end of an eeprom write ?

I cannot clearly see it in the code :

void PicEeprom::runEvent() // Write cycle end reached
{
writeEeprom();
clearRegBits( m_WR );
m_wrMask = 0;

Maybe not the right place though.

Anyway, on a PIC12F683, I use the following code (XC8)

INTCONbits.GIE = 0;
EECON1bits.WREN = 1;
for (char i = 0, B0 = 33 ; B0<44 ; B0++){
  EEADR = i;
  EEDAT = B0;
  // Write sequence for each byte :
  // Set 0x55, then 0xAA in EECON2, then do WR.
  EECON2 = 0x55;
  EECON2 = 0xAA;
  EECON1bits.WR = 1;
  while (!PIR1bits.EEIF); -> code seems stuck there in SimulIDE ; polling EECON1bits.WR -> 0 is ok though.
  _nop();

etc..

I checked the PIC12F683 xml config files, and eeprom interrupts & registers look fine to me.

Thanks for your help,

Hi.

I haven't tested and I don't know the whole code for your firmware, But at first sight I don't see EECON1.WREN (Write Enable bit) being set.

Hi,

Sorry I cut the code snippet a bit too early - I edited my post with the relevant code for an EEPROM byte write.

In short : 

while (!PIR1bits.EEIF) -> KO ; looks like flag never set.
while(EECON1bits.WR) -> OK -> as per the  "clearRegBits( m_WR )" of SimulIDE code I guess.

Ok thanks.

I think you are totally right, the interrupt is never called.
And should be called exactly where you pointed ( runStep() ).

But I think there is another issue, I'm investigating it.

Seems that the only problem was interrupt not raised.
Already fixed in the source code:

void PicEeprom::runEvent() // Write cycle end reached
{
    writeEeprom();
    clearRegBits( m_WR );
    m_interrupt->raise();
    m_wrMask = 0;
}