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

nRF52840 HFXO and HFCLKSTARTED event

Hello everyone,

I am having some trouble starting the HFXO crystal manually before using the RADIO to send raw advertisements: the HFCLKSTARTED event never raises. The code used to start the HFXO is:

NRF_CLOCK->TASKS_HFCLKSTART = 1;

while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;

But the execution stalls in the while loop because the event HFCLKSTARTED is never raised. After reading a few posts with people who had similar issues, here are the things I tried so far:

- Tried to remove the while loop to see if the radio would work: it does not

- Changed crystal and its capacitors. The crystal used is 8Y-32.000MAAV-T and the capacitors are 12pF NP0 2%. We followed the Nordic layout guidelines.

- Probed the crystal pins: the scope gives correct waveforms so it is defenetly not a soldering problem of the nRF52840.

- Ensured that the 1uF capacitor at DEC4 pin is soldered properly

- Tried our code on a different board: the code works flawlessly (with the while loop)

- Tried a Nordic example (ble_app_beacon for instance) with SoftDevice: the advertisements are sent correctly.

The last point is what baffles me the most. According to this post, it is mentionned that the Softdevice will always start the HFXO before a RADIO event, which totally makes sense since it is mandatory for the RADIO to work. However, if the softdevice is actually able to start the HFXO to send advertisements, why it doesn't work when using our code (without softdevice)?

Our code is not the cause of the problem because it was tested successfully on a different board. I am tempted to say that the board is not the problem also because it works when using a Nordic example.

I must be missing something. Any help would be greatly appreciated.

Parents
  • Hi

    In our examples, the HFXO is started manually by writing the function like this. Please give it a go like this:

    /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }

    You could also try debugging, and stepping through the code to see what happens in TASKS_HFCLKSTART.

    - Tried our code on a different board: the code works flawlessly (with the while loop)

     What board were you initially testing on? Was this a custom board? And is the different board a dev. kit or another custom one? I'd like to take a look at your schematics, just to make sure there are no hardware issues we're missing here. If you don't want to share the schematics publicly, just say the word, and I'll set this case to Private mode so that no one except yourself and Nordic engineers will be able to see this case.

    Best regards,

    Simon

Reply
  • Hi

    In our examples, the HFXO is started manually by writing the function like this. Please give it a go like this:

    /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }

    You could also try debugging, and stepping through the code to see what happens in TASKS_HFCLKSTART.

    - Tried our code on a different board: the code works flawlessly (with the while loop)

     What board were you initially testing on? Was this a custom board? And is the different board a dev. kit or another custom one? I'd like to take a look at your schematics, just to make sure there are no hardware issues we're missing here. If you don't want to share the schematics publicly, just say the word, and I'll set this case to Private mode so that no one except yourself and Nordic engineers will be able to see this case.

    Best regards,

    Simon

Children
  • Sorry I forgot to give that information. The boards I am referring to are indeed custom boards. The two boards mentionned in my original posts are the same design (let's call them board A and B). Our code that does not use the softdevice works on board A but not on board B. However, if I use an example from nordic that uses softdevice (ble_app_beacon for instance) and flash it on board B, the advertisement works. That tells me it is probably not an hardware issue (unless I am missing something) because the nordic example is actually able to start HFXO to perform the advertisements. Both boards are populated with exact same components and i've verified the soldering and the values of the critical components (C3, Y1, C4 and C5 for instance).

    I don't mind to post the schematic because it is pretty much the reference design provided by Nordic, here it is:

    The source code you provided in your answer is pretty much the same thing we are using in ours. What do you mean exactly by "stepping through the code to see what happens in TASKS_HFCLKSTART"? The code starting HFCLK is pretty much writing to a register and I can't really step deeper into that. Looking at the CLOCK register values while stuck in the while loop does not reveal much as well: HFCLK is running on RC and HFCLKSTART task has been triggered.

Related