Flash MPC55xx

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Flash MPC55xx

3,454 次查看
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

标签 (1)
2 回复数

3,110 次查看
jonr
Contributor III

3,110 次查看
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 项奖励
回复