Hello Neo, sorry I missed your question before... I known chances are you may not have this problem anymore, but for future reference, this is the code that I modified.... based on the memory_config_160mhz() function included with many of NXP examples:
void memory_config_160mhz(void)
{
/* If waking up (DRUN clock is set to PLL), wait until FXOSC and PLL has been stabilized */
if (ME_SYSCLK_PLL_PHI_0 == MC_ME.DRUN_MC.B.SYSCLK)
{
/* System clock is PLL, so this is a wake up event */
while (MC_ME.GS.B.S_FXOSC == 0)
{
/* Wait for FXOSC to stabilize */
}
while (MC_ME.GS.B.S_PLLON == 0)
{
/* Wait for PLL to provide stable clock */
}
}
... /* Same as NXP sample code */
typedef void (*mem_write_code_ptr_t)(uint32_t, uint32_t);
/* create a new type def: a func pointer called mem_write_code_ptr_t */
/* which does not return a value (void) */
/* and will pass two 32 bit unsigned integer values */
/* (per EABI, the first parameter will be in r3, the second r4) */
asm (" mbar"); /* Wait for prior code to complete before proceeding. */
(*((mem_write_code_ptr_t)mem_write_code_vle))
/* cast mem_write_code as func ptr */
/* "*" de-references func ptr, i.e. converts to func*/
(PFLASH_PFCR1_VALUE_160MHz, /* which passes integer (in r3) */
(uint32_t)&PFLASH_PFCR1_REG); /* and address to write integer (in r4) */
...
...
...
}