This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

32khz synth clock

Hi there, I'm having some truble to understand how to set a synthetice 32khz clock from the 16Mhz external crystal. Right now I have the next code working fine:

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Synth << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { /* Do nothing */ }

But I'm a litle confuce. Somewhere I read thath it is possible to synthetice the 32khz with the internal 16Mhz clock. So, I suposse that it's necesary to start the 16 external clock first? Like this:

NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { /* Do nothing */ }

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Synth << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { /* Do nothing */ }

So, the question is, which is the right way to start the synth clock, and how to know if is running with the external clock. Thanks!

  • Hi Daniel

    The last alternative is the correct one.

    Synthesizing the 32k clock from the 16MHz clock only makes sense if the external 16MHz crystal is running, so you should start that first and then enable the 32k clock.

    Please keep in mind that the current consumption is quite high in this mode, and it is not a very good option if you are looking for long battery life.

    Best regards
    Torbjørn

Related