Recently I find a problem of MPC5744P clock mode.I use MCAL code provide by NXP.
I find that if I initialize system clock in DRUN mode,I can't initialize it again.Even if this clock mode and clock configuration are same,never operate any other module and peripheral,system clock was force set to IRC,and MC_ME_GS.S_MTRANS always 1,that means mode transition always ongoing and system clock always 16MHZ.
I wonder how it happened,and how to deal with it.It's necessary for bootloader development.When bootloader initialize clock,after jump to app it can't set correct system clock.
Thanks,here append a sample code.
Mcu_Init(&McuConfigPB_0);
(void)Mcu_InitClock(McuClockSettingConfig);
while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
{
}
Mcu_DistributePllClock();
(void)Mcu_InitClock(McuClockSettingConfig);
2019.8.15 Update
It's useful that switch to a mode that disable all peripherals before re-initialize clock.After that switch to normal mode.But here still a problem,if called Spi_DeInit() in bootloader,DSPI2 can't be disabled.I also find this problem when using NXP SDK code.
Code like this.
Mcu_Init(&McuConfigPB_0);
Mcu_InitClock(McuClockSettingConfig);
while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
{
}
Mcu_DistributePllClock();
Spi_Init();
Spi_DeInit();
Jump_ToApp();
Mcu_Init(&McuConfigPB_0);
Mcu_SetMode(RUN0);
Mcu_InitClock(McuClockSettingConfig);
while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
{
}
Mcu_DistributePllClock();
Mcu_SetMode(DRUN);