PIC eeprom interrupt
Quote from Christian on October 17, 2024, 8:36 amHello,
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,
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,
Quote from arcachofo on October 17, 2024, 9:38 amHi.
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.
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.
Quote from Christian on October 17, 2024, 10:27 amHi,
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.
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.
Quote from arcachofo on October 17, 2024, 1:03 pmOk 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.
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.
Quote from arcachofo on October 18, 2024, 4:49 amSeems 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; }
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;
}
Quote from Christian on October 18, 2024, 9:05 amFantastic, thanks a lot !
(Tested - behaved as expected)
Fantastic, thanks a lot !
(Tested - behaved as expected)