cancel
Showing results for 
Search instead for 
Did you mean: 

I am using DFLASH for storing data at multiple locations. Code is attached below. "READ MEMORY BLOCK FAILED" error.

Pooja WANI
Associate II

#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

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
3 REPLIES 3
Erwan YVIN
ST Employee

Hello ,

Could you tell more details of your Program Counter (By Assembler) ?

we do not know where the program is.

Best Regards

Erwan

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.

0690X00000At9nvQAB.png0690X00000At9nqQAB.png0690X00000At9nlQAB.png

Thank you.

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