Flash MPC55xx

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

Flash MPC55xx

1,682 Views
joesmith
Contributor I

    Hi Can Anyone give me some advice on how to program me the flash on mpc55xx, in C.

 

I have the following code

 

main()

{

  unsigned long* FlashRegister   ;

 

  FLASH.HLR.R = 0xB2B22222;

  FLASH.HLR.B.HBLOCK = 0b1;

  FLASH.HSR.B.HBSEL = 0b1;

 

  FlashRegister = ((unsigned long*)(0x80000));

 

  FLASH.MCR.B.PGM = 1;

  *(FlashRegister) = 5;

 

  FLASH.MCR.B.EHV = 1;

 

  while(FLASH.MCR.B.DONE == 0)

  {

 

  }

  FLASH.MCR.B.EHV = 0;

  FLASH.MCR.B.PGM = 0;

}

 

but when i try and read the address back it still says its 0xffffffff.

 

It properly something really stupid.

 

Cheers

 

Joe

Labels (1)
2 Replies

1,339 Views
jonr
Contributor III

1,339 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Probably too late but:

FLASH.HLR.B.HBLOCK = 0b1;

"1" means the flash block is locked

"0" means the block can be erase/programmed.

So, it should be changed to:

FLASH.HLR.B.HBLOCK = 0b0;     //unlock all high blocks

If you program the flash, it is not necessary to set the HSR register. This line can be deleted:

FLASH.HSR.B.HBSEL = 0b1;

0 Kudos
Reply