MKV31 switching power modes and clock frequencies

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKV31 switching power modes and clock frequencies

720 Views
renatodutra
Contributor I

When the microcontroller starts the frequency of operation (core) is set to 95.9774 MHz using the internal reference clock (32.768 kHz).
In order to store non-volatile information to the microcontroller, the last segment of the flash memory is used, and the power mode is switched from HSRUN to RUN with a core frequency of 62.9MHz. The writing to the flash memory is successful and then the microcontroller is switched back to HSRUN, however the core frequency instead of going back to 95.9774 MHz it goes to 83.88 MHz.

To set RUN mode:


CLOCK_SYS_SetConfiguration(&g_defaultClockConfigRun);
powerModeConfig.powerModeName = kPowerModeRun;
SMC_HAL_SetMode(SMC, &powerModeConfig);


To set HSRUN mode:


powerModeConfig.powerModeName = kPowerModeHsrun;
SMC_HAL_SetMode(SMC, &powerModeConfig);
CLOCK_SYS_SetConfiguration(&g_defaultClockConfigHsRun);

 

g_defaultClockConfigRun and g_defaultClockConfigHsRun configuration attached (both generated by processor expert)

 

Any idea why the HSRUN frequency is not returning to 95.9774MHz?

Any help appreciated. 

 

Thanks.

Original Attachment has been moved to: clock_configurations.txt.zip

Labels (1)
0 Kudos
4 Replies

512 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding your question, I attach the MCG table.

95.9774MHz/0.032768MHz=2929

83.88MHz/0.032768MHz=2529

62.9MHz/0.032768MHz=1919

Do you use external precise 32.768KHz crystal and set DRST_DRS=11 and DMX32=1 to get 95.9774MHz clock?

I think the 83.88MHz is an expected clock frequency if you use default FEI mode and internal 32.768KHz IRC.

Hope it can give you clue?

BR

XiangJun Rong

pastedImage_1.png

0 Kudos

512 Views
renatodutra
Contributor I

Hi Xiangjun,

Thanks for the prompt reply.

Yes, I'm using the internal reference clock (32.768kHz).

My question is why, when I start the microcontroller the clock is running at 95.9774MHz, but after I switch power modes it can no longer go back to the original clock of 95.9774MHz.

Thanks for your help.

-rd

0 Kudos

512 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The configuration of DRST_DRS and DMX32 bits are different for high speed mode and normal speed mode.

For HighSpeed Run mode:

.mcgConfig =
        {
            .mcg_mode = kMcgModeFEI, /*!< FEI mode */
            /* ------------------ MCGIRCCLK settings ---------------------- */
            .irclkEnable = true, /*!< MCGIRCLK enable */
            .irclkEnableInStop = false, /*!< MCGIRCLK enable in stop mode */
            .ircs = kMcgIrcSlow, /*!< Slow internal reference clock selected */
            .fcrdiv = 0U,

            /* -------------------- MCG FLL settings ---------------------- */
            .frdiv = 0, /*!< MCG_C1[FRDIV] */
            .drs = kMcgDcoRangeSelHigh, /*!< MCG_C4[DRST_DRS] */
            .dmx32 = kMcgDmx32Fine, /*!< MCG_C4[DMX32] */
            .oscsel = kMcgOscselOsc, /*!< Selects System Oscillator (OSCCLK) */

        },

For normal speed run mode:

        .mcgConfig =
        {
            .mcg_mode = kMcgModeFEI, /*!< FEI mode */
            /* ------------------ MCGIRCCLK settings ---------------------- */
            .irclkEnable = true, /*!< MCGIRCLK enable */
            .irclkEnableInStop = false, /*!< MCGIRCLK enable in stop mode */
            .ircs = kMcgIrcSlow, /*!< Slow internal reference clock selected */
            .fcrdiv = 0U,

            /* -------------------- MCG FLL settings ---------------------- */
            .frdiv = 0, /*!< MCG_C1[FRDIV] */
            .drs = kMcgDcoRangeSelMidHigh, /*!< MCG_C4[DRST_DRS] */
            .dmx32 = kMcgDmx32Default, /*!< MCG_C4[DMX32] */
            .oscsel = kMcgOscselOsc, /*!< Selects System Oscillator (OSCCLK) */

        },

Hope it can helkp you

BR

XiangJun Rong

0 Kudos

512 Views
renatodutra
Contributor I

Hi xiangjun,

Thanks for the reply.

I do understand that the configuration for HSRUN is different to RUN, as you can see on the file that I have attached on my first post. My question is related to the fact that  the microcontroller cannot go back to the original clock rate.

Here is a brief description of the scenario I'm currently experiencing:

- Microcontroller starts in HSRUN operating at ~95MHz (OK)

- Microcontroller has its power mode switched RUN operating at ~62MHz (OK)

 - Writing to flash is successfully done. (OK)

- Microcontroller is switched back to HSRUN (OK), however the clock frequency goes to ~88MHz instead of going back to 95MHz.

And that is my question. Why I cannot go back to 95MHz? Why it stays at 88MHz?

I appreciate your help on this.

Regards,

rd 

0 Kudos