Programmatically erase flash memory block
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-03-02 6:57 AM
Posted on March 02, 2016 at 15:57
Good morning to everyone.
I am trying to erase a flash memory block. I am try not to use the drivers. As now, I managed to program individual memory cells of the flash memory with storage data, following the Reference Manual at page 6 Now, in order to store new values, I want to programmatically erase a flash memory block following the guide at page 6 I use the following code:CFLASH.MCR.R = CFLASH.MCR.R | 0x4; /* Change the value of MCR[ERS] bit from 0 to 1. */
CFLASH.HBS.B.HSL = 0b01; /* Select H0 flash memory block: High Address Space starting at 0x0008_0000*/
*(ULONG*)0x00080000 = 1; /* Interlock writing as per RM pag 6*/
CFLASH.MCR.R = CFLASH.MCR.R | 0x1; /* Set MCR[EHV] to 1, in order to start an internal erase sequnece. */
/*... unreachable code. */
The problem is that, after setting MCR[EHV] to 1, the micro go in error. The strange thing is that MCR[RWE] is set to 1, indicating a Read While Write Event Error. I don't understand why this is the case.
I am trying the operation on a block where there is no program code (only a stored value) and I am doing the actions prescribed by the RM. The block is not locked: the corresponding bit in HBL register is set to 0.
Resets using other tools work, so is not a problem of the flash, but of the code.
Someone has some idea regarding this code snippet?
Thank you,
Ivan
#flash-erase
Labels:
- Labels:
-
Flash
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-08 1:46 AM
Posted on April 08, 2016 at 10:46Hello Ivan ,sorry for the late answer,Did you solve the issue ?Could you confirm the device used ?you can find the flash driver in the SPC5Studio Eclipse marketplace.(cf screenshot)often , after generating an internal erase sequence , you have to wait for completion/* Waiting completion then stopping operation.*/ while (!DFLASH.MCR.B.DONE) ; Best regards Erwan
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-04-08 1:47 AM
Posted on April 08, 2016 at 10:47
screenshot here
________________ Attachments : 2016-04-08_104205.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006qWdT&d=%2Fa%2F0X0000000boS%2FW_iJvckj2YOagM.FKDQaQl6Q8DSypU48UOtvE4Z9iag&asPdf=falseOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-05-03 8:39 AM
Posted on May 03, 2016 at 17:39
Hello Erwan.
I found the driver of which you spoke and learned to use it. Now the issue is solved.Thank you,Ivan