Re-Writing data in Flash Memory for XMC 4400

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User14735
Level 1
Level 1
Hello
I am using the XMC 4400 chip and the part which I am going to discuss is part of a larger code.

At power up I write certain data into the flash memory say in flash sector 1. During normal operation I take data from RAM and routinely write it to Flash memory until I fill up the entire sector. If there is a reset then the data from Flash is used to repopulate the data variables in RAM
After writing the entire Flash sector 1, I erase that sector to reprogram it with new data. I have observed that after erasing the flash memory some of the data values in RAM get changed which affects the operation of my entire code.

Is there a way I can keep the RAM values intact after the Flash erase?
What are things I should do before erasing flash such as disabling interrupts which I am doing before erasing flash memory?
0 Likes
2 Replies
User16529
Level 4
Level 4
First solution authored
What sector do you exactely flash/erase? Because there are sectors reserved for the code, and write in them can corrupt your code
0 Likes
User14735
Level 1
Level 1
Hello Janet
Thank you for the reply. I have fixed my issue. The RAM contents would change because a DMA DAVE App was not being disabled during flash erase. Hence it would change certain RAM contents and populate it with wrong data.
0 Likes