Why can`t I write 0x12345678 twice continuously to flash code memory of MPC5675K?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why can`t I write 0x12345678 twice continuously to flash code memory of MPC5675K?

1,672 Views
小兜麦
Contributor II

Hello!

     Why can`t I write 0x12345678 twice continuously to flash code memory? But I can do this in data memory!

     Does someone know how to do this ?

    Thank you !

 

 

 

   Xiaodou Mai

Labels (1)
0 Kudos
8 Replies

1,402 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this is copied from reference manual (http://www.freescale.com/files/32bit/doc/ref_manual/MPC5675KRM.pdf):

“For the code flash memory module, word size is fixed at 64 bits. Each 64-bit doubleword is associated with 8 ECC bits that are programmed to enable a Single-bit Error Correction and a Double-bit Error Detection (SECDED).

For the data flash memory module, word size is fixed at 32 bits. Each 32-bit word is associated with 7 ECC bits that are programmed to enable SECDED.”

That means we are allowed to program doubleword only once per erase. In other words, we should not program double word which is not fully erased.

So, we should program the data in this way to code flash:

FLASH_A.MCR.B.PGM = 1;

*(unsigned int*)0x1000 = 0x12345678;

*(unsigned int*)0x1004 = 0x12345678;

FLASH_A.MCR.B.EHV = 1;

while(FLASH_A.MCR.B.DONE == 0){};

FLASH_A.MCR.B.EHV = 0;

FLASH_A.MCR.B.PGM = 0;

If the data are programmed in two steps then it leads to ECC error.

Regards,

Lukas

0 Kudos

1,402 Views
小兜麦
Contributor II

Hi,

Thank for your great answer!

I want to program doubleword continuously to Mid/High Address Space.And I have read the datasheet of 5675K and it said "The first (lower addresses) 16 bytes (128 bits) of every 32-byte aligned range are stored in CFM0 and the last 16 bytes

(128 bits) are stored in CFM1".What do I do to program more than 16 bytes to Mid/High Address Space in 5675K?

Can you give me the similar code example?

I wish your answer,sir.

Thank you!

0 Kudos

1,402 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

//CMF0

FLASH_A.MCR.B.PGM = 1;

*(unsigned int*)0x00080000 = 0x12345678;

*(unsigned int*)0x00080004 = 0x12345678;

FLASH_A.MCR.B.EHV = 1;

while(FLASH_A.MCR.B.DONE == 0){};

FLASH_A.MCR.B.EHV = 0;

FLASH_A.MCR.B.PGM = 0;

FLASH_A.MCR.B.PGM = 1;

*(unsigned int*)0x00080008 = 0x12345678;

*(unsigned int*)0x0008000C = 0x12345678;

FLASH_A.MCR.B.EHV = 1;

while(FLASH_A.MCR.B.DONE == 0){};

FLASH_A.MCR.B.EHV = 0;

FLASH_A.MCR.B.PGM = 0;

//CMF1

FLASH_B.MCR.B.PGM = 1;

*(unsigned int*)0x00080010 = 0x12345678;

*(unsigned int*)0x00080014 = 0x12345678;

FLASH_B.MCR.B.EHV = 1;

while(FLASH_B.MCR.B.DONE == 0){};

FLASH_B.MCR.B.EHV = 0;

FLASH_B.MCR.B.PGM = 0;

FLASH_B.MCR.B.PGM = 1;

*(unsigned int*)0x00080018 = 0x12345678;

*(unsigned int*)0x0008001C = 0x12345678;

FLASH_B.MCR.B.EHV = 1;

while(FLASH_B.MCR.B.DONE == 0){};

FLASH_B.MCR.B.EHV = 0;

FLASH_B.MCR.B.PGM = 0;

And then continue in the same way.

Next option is to use SSD flash drivers:

http://www.freescale.com/files/32bit/software/MPC567xK_C90LC_Flash_SSD.exe

When using the drivers, you do not need to take care about the blocks, everything is managed by the drivers. 

Regards,

Lukas

0 Kudos

1,402 Views
zhouxian
Contributor III

Could you tell me how to use the c-array_driver as provided in Standard Software C90LC Driver v1.0.4. Besides,  I want to use the driver in the S32DS  IDE, where can I find the lib files?

0 Kudos

1,402 Views
小兜麦
Contributor II

Hi,

Thank you again!

I want to operate software system reset at the end of my program. I cant not make sure which register can generate a software system reset.Can you give me the example code?

Regards,

xiaodou Mai

0 Kudos

1,402 Views
anegoiko
Contributor III

Hi,

Yesterday I made the same question by myself, and David Tosenovjan replied here:

Does MPC5606B support software reset?

I hope it will be usefull for you too.

Regards,

1,402 Views
小兜麦
Contributor II

Thank you very much!Your answer gave me much assistance!

0 Kudos

1,402 Views
anegoiko
Contributor III

Hi,

I'm trying to do a system reset at the end of my program too. Did ypu finally get it?

Thanks,

0 Kudos