Flash MPC55xx

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Flash MPC55xx

3,451件の閲覧回数
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,107件の閲覧回数
jonr
Contributor III

3,107件の閲覧回数
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 件の賞賛
返信