Hi,
we have an odd issue on ~ 50% of our in-house boards here. We're using the internal RC as a low frequency clock, and then enable one RTC. No softdevice or anything. In main(), after the classic Reset_Handler (SDK 17.0.2), the first thing we do is:
// start high frequency clock
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
__DSB();
// wait for selected low-frequency oscillator to start up
enum {LFCLK_OSC_RC = 0, LFCLK_OSC_XTAL = 1, LFCLK_OSC_SYNTH = 2} osc = LFCLK_OSC_RC;
NRF_CLOCK->LFCLKSRC = osc;
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
__DSB();
// setup and reset rtc
NRF_RTC2->TASKS_STOP = 1;
NRF_RTC2->PRESCALER = 1;
NRF_RTC2->TASKS_CLEAR = 1;
while (NRF_RTC2->COUNTER != 0);
NRF_RTC2->TASKS_START = 1;
//while (NRF_RTC2->COUNTER == 0); // HANG 4ever :(
__DSB();
On the second last line, while (NRF_RTC2->COUNTER == 0);we hang indefinitely on some boards. How can this be?