AnsweredAssumed Answered

MC5604P - In Application Programming - erase/modify Code Flash

Question asked by Steffen Rose on Jul 1, 2015
Latest reply on Jul 7, 2015 by Lukas Zadrapa



I want to implement a Bootloader. But my implementation of the Erase and Flash functionality will not work.

I'm wondering that it is not working (possible) AND no error bit is set (why?).


The next function should flash some test data to the Code Flash at 0x0000.8000. This area is erased.

The function is located in RAM (0x4000.00A8).


#pragma section RX ".ramfunction" ".ramfunction" data_mode=far_abs code_mode=far_abs


__declspec(section ".ramfunction") void write(void);

void write(void)


    //CFLASH.MCR.R = 0x10;

    CFLASH.MCR.B.PGM = 1; //double word / 8 Byte


     *(U32*)0x8000 = 0x11223344;

     *(U32*)0x8004 = 0x11223344;


    //CFLASH.MCR.R = 0x11;

    CFLASH.MCR.B.EHV = 1; /* start program */

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




    //CFLASH.MCR.R = 0x10;

    CFLASH.MCR.B.EHV = 0; /* stop program */


    //CFLASH.MCR.R = 0x00;       




CFLASH_LMLR->LME - Lock is disabled

CFLASH_SLMLR->SLE - Lock is disabled


I'm the meaning this sequence ist described in MPC560XPRM.pdf / Double word program.


Hope anybody can tell me my mistake or ideas to check additional prerequirements. Also an example Sourcecode for the CodeWarrior 5.9 would be nice.

Thank you very much.