In timeout handler, I need to reload a new value, could this be fail since the timer stop is delayed by SWI0.
In timeout handler, I need to reload a new value, could this be fail since the timer stop is delayed by SWI0.
Yes you can. Verified on SDK8.1 S110 I have tried this below code on S110 with connection established to master control panel
static app_timer_id_t m_test_timer_id;
#define GPIO_NUM 6
#define TEST_INTERVAL1 APP_TIMER_TICKS(5, APP_TIMER_PRESCALER)
#define TEST_INTERVAL2 APP_TIMER_TICKS(10, APP_TIMER_PRESCALER)
static void test_timeout_handler(void * p_context)
{
static bool is_true = true;
nrf_gpio_pin_toggle(GPIO_NUM);
uint32_t err_code;
if(is_true)
{
err_code = app_timer_stop(m_test_timer_id);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_test_timer_id, TEST_INTERVAL1, NULL);
APP_ERROR_CHECK(err_code);
}
else
{
err_code = app_timer_stop(m_test_timer_id);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_test_timer_id, TEST_INTERVAL2, NULL);
APP_ERROR_CHECK(err_code);
}
is_true = !is_true;
}
and I got the timer value changed correctly (with 0.04ms error because of handler execution time).Attaching is logic analyzer output for togle GPIO pin inside the handler
cgha, please update this thread, if this answer helped you then please click the ✓ to the left of the answer so that others can come and look here.