Flash Physical Sector

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

cross mob
Not applicable
Hello,
I have an application, where I need to store once in a while configuration data to flash memory. As I need to erase the flash memory, before writing new content to it, I have to decide whether I want to erase a physical or a logic sector. I'm using a xmc4200 and according to the data sheet I could have a maximum of ~100 configuration data changes when erasing logical sectors and a maximum of ~1000 configuration data changes when erasing physical sectors. Right?

The reference manual states that a physical sectors size ranges from 64k bytes to 256k bytes.

Now, if I would go the "physical sector" route, I would have to spend 64k byte to 256k byte for a configuration block. The xmc4200 has 256k byte of flash, so this would not be feasible if a physical sector would have a size of 256k byte. Where can I find the exact size of a physical sector for a xmc4200-Q48x256?

In the peripheral library's xmc4_flash.h header, there are a couple of macros XMC_FLASH_PHY_SECTOR_x, with x being one of 0, 4, 8, 9, 10, 11 and from the addresses of the sectors I can't derive a reasonable sector size (sector 4 and 8 having the same base address for example). BTW: the Doxygen documentation states that all macros define the start of physical sector0 😉

Best regards,

Torsten
0 Likes
3 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi Torsten,

We have fixed the documentation issues you mention below. Thanks for reporting them.
To your question, you can find the answer in the reference manual p8-7: physical sectors 0 and 4 has 64KB each, and physical sector 8 has 128KB.

Best regards,
Jesus
0 Likes
Not applicable
Hello Jesus,
thank you very much! In the table 8-2 that you've mentioned, is the physical sector 8 the last row of that table? And, shouldn't the XMC_FLASH_PHY_SECTOR_8 macro be defined as "(uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x20000UL)" then?

Thank you very much, for the informations.

Kind regards,
Torsten
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi Torsten,

Exactly.

We have fixed xmc4_flash.h as
#define XMC_FLASH_PHY_SECTOR_0 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x00000UL) /**#define XMC_FLASH_PHY_SECTOR_4 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x10000UL) /**#define XMC_FLASH_PHY_SECTOR_8 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x20000UL) /**#define XMC_FLASH_PHY_SECTOR_9 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x40000UL) /**#define XMC_FLASH_PHY_SECTOR_10 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x80000UL) /**#define XMC_FLASH_PHY_SECTOR_11 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0xC0000UL) /**
Best regards,
Jesus
0 Likes