Skip to content

K64 FSL gets stuck in CLOCK_SetExternalRefClkConfig (FSL upgrade needed) #10897

@Alex-EEE

Description

@Alex-EEE

Description

In case anyone out there runs into this issue, and in case anyone wants to file a PR to address it.

The current FSL for Kinetis K64 is out of date. That hasn't generally been a problem, but when trying to bring up a custom board, mbed-os was getting stuck in this step in the mbed version of the FSL:

status_t CLOCK_SetExternalRefClkConfig(mcg_oscsel_t oscsel) {
...
    MCG->C7 = (MCG->C7 & ~MCG_C7_OSCSEL_MASK) | MCG_C7_OSCSEL(oscsel);
    if (kMCG_OscselOsc == oscsel)
    {
        if (MCG->C2 & MCG_C2_EREFS_MASK)
        {
            while (!(MCG->S & MCG_S_OSCINIT0_MASK))
            {
            }
        }
    }
    if(needDelay)
...

After pulling the latest FSL from NXP, I noticed they removed this while loop. Looks like mbed has a buggy version of fsl_clock.c

FSL version:

status_t CLOCK_SetExternalRefClkConfig(mcg_oscsel_t oscsel) {
...
    MCG->C7 = (MCG->C7 & ~MCG_C7_OSCSEL_MASK) | MCG_C7_OSCSEL(oscsel);
    if(needDelay)
...

Using this version of fsl_clock.h, fsl_clock.c, my board boots to main no problem.

Issue request type

[ ] Question
[ ] Enhancement
[X ] Bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions