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

esb with softdevice - clock initialization failes (urgent)

Hi,

For my application I was using ESB without softdevice and just recently I wanted to add dfu so I had to add softdevice as well.

After adding softdevice I found out that my piece of code that is starting lfclk and hfclk is now failing.

void clocks_start( void )
{
    nrfx_clock_enable();

    nrfx_clock_hfclk_start();
    while (!nrfx_clock_hfclk_is_running())
                 ;

    nrfx_clock_lfclk_start();
    while (!nrfx_clock_lfclk_is_running())
                 ;
}

First symptom is that hfclk_is_running function never returns true. After commenting out that while() loop when application reach lfclk_start it simply stops execution - I think it gets stuck somewhere in softdevice.

I already tried to use softdevice api for requesting clocks and added softdevice enabling, but then I got some other weird errors - probably softdevice was clashing with ESB, but didn't invetigate it much further. Then I read somewhere that if application does not use softdevice - like in my case - I can just ignore it. But then the question is why this clock function is failing?

Hoping for a quick answer !

Michał

  • I removed that clocks_start() and only use nrfx_clock_hfclk_start() directly without the while and that works for me.

  • Hi Michał

    When using the SoftDevice you shouldn't access the clock peripheral directly, which is what the nrfx_clock driver is doing. 

    Starting LF clock is not necessary, since the SoftDevice starts this automatically, but if you want to change the LF clock source you have to do this as a part of the SoftDevice initialization. 

    Starting the external HF clock can be done by calling sd_clock_hfclk_request(), after you have enabled the SoftDevice. 

    Best regards
    Torbjørn 

  • Hi Torbjørn,

    I am a bit confused: I don't want to use softdevice in my main application so I am not enabling softdevice at all. Shouldn't in that case  "standard" nrfx_clock api be fine as suggested by Nguyen? I tried that but it doesn't work for me.

    I tried to add softdevice to my application by using softdevice handler module, because I also need flash access. Then I am only requesting hfclk and that works fine. Unfortunately when initializing ESB protocol, exactly when accesing first RADIO register (which is TXPOWER but I don't this matters) application hangs. Is using ESB with softdevice enabled a valid use case? I guess all RADIO registers should be accessed via SD api when it is enabled but there no such ESB implementation which uses SD api.

    Best regards

  • Hi Michał

    My apologies, it is true that accessing the RADIO peripheral directly when the SoftDevice is enabled is not possible. I should have realized this when reading your original question. 

    As you can read here many peripherals are either blocked or restricted when the SoftDevice is enabled. Blocked peripherals can not be accessed at all, while restricted peripherals can be accessed only if you use the SoftDevice API's. 

    The only way to use the ESB library while the SoftDevice is enabled is to run all ESB activity inside a SoftDevice timeslot, which adds quite a lot of complexity to the application. 

    Is there a way you can modify your application to not enable the SoftDevice when running ESB?

    Best regards
    Torbjørn

  • Hi Torbjørn,

    Yes, I can not enable the SoftDevice in my main application. This is actually what I am trying to do.

    But as mentioned in first post - if I just put softdevice in flash and not enable it, the application crashes on clock request. How should I request hfclk when softdevice is present in flash but not enabled in software?

    Thanks

Related