I want to add a global variable that would increase every time the timer handler is called. I can't get it to work with static, volatile, or even pass on as variable. the "counter" below just stay at 0. I'm wondering if I have to store then load this from flash storage in the timeout_handler function. Please help.
volatile uint32_t counter = 0;
static void sensor_level_meas_timeout_handler(void * p_context)
{
.....
counter=counter+1;
display_counter(counter); //this function basically send the counter value via beacon ad's minor. I know this work as I can display a constant value.
....
}
int main(void)
{
.....
err_code = app_timer_create(&m_sensor_timer_id, APP_TIMER_MODE_REPEATED, sensor_level_meas_timeout_handler);
err_code = app_timer_start(m_sensor_timer_id, SENSOR_LEVEL_MEAS_INTERVAL, NULL);
...
}