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

Waiting for the Low Frequency Clock to be started

nRF52840

SDK15.3

My question is regarding the low frequency clock.I am initializing the low frequency clock as follows:


NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal;
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;

while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
}

When TASKS_LFCLKSTART is initiated in line 3, it will generate the EVENTS_LFCLKSTARTED event.

1) My question is do I need to explicitly wait for the EVENTS_LFCLKSTARTED event to be generated before I proceed or can I remove the while loop. I do not want to have a while loop which could potentially turn into an infinite while loop if the EVENTS_LFCLKSTARTED event is never triggered. Currently, I have removed the while loop.

2) How much time does it take from when the LFCLKSTART task is triggered to when the LFCLKSTARTED event is generated? Does this time vary or is it consistent? Is this event generated in the next instruction or can it take even longer?

3) What other ways can I make sure the clock is started, but not have that potentially infinite loop?

Thanks.

Parents Reply Children
Related