This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

clock_control_on returns -EPERM on ncs 1.4.0

Hi,

When upgrading a project from ncs 1.3.0 to 1.4.0, the clock_control_on() call behaves different; It always returns -EPERM. Did the API change?

The call is used as follows:

static int clock_init(void)
{
    int err;
    const struct device *clock;

    clock = device_get_binding(DT_INST_LABEL(0));
    if (!clock) {
        printk("Unable to find clock device binding\n");
        return -ENODEV;
    }

    err = clock_control_on(clock, CLOCK_CONTROL_NRF_SUBSYS_HF);
    if (err) {
        printk("Unable to turn on the clock: %d", err);
    }

    return err;
}

Thanks,

-Bastiaan

Parents Reply
  • Hi Håkon,

    Running into another but closely related problem:

    My device has USB, and we're using the radio for our own protocol, that's why I do the clock_init() stuff. I'm also using the temperature sensor to implement errata anomaly 153.

    Problem is, if i run my device without USB attached, I run into this assert:

    https://github.com/nrfconnect/sdk-zephyr/blob/master/drivers/sensor/nrf5/temp_nrf5.c#L65

    Looks to me this is related to the HFCLK. If I disable my clock_init() code, everything as long as I keep USB connected: as soon as I disconnect it, the radio stops receiving (because the USB driver stops the HFCLK, I think?).

    What's happening? It appears the USB and temperature stuff tries to be smart with the HFCLK, disabling it when it's not needed. How do I get my own code (for the radio) to tell this logic that I still need the clock?

    Thanks.

    -Bastiaan

Children
Related