Hi,
Currently I'm using internal RC osciallator for LFCLK on the system that run on CMSIS-RTX and Softdevice S110 and it doesn't have external 32K crystal.
The RTC os timer implemented on RTX OS Doesn't look so accurate.
Initializing RTX os tick with RC LFCLKSRC like codes below, and tick interval is 1ms as recommended.
When setting a timer, it seems that it runs ~20% faster than real 1sec. It calls handler around 700~800 ms.
If I change the tick interval to 10ms, it runs about 10% slower than real clock.
Softdevice is initialized with NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION.
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION, NULL); /* Use internal oscillator */
It seems that BLE function works quite accurate.
Am I missing some configuration? or Any additional configuration for RTX is necessary?
int os_tick_init (void) { NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos); /* Use Internal RC oscillator / NRF_CLOCK->CTIV = ((0x10 << CLOCK_CTIV_CTIV_Pos) & CLOCK_CTIV_CTIV_Msk); / calibration timer 4000ms */ NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; NRF_CLOCK->TASKS_LFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
// Do nothing.
}
NRF_RTC1->PRESCALER = OS_TRV;
NRF_RTC1->INTENSET = RTC_INTENSET_TICK_Msk;
NRF_RTC1->TASKS_START = 1;
return (RTC1_IRQn);
}