I'm trying to use a low accuracy GPIOTE event to start RTC1. The following code works as expected when using hi accuracy mode but will constantly trigger in_pin_handler() using low accuracy mode. If I remove nrf_drv_rtc_enable() from in_pin_handler() it functions as expected.
Is there something I'm missing either in the RTC or GPIO config?
static void gpio_init(void) {
ret_code_t err_code;
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
in_config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(GPIO_INPIN, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(GPIO_INPIN, true);
}
static void rtc1_config(void) {
uint32_t err_code;
nrf_drv_rtc_config_t config = { \
.prescaler = 1000, \
.interrupt_priority = RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \
.reliable = RTC_DEFAULT_CONFIG_RELIABLE, \
.tick_latency = RTC_US_TO_TICKS(NRF_MAXIMUM_LATENCY_US, RTC_DEFAULT_CONFIG_FREQUENCY), \
};
err_code = nrf_drv_rtc_init(&rtc1, &config, rtc1_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_rtc_tick_enable(&rtc1,false);
nrf_drv_rtc_counter_clear(&rtc1);
err_code = nrf_drv_rtc_cc_set(&rtc1,0,1,true);
APP_ERROR_CHECK(err_code);
}
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
nrf_drv_gpiote_in_event_disable(GPIO_INPIN);
nrf_drv_rtc_enable(&rtc1);
}