Hello,
SDK 15.3.0
nRF52840-DK
s140
IDE:SES
I am running into an issue using the app timer and LPComp together. The error is NRF_FAULT_ID_SDK_ERROR, With RTT output ERROR 4 [NRF_ERROR_NO_MEM] @ line 10 in the code below
static void lpcomp_event_handler(nrf_lpcomp_event_t event) { ret_code_t err_code; if (event == NRF_LPCOMP_EVENT_UP) { bsp_board_led_invert(BSP_BOARD_LED_0); // just change state of first LED voltage_rising_detected++; voltage_rising_total++; err_code = app_timer_stop(m_timer_id); APP_ERROR_CHECK(err_code); err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(50), NULL); APP_ERROR_CHECK(err_code); } }
The App timer does not have a reset function, so I need to stop and start the timer every time I would like to restart it. I have a signal I need to count that will run every 104ms, with 50ms of rising edges to count at 88Khz and a down time of 54ms. I intend to use the LPComp to count the rising edges of the 88kHz signal then on the last count of the signal the timer will start (and not be restarted by a new rising edge) and when the timer handler is called I will reset the count and calculate the value from that count. I essentially need to be able to detect when there are no more rising edges to know when to reset the count for the next cycle.
What might be causing the NRF_FAULT_ID_SDK_ERROR and ERROR 4 [NRF_ERROR_NO_MEM]?
What is the execution time of app_timer_stop, and app_timer_start? (I assume the execution is on the long side to be run in an interrupt, but an alternative method is not clear to me)