Hello everyone,
I am stuck at a problem that I cannot resolve myself but I see that other people in the forum don't experience such a behaviour of their nrf52832s.
I want to have a 1 second timebase with RTC2 using the Nordic's SDK version: nRF5_SDK_17.0.2_d674dde.
I can get an interrupt at each RTC tick, but I cannot get interrupt on COMPARE0 event. Here is my code:
const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(2);
void rtc_handler(nrf_drv_rtc_int_type_t int_type){
if (int_type == NRF_DRV_RTC_INT_COMPARE0)
{
nrf_gpio_pin_toggle(22); //This never gets called
}
else if (int_type == NRF_DRV_RTC_INT_TICK){
nrf_gpio_pin_toggle(23); //This gets called once every 122 ms
}
}
void lfclk_config(void){
ret_code_t err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
nrf_drv_clock_lfclk_request(NULL);
}
void user_rtc_init(void){
uint32_t err_code;
lfclk_config();
//Initialize RTC instance
nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
config.prescaler = 4095;
err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);
APP_ERROR_CHECK(err_code);
//Enable tick event & interrupt
nrf_drv_rtc_tick_enable(&rtc,true);
//Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
err_code = nrf_drv_rtc_cc_set(&rtc, 0, 1 * 8, true);
APP_ERROR_CHECK(err_code);
//Power on RTC instance
nrf_drv_rtc_enable(&rtc);
}
Any help is appreciated! Thanks in advance!
L. B.