2019-11-19 11:47 PM
#include "components.h"
unsigned int i, location_no, data[9];
int main(void)
{
/* Memory Unlock */
DFLASH.LML.R = 0xA1A11111; //write password
DFLASH.LML.R = 0x00000000; //unlock all 4 16k blocks
DFLASH.SLL.R = 0xC3C33333; //write password
DFLASH.SLL.R = 0x00000000; //unlock all 4 16k blocks
/* Read */
for(location_no=0; location_no<9; location_no++)
{
data[location_no] = *(unsigned int *)(0x00800000 + (location_no << 2));
}
/* Erase */
DFLASH.MCR.B.ERS = 1; //erase operation
DFLASH.LMS.R = 0xF; //select all 4 block for erase
*(unsigned int *)0x0080FFFC = 0xFFFFFFFF; //interlock write
DFLASH.MCR.B.EHV = 1;
while((DFLASH.MCR.B.DONE != 1) && (DFLASH.MCR.B.PEG != 1));
DFLASH.MCR.B.EHV = 0;
DFLASH.MCR.B.ERS = 0;
/* Program */
DFLASH.MCR.B.PGM = 1; //Program operation
//*(unsigned int *)0x00800000 = 0xAABBCCDD; //interlock write
for(location_no=0; location_no<9; location_no++)
{
*(unsigned int *)(0x00800000 + (location_no << 2)) = 0xAABBCC*location_no;
DFLASH.MCR.B.EHV = 1;
while((DFLASH.MCR.B.DONE != 1) && (DFLASH.MCR.B.PEG != 1));
DFLASH.MCR.B.EHV = 0;
}
DFLASH.MCR.B.PGM = 0;
return 0;
}
When I am trying to write word by word to multiple locations, while writing 4th word, an error is occured.. READ MEMORY BLOCK FAILED. However, next 5 locations are written successfully.
Screenshot is attached below.
I am looking forward for the reply.
Thanks and Regards,
Pooja WANI
2019-11-28 07:49 AM
Hello ,
Could you tell more details of your Program Counter (By Assembler) ?
we do not know where the program is.
Best Regards
Erwan
2019-12-01 09:07 PM
Some screenshots from PLS UDE window are attached herewith. Please help me to find out the solution. I am blocked here since last two weeks.
Thank you.
2019-12-03 02:34 AM
Hello,
When I wrote it at alternate locations. I could write successfully. This may be due to ECC calculations (not sure though).
However, after turning the power off, I could not read the previously stored data.
Thanks and Regards,
Pooja WANI