XMC4800 flash read/write error PFDBER

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

cross mob
AndreaV
Level 1
Level 1
First solution authored 5 sign-ins First reply posted

Hello,

I'm writing a program that write to, and read from flash and I have stange behavior, I thinking due to FSR->PFDBER bit that go high.

For example I'm using debugger and I point to flash with a simple pointer used like array:

AndreaV_1-1670322614280.png

Sometime work fine but sometime I have bus fault and bit PFDBER go on. Another test I have done is if I debug some "for" iterations (3-4) with debugger step by step and after I resume program, problem not happens.

I increased XMC_FLASH_SetWaitStates(8) from 4 to 8 but error persist. I disable XMC_FLASH_DisableDoubleBitErrorTrap() and bus fault not happens but I don't trust the readed data if bit PFDBER is high.

Also command "XMC_FLASH_ProgramPage" sometime looks like not write all data in flash, but I don't know if the problem is the read operation or the write because the debugger sometimes show ?????? and sometime is not refreshed I don't know why?

I hope someone can help me to clarify the situatio, so I ask:

  • Someone can explain me better what PFDBER means and how to manage it?
  • Before flash write operation I MUST disable interrupts or not?
  • Before flash write operation I MUST erase sector?
  • Before reading or writing is better to "XMC_FLASH_ClearStatus();"?
  • There need some waiting time after write(I waiting for FLASH_FSR_PBUSY_Msk) or read?
  • When debugger memory show all ????? what can I do? Ho can I refresh memory showed in debugger?

 

Thank's in advance for support,

Andrea.

 

 

0 Likes
1 Solution
AndreaV
Level 1
Level 1
First solution authored 5 sign-ins First reply posted
  • I have make some test and the solution is to erase the entire sector before write a page.
  • About PFDBER, in my opinion, is caused because when you use XMC_FLASH_ProgramPage without erase a sector before, if the command has to write 0 on bits that are at 1, the micro see a difference beetwen the value on flash after write and the value requested to be writed, and say about a value on flash non attendible by setting PFDBER. Example: In the flash there are bytes 0xFF and I use XMC_FLASH_ProgramPage to write 0x00.

I hope that my answer is correct.

Thanks.

 

View solution in original post

0 Likes
2 Replies
AndreaV
Level 1
Level 1
First solution authored 5 sign-ins First reply posted

UPDATE:

AndreaV_0-1670342017315.png

 

I have ceated a recurrent condition that go in fault, the condition is:

  1. I read, modify, write and read page 0(256byte) in sector S5. (In the last read the data are same as the wited).
  2. I write page 3(256byte) in sector S5.
  3. I write sector S11(some pages).
  4. I overwrite page 3(256byte) in sector S5.
  5. I overwrite page 0(256byte) in sector S5.
  6. All read and write go properly without problems.
  7. I retry the same sequence and at step 1, if I read after write page 0, I don't read the rigth data but the old.

If I restart the micro I have the same problem, I need to download the program again to complete the procedure at last 1 time.

Look like a cache problem... but I use uncached address and the bit PFDBER go at 1 when there is the difference.

But to write 0 on flash I need to erase sector before? Write modify only falsh bit at 0 to 1 and not bit at 1 to zero.

0 Likes
AndreaV
Level 1
Level 1
First solution authored 5 sign-ins First reply posted
  • I have make some test and the solution is to erase the entire sector before write a page.
  • About PFDBER, in my opinion, is caused because when you use XMC_FLASH_ProgramPage without erase a sector before, if the command has to write 0 on bits that are at 1, the micro see a difference beetwen the value on flash after write and the value requested to be writed, and say about a value on flash non attendible by setting PFDBER. Example: In the flash there are bytes 0xFF and I use XMC_FLASH_ProgramPage to write 0x00.

I hope that my answer is correct.

Thanks.

 

0 Likes