Problem of MPC5744P clock mode switch.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem of MPC5744P clock mode switch.

838 次查看
xinxin_you
Contributor II

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);
                       /* Initialize clock */
    (void)Mcu_InitClock(McuClockSettingConfig);

    while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
    {
        /* wait until all enabled PLLs are locked */
    }
    
    Mcu_DistributePllClock();                   /* switch system clock tree to PLL */
    (void)Mcu_InitClock(McuClockSettingConfig);‍‍‍‍‍‍‍‍‍‍‍/*Always 16MHZ and mode transition ongoing*/‍‍‍‍‍‍‍‍‍‍‍

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.

    
/*In Bootloader,only initialize SPi and clock,before jump to app,deinit spi*/
Mcu_Init(&McuConfigPB_0);
    Mcu_InitClock(McuClockSettingConfig);
    while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
    {
        /* wait until all enabled PLLs are locked */
    }
    Mcu_DistributePllClock();

   Spi_Init();

   Spi_DeInit();
   Jump_ToApp();
/*Here is app,I want to disable all peripheral before re-initialize clock but it's failed*/
    Mcu_Init(&McuConfigPB_0);
    Mcu_SetMode(RUN0);/*Here the RUN0 mode will disable all peripheral*/
    /*It's failed,DSPI2 can't disable,MC_ME_PS6.S_DSPI2 is 1*/
    /*So clock initialize can't finished,always ongoing*/
    Mcu_InitClock(McuClockSettingConfig);
    while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
    {
        /* wait until all enabled PLLs are locked */
    }
    Mcu_DistributePllClock();
    Mcu_SetMode(DRUN);/*Switch to normal mode*/
标签 (1)
0 项奖励
回复
0 回复数