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

app_scheduler and app_timer

I've searched and the majority of answers seem to be years old. 

I have an existing app_timer event handler that works perfectly, blinking LEDs. 

I will soon have another that needs to do some I/O and thus needs not to be running out of an ISR. 

I enabled  APP_SCHEDULER_ENABLED and APP_TIMER_CONFIG_USE_SCHEDULER

I put the following code into my "init"

#define SCHED_QUEUE_SIZE                    16        
#define SCHED_MAX_EVENT_DATA_SIZE           192       

   APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);

    ret = app_timer_init();
    APP_ERROR_CHECK(ret);

and in my "main loop" I put this to make sure that things got called every 50 milliseconds or so.

   do
           {
             /*
             ** read from the input stream.
             */
             serial_ret_code = nrf_serial_read(&serial0_uart, &c, 1, NULL, 50);
             if (NRF_SUCCESS != serial_ret_code)
             {
                app_sched_execute();

                continue;
             }
             else
             {
                app_sched_execute();

                break;
             }

           } while (true);


A couple of things happen.

First, the event handler never gets called (again, this works fine without the app_scheduler) and second I get this in my debugger:


Stopped by vector catch

In the Call Stack window it shows me at address 0x8C4 - somewhere in the softdevice