Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
User7688
Level 2
Level 2
Hi, I need to read the sector10/11 flash memory, FLASH_READ run from PSRAM .
The code reads the address to 0c082800 , then generates BusFault_Handler .
What is wrong with my code ?

int main(void)
{
uint32_t count=(512*1024)/256;
uint32_t Address=FLASH_SECTOR10_BASE;
uint8_t buff[FLASH_PAGE_SIZE];

while(count--)
{
FLASH_Read(Address, &buff, FLASH_PAGE_SIZE/4);
Address+=FLASH_PAGE_SIZE;
}
}

void FLASH_Read(uint32_t Address, uint32_t * buff, uint32_t count4)
{
while(count4--)
{
volatile uint32_t * p = (volatile uint32_t * )(Address);
uint32_t dtemp = *p;
*buff=dtemp;
buff++;
Address+=4;
}
}
0 Likes
7 Replies
Not applicable
HI,

You are missing the while(1); statement at the end of int main(void). 🙂

Regards,
Daryl
0 Likes
User7688
Level 2
Level 2
Hi, The code works correctly.

the problem was that memory was corrupted by writing a page that contained zeros , but it wasalready written with zeros. when I wanted to read the memory generated BusFault_Handler

thank you
0 Likes
Not applicable
Hi,

I hope your problem is already solved.

From the code you provided, there was no programming of the flash.

The issue I think is that the missing while (1) at the end of the int main(void). Without this line of code, the code will continue to execute beyond the code space. This might have cause the error to occur.

int main(void)
{
uint32_t count=(512*1024)/256;
uint32_t Address=FLASH_SECTOR10_BASE;
uint8_t buff[FLASH_PAGE_SIZE];

while(count--)
{
FLASH_Read(Address, &buff, FLASH_PAGE_SIZE/4);
Address+=FLASH_PAGE_SIZE;
}

while(1U) // this is missing.
{

}
}
0 Likes
User7688
Level 2
Level 2
thanks for the reply.

that is not the actual code , copy only part , to see if my code was right .

I solved and wrote bad flash memory and when I wanted to read it generated BUSFAULT .

this is because the endurance of xmc4500 is so poor, ( only 100 erases ) .
then I had to save the flash memory until this is full, and back again to erase .
when booting the operating system , read the latest flash program and executed.

and I solved it all, thanks .
thank you.
0 Likes
Not applicable
HI,

From the datasheet, the data retention time for the flash sector is 20 years for a maximum of 1000 erase cycles (for physical sector) and 100 erase cycles(for logical sector). In a real application, if we do not require the data retention time of less than 20 years, the number of supported erase cycles can be larger than 1000 erase cycles for the physical sectors. Normally, the assumed use case is for code firmware storage where the firmware update is limited.

If required to use the flash as data, it is recommended to use an external EEPROM or an emulated EEPROM on the flash (like what you have currently done for your code). This will improve the flash endurance as the erase/program cycles are now limited.

For your information, in DAVE:
XMC1000 devices: We have an E_ERPROM_XMC1 APP, that emulates a portion of the flash as an EEPROM for data storage. This is available today.
XMC4000 devices: Releasing an EEPROM APP for XMC4000 devices in Jan 2016. This will emulate the behaviour of an EEPROM on XMC4000 series device, aim to increase the flash endurance for writing data.

Regards,
Daryl
0 Likes
User7688
Level 2
Level 2
Hi, Daryl

http://www.infineonforums.com/threads/691-xMC4000-Flash-endurance.?highlight=ENDURANCE

"if you are doing Programming / Erasing only on a particular sector (eg. update of ROM table), then you are limited only to 100 times."

If I erase/program (eg . S10 ) . on how many cycles , can I?
0 Likes
Not applicable
Hi,

If it is S10, it belongs to the logical sector. The cycles are limited to 100 times for a 20 years data endurance.

Regards,
Daryl
0 Likes