I am having an issue where i use a GPIO pin to start and stop a timer based on device state and a GPIOE toggle event. The issue i am seeing is that nrf_drv_timer_enable and nrf_drv_timer_disable randomly fail assert and this is causing a hard fault. I need this timer to start and stop so that i can get to lowest connected power states when it is not needed. I cant see a really good reason for this to be happening so any help would be appreciated. Below is the code.
void MilesWakeHandler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
uint8_t fret = EXIT_SUCCESS;
/* Get Pin Value */
uint32_t sense = nrf_gpio_pin_read(UTA_MILES_WAKE);
if(sense == 1)
{
//NRF_LOG_DEBUG("Miles Wake High");
nrf_drv_timer_enable(&m_timer1); //Start Timer
//TODO request timeslot if needed
}
else if (sense == 0)
{
nrf_drv_timer_disable(&m_timer1); //Stop Timer
nrf_drv_timer_clear(&m_timer1); //Clear Timer
//NRF_LOG_DEBUG("Miles Wake Low");
appMiles_ProcessHits();
//TODO stop timeslot if needed
//app_sched_event_put(NULL, 0, (app_sched_event_handler_t)MilesSleep);
}
}