Page 1 of 1

is this a bug with the EEPROM component ?

Posted: Mon Nov 03, 2008 1:48 pm
by chevy6600
Hi guys, hope you can help. After spending the past 4 or 5 days trying to sort the problem as per this post... http://www.matrixmultimedia.com/mmforum ... f=5&t=4990
i have found out and sorted the problem. It now appears that in my algorithms, i had the `write to eeprom` component, and looking at the asm code it appears that it disables ALL interrupts :!: It is now evident that this included my PWM servo signal code, causing it to miss some of the triggers used in the timing of the high/low pulses. :evil:
It is now evident that you cannot use the interrupts in the way i am, together with the `write to eeprom `component! ....which is a bit of a *&$"^*$ :evil:

Q. if the `write to eeprom` component halts all interrupts, should it not be restarting where it left off and not missing any steps instead :?:

Q. is this a bug or is it as it should be :?:

Re: is this a bug with the EEPROM component ?

Posted: Mon Nov 03, 2008 5:02 pm
by Benj
Hello

This is a microchip silicone thing im afraid. However there is a workaround.

Basically the EEPROM data is written to the EEPROM by writing 0x55 and 0xaa and then the EEPROM data. This is Microchips mechanism to make sure that you really do want to overwrite a byte of the EEPROM. Basically if an interrupt occurs while you are doing this then your new EEPROM data will not get written.

My workaround would invlove editing the EEPROM_Code.c file and commenting out the interrupt disable and enable commands. Once you have done this you will have to verify your EEPROM writes in your code to make sure that an interrupt did not break the EEPROM write chain of events. If the EEPROM data has not been updated then repeat the write until the data is valid.

Hope this helps.

Re: is this a bug with the EEPROM component ?

Posted: Mon Nov 03, 2008 5:11 pm
by chevy6600
Hi benj, thanks for that, i`ll do as you suggest.

Re: is this a bug with the EEPROM component ?

Posted: Mon Nov 03, 2008 5:18 pm
by Steve
Alternatively, you could rearrange the code from this...
eecon2 = 0x55;
eecon2 = 0xAA;
set_bit(eecon1, WR);
while (test_bit(eecon1, WR)); //wait for EE write to complete...

if (bInterruptsEnabled)
set_bit(intcon, GIE); //Re-enable Interrupts
to this:
eecon2 = 0x55;
eecon2 = 0xAA;
set_bit(eecon1, WR);

if (bInterruptsEnabled)
set_bit(intcon, GIE); //Re-enable Interrupts

while (test_bit(eecon1, WR)); //wait for EE write to complete...
This will mean that the interrupts are turned off for only 5 or 6 instruction cycles, as opposed to the 8ms it could take to actually perform the EEPROM write.

Re: is this a bug with the EEPROM component ?

Posted: Wed Nov 05, 2008 10:55 am
by chevy6600
Hi steve, i have just come back on line and seen your suggestion, thanks for the input i`ll give your alteration a go now as well.
thanks.