is this a bug with the EEPROM component ?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

is this a bug with the EEPROM component ?

Post 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 :?:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: is this a bug with the EEPROM component ?

Post 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.

chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

Re: is this a bug with the EEPROM component ?

Post by chevy6600 »

Hi benj, thanks for that, i`ll do as you suggest.

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: is this a bug with the EEPROM component ?

Post 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.

chevy6600
Flowcode V4 User
Posts: 115
Joined: Fri Feb 22, 2008 6:38 pm
Contact:

Re: is this a bug with the EEPROM component ?

Post 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.

Post Reply