K64 and 24Mhz external crystal

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

K64 and 24Mhz external crystal

1,381 Views
yuriydovgalyuk
Contributor III


Hi all,

I have a PCB with k64fx512 MCU onboard (self-made), additionally there is 24MHz crystal connected to the MCU as external clock source.

The problem I faced with when I tried to enter PEE state is that it seems to be impossible.

In order to transfer to PEE, it is necessary to perform a transition to FBE mode. For this, it is required to setup correct divider into FRDIV register, so the frequency is between 31.25 kHz to 39.0625 kHz. But this is impossible with the dividers options available: 32, 64, 128, 256, 512, 1024, 1280, 1536.

When I set divider to 512 or any other, I never can pass the check of IREFS to be cleared. The code waits for IREFS to be 0, and it hangs there.

Is there any ways to overcome this issue?

Additionally, I cannot use IRC48M as a source for MCG - same situation, wait forever for IREFS to be cleared. But KDS suggests that according to AN4905 IRC48M cannot be used as MCG source due to chip limitations.

Will be grateful for the help.

Labels (1)
6 Replies

947 Views
Stano
NXP Employee
NXP Employee

Hi Yuriy,

sorry for the delay with answer.

As you know there are two ways to solve this issue. The first step is to change the external crystal to range from 16MHz to 20MHz, then use FRDIV = 512 to access FBE mode.

The second way is to use internal 48MHz clock source (IRCLK) and divide by 1536 to access FBE mode. To enable the IRCLK it has to be set MCG_C2_IRCS = 1 and MCG_C1_IRCLKEN = 1.

I think it will help you.

Best Regards,

Stano.

947 Views
yuriydovgalyuk
Contributor III

Hi Stanislav,

Yes, you are right. I decided to go with option #2 -  use internal 48 MHz clock source - which is fine for my project now. It is also important not to forget enable clocking to USB :smileyhappy:.

BUT, the main reason why 24MHz oscillator was soldered is because in the datasheet it says that the MCU supports:

- 3 to 32 MHz and 32 kHz crystal oscillator.

The question arises than why Freescale/NXP states this in the datasheet, if in fact not all crystals in this range can be used. To my mind this is confusing.

Thanks for you answer! :smileyhappy:

0 Kudos

947 Views
inderjitjutla
Contributor II

Hello, are you using the kinetis sdk? I'm trying to do something similar to you but having issues with getting the right configurations. Can you show me your clock_manager_user_config_t if you have it? As in your MCG Config. And your osc_user_config_t.

0 Kudos

947 Views
yuriydovgalyuk
Contributor III

Sure, here you are:

/* Configuration for enter RUN mode. Core clock = 120MHz. */

const clock_manager_user_config_t g_defaultClockConfigRunIrc48 =

{

    .mcgConfig =

    {

        .mcg_mode           = kMcgModePEE,   // Work in PEE mode.

        .irclkEnable        = true,  // MCGIRCLK enable.

        .irclkEnableInStop  = false, // MCGIRCLK disable in STOP mode.

        .ircs               = kMcgIrcSlow, // Select IRC32k.

        .fcrdiv             = 0U,    // FCRDIV is 0.

        .frdiv   = 0U,

        .drs     = kMcgDcoRangeSelLow,  // Low frequency range

        .dmx32   = kMcgDmx32Default,    // DCO has a default range of 25%

        .oscsel  = kMcgOscselIrc,       // Select OSC

        .pll0EnableInFllMode = true,  // PLL0 enable

        .pll0EnableInStop    = false,  // PLL0 disalbe in STOP mode

  .prdiv0              = 9U,

        .vdiv0               = 1U,

    },

    .simConfig =

    {

        .pllFllSel = kClockPllFllSelPll,    // PLLFLLSEL select PLL.

        .er32kSrc  = kClockEr32kSrcLpo,// Rtc,     // ERCLK32K selection, use RTC.

        .outdiv1   = 0U,

        .outdiv2   = 1U,

        .outdiv3   = 2U,

        .outdiv4   = 4U,

    },

    .oscerConfig =

    {

        .enable       = true,  // OSCERCLK enable.

        .enableInStop = false, // OSCERCLK disable in STOP mode.

    }

};

osc_user_config_t osc0Config =

    {

        .freq                = OSC0_XTAL_FREQ,

        .hgo                 = MCG_HGO0,

        .range               = MCG_RANGE0,

        .erefs               = MCG_EREFS0,

        .enableCapacitor2p   = OSC0_SC2P_ENABLE_CONFIG,

        .enableCapacitor4p   = OSC0_SC4P_ENABLE_CONFIG,

        .enableCapacitor8p   = OSC0_SC8P_ENABLE_CONFIG,

        .enableCapacitor16p  = OSC0_SC16P_ENABLE_CONFIG,

    };

But keep in mind I am using internal 48Mhz osc. It is impossible to use 24MHz external crystal.

0 Kudos

947 Views
inderjitjutla
Contributor II

Thanks! That makes sense. Although I still can't seem to get the mcu working. Could you show me your BOARD_ClockInit, BOARD_InitOsc0, and CLOCK_SetBootConfig for the above configs? Did you have to boot to FBE or should I be able to boot to PEE with that config? I'm also using an external 32.768kHz crystal for the RTC.

0 Kudos

947 Views
yuriydovgalyuk
Contributor III

Hi again,

It seems that no one have a ready made answer for my question.

So, I have an additional question:

Is that possible to switch to FBE mode using IRC48M (just to satisfy the conditions) and afterwards proceed to PEE mode using external 24MHz crystal oscillator?

0 Kudos