AnsweredAssumed Answered

MPC5567: word based Flash programming routine

Question asked by Marco Mondo on Sep 11, 2009
Latest reply on May 9, 2013 by Jon Zeeff

Hi,

 

 

I am developing a routine to write a single word in internal flash.

 

I've tryed the following code but it doesn't work:

 

 

 //The sector is already unlocked

 

 t_WORD *pa;

 

pa = (t_WORD *)0xA0000; //High Memory, sector 1 

 

  FLASH.MCR.B.PEAS = 0;
  FLASH.MCR.B.PGM = 1;
 *pa = 0xCAFE;   // Data Interlock Write
  FLASH.MCR.B.EHV = 1;
   while(!FLASH.MCR.B.DONE)
      {
       ; 
      }
      FLASH.MCR.B.PEG = 1;
      FLASH.MCR.B.EHV = 0;
      FLASH.MCR.B.PGM = 0;

 

 ...

 

The question is that if when the "data interlock" instruction an EXCEPTION IVOR2 arise and the system hang.

What's wrong with the code above?

 

Thanks to all,

 

emme

 

emme

Outcomes