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ł

  • Hi Michał

    Sorry, I didn't realize that the issue happens even when the SoftDevice is disabled. I will have to check internally if this is a known issue. 

    In the mean time, could you try to start the clocks by accessing the hardware registers directly and see if that works?

    To start the LF clock just run the following code: 

    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

    You can also do something similar for the HF clock, just replace LF with HF in the code snippet above. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    So I tried to access NRF_CLOCK registers directly as you suggested. I was observing CLOCK registers in SES ide and I can see that both clocks has status "running" so this seems to be fine. 

    Still there seems to be a problem when accessing i2c or spi - device bricks then. As those peripherals require hfclk I believe there is still something wrong with hfclk initialization.

    I noticed while debugging that code goes to 0x00000A60 addres which I believe is softdevice? Does it make sense ? I am using s140 sd 7.0.1 for nrf52840

    Thanks

  • can you try to add following code at the beginning of your application

    sd_softdevice_vector_table_base_set(CODE_START);
    If you are jumping to the application from the bootloader, softdevice might not forward interrupts to the application.
  • Hi Krzysztof :)

    thank you for the input but that doesn't fix the issue. I am actually testing this without btl right now, just sd + application (and I get the same behaviour in both cases) so I wasn't expecting this to help in my case.

    Any other suggestions?

    Thanks,
    Michał B

  • Hi Michał 

    A colleague of mine pointed out that when you have a SoftDevice added you actually have to reserve 8 bytes of RAM for the SoftDevice, even if you don't enable it. 

    This is mentioned in the documentation, here

    Could you try changing the RAM start address from 0x20000000 to 0x20000008 and see if it solves the issue?

    Best regards
    Torbjørn

Related