XMC4500 PFLASH programming

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

cross mob
User10000
Level 1
Level 1
Hello.

Anyone who have experienced about xmc4500 flash programming help me please.

I need to store some data at non-volatile area.
I added the code from XMClib Flash-progam example but the software has a problem.

XMC_FLASH_EraseSector(XMC_FLASH_SECTOR_11); -------- // 1
XMC_FLASH_ProgramPage(XMC_FLASH_SECTOR_11, idata); -------- // 2

ptr_data = XMC_FLASH_SECTOR_11; --------// 3

for (count = 0; count < XMC_FLASH_WORDS_PER_PAGE; ++count) { --------// 4
odata[count] = *ptr_data; --------- // 5
++ptr_data; ----------// 6
}

Address of XMC_FLASH_SECTOR_11 is 0x0C0C0000

When software is executed with above 6 line, there are written data in SECTOR11 memory.
Remove above line 1(erase) and 2(program) and after power OFF/ON SECTOR11 data are changed to '0'.
It seem that the written data don't retain.

Please help me what should I do.
0 Likes
4 Replies
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi,

I am not sure what is wrong with your code maybe you can give my flash programming code (see ZIP attachment) a try.

Example flash programming ...



if (FLASH_If_Write(&FlashWriteAddress, (u32*)(LeftBytesTab),1))
{
//Flash program error ...
LED_OFF(); // off led to indicate program error
}

0 Likes
User10000
Level 1
Level 1
Hello Travis.

Thank you for your reply.

Attached your sample code save data into flash well.
But it seems that address offset doesn't match my data type.

I want to save below data at PFLASH sector 11(0x0C0C00000).
{0x9600A8, 0x00FFFFFF, 0x0000000A, 0x02FAF8CB}
How should I correct your sample code please?

Best regards.
0 Likes
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi,

Flash programming is done in a page size, so remaining unused buffer is best to fill them with zeros. Attached is an example which is able to write your mentioned data to sector 11. All you need to do is to set the variable "keypress = 0xAA" while the software is running.

1434.attach
0 Likes
User10000
Level 1
Level 1
Hi Travis.

I finished flash programming by your help.

Thank you very much.
0 Likes