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
You can go to:
for some working flash burning code.
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;