This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to sample data with app_timer in IRQ but process outside interrupt?

I want to process queued sensor data collected at a fixed interval (every 100ms) via TWI in the background/main loop. In the example ble_app_hrs, timer expiration callbacks run directly in the IRQ.

APP_TIMER_INIT(APP_TIMER_PRESCALER,
               APP_TIMER_MAX_TIMERS,
               APP_TIMER_OP_QUEUE_SIZE,
               false);

err_code = app_timer_create(&device.sample_data_timer_id,
                              APP_TIMER_MODE_REPEATED,
                              OnSampleDataTimerExpired);
APP_ERROR_CHECK(err_code);

That fourth, false parameter of APP_TIMER_INIT is supposed to indicate whether the scheduler is desired, otherwise the callback runs in the IRQ. I need this enabled if I want the callback to run in the main/background loop (NOT THE IRQ) but am unsure how to use the scheduler and whether I can run one timer callback in IRQ and another in background?

Related