MPC5554 FLASH PROGRAM ERROR

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

MPC5554 FLASH PROGRAM ERROR

545 Views
xianggan
Contributor I

说明:

    1.CPU型号为MPC5554;

    2.时钟频率为:8Mhz;

    3.在编程FLASH前已经完成0x00000000~0x80000地址的编程解锁并擦除,而且经检查确认地址范围内都是0xFF。

  4.程序运行在内部flash的0x110000~0x150000地址空间;

  

FLASH 编程代码如下:

    void  WriteFlash(void)

{

       uint64_t  *pFlash,*pData ;

       int32_t  i,j,k,len;

       uint16_t  code[256];

        pFlash = (uint64_t *)0x000000;

        uint64_t  LongWordData;

      

        FLASH. MCR. B. PGM =1;

       for(len=0,len<0x100000;len=len+256)

     {

            Read256ByteFromCANbus((uint16_t *)code);

           pData=(uint64_t *)code;

          for(i=0;i<8;i++)

         {

                 for(j=0;j<4;j++)

                {//write 256bt

                      LongWordData = *pData ++;

                      *pFlash ++ = LongWordData;

                 }

                 FLASH. MCR. B. EHH =1;

                for(k=0;k<4000;k++)

               {  if(FLASH.MCR.B.DONE)  break;

                }

               FLASH. MCR. B. EHV=0;

           }

      }

     FLASH. MCR. B. PGM=0;

      FLASH. MCR. B. BFEN=0;

      FLASH. MCR. B. BFEN=1;

}

问题:使用上述代码写入数据到0~0x40000地址范围不会有任何问题;但写入数据到0~0x80000地址范围时,在0x40000~0x80000地址范围(具体地址随机,不固定)出现ECC错误。

Labels (1)
0 Kudos
1 Reply

428 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this is not a problem from microcontroller's point of view. I slightly modified your code for my quick test and this piece of code works as expected:

FLASH.MCR.B.PGM = 1;
  for(len=0;len<0x80000;len=len+32)

  {
    for(j=0;j<8;j++)

    {
        *(unsigned int*)(len + (j*4)) = len + (j*4);
    }    
    FLASH.MCR.B.EHV = 1;
     while(FLASH.MCR.B.DONE == 0)
     {
     };
     FLASH.MCR.B.EHV = 0;
  }
  FLASH.MCR.B.PGM = 0;

By the way, if you use timeout for checking DONE bit, you should catch such event, not just continue...

Regards,

Lukas

0 Kudos