Page 1 of 1

Help! Flash EEPROM Component

Posted: Tue Jun 24, 2025 10:36 am
by seokgi
Hello?

I'm working on a project, but it doesn't work because I'm doing it wrong.

If you have a simple example, I'd like to refer to it.

MCU:PIC24FJ512GA606
Component:Flash EEPROM

And when communicating with Modbus RTU Slave of RS-232 base, it keeps stopping (within 10 minutes).
Other operations are fine.
When it stops, if I do a hardware reset, it works normally.
Is there a way I can do it?
Thank you.

Re: Help! Flash EEPROM Component

Posted: Tue Jun 24, 2025 10:51 am
by mnfisher
Please give us some more info - some sample code that demonstrates the error?

Re: Help! Flash EEPROM Component

Posted: Tue Jun 24, 2025 11:07 am
by seokgi
What information should I provide?
No special messages will be generated.
I will post the project I wrote.

Re: Help! Flash EEPROM Component

Posted: Fri Jun 27, 2025 4:28 pm
by BenR
Hello,

The FlashEEPROM component is setup to have 256 16-bit values available however in your initialisation and write functions you are writing to address 20481. This should be in the range 0-255, probably 1 as the EEPROM component itself manages the offset address.

Secondly you are writing to the EEPROM every time around your loop. At least I think you are, the code is currently disabled. This is a big no no as you can rattle around that loop very quickly and you will quickly wear out the flash memory which is usually only good for 100,000 erase/write cycles. If possible you should only write to the EEPROM when the values you need to store change. If the values you need to store are changing constantly then you may have to try and detect a power loss event and saving to the EEPROM then.