Problem using FLASH002-App

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

cross mob
Not applicable
Hallo,

I'm trying to erase flash memory by using FASH002-App, but I get a sequence error SQER on a XMC4500 MCU. It seems that the compiler optimizes away the first line in "Flash002_EraseSector" as the same adress is accessed twice:


/* Clear the flash status register */
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000F5U;
/* Erase sequence */
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000AAU;
M32(FLASH002_UNCACHED_BASE + 0xAAA8U)=0x00000055U;
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x00000080U;
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000AAU;
M32(FLASH002_UNCACHED_BASE + 0xAAA8U)=0x00000055U;
M32(Address)=0x00000030U;


Using a volatile in M32 macro helps. But of course, this change is lost if I run the code generator again. How can I use the function without a SQER?

Thanks
0 Likes
2 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
endres wrote:
Hallo,

I'm trying to erase flash memory by using FASH002-App, but I get a sequence error SQER on a XMC4500 MCU. It seems that the compiler optimizes away the first line in "Flash002_EraseSector" as the same adress is accessed twice:

Using a volatile in M32 macro helps. But of course, this change is lost if I run the code generator again. How can I use the function without a SQER?

Thanks


Can you please use the "Flash002_EraseSector"?


#include
int main(void)
{
uint32_t status;
uint32_t StartAddr = FLASH002_SECTOR7_BASE;
// Initialize
DAVE_Init(); // FLASH002_Init() will be called within DAVE_Init()
status = Flash002_EraseSector(StartAddr);
while(1)
{
}
}

0 Likes
Not applicable
Hi,

I'm using "Flash002_EraseSector". The code is extracted out of this function. I forgot to mention that. I also tried this example before. Same problem there. Stepping over the last line "M32(Address)=0x00000030U;" rises a SQER-error.
0 Likes