Page 1 of 1

Interrupt can not interrupt main sometimes

Posted: Thu Jul 20, 2023 7:39 am
by Gabriel_Simmann
I am trying to realize an interrupt that gets executed every 5ms, no matter what. For that purpose i am using the esp_timer library in the ESP_TIMER_ISR Mode and the Interrupt priority is set to 3. Therefore the configuration and initialization of the timer looks the following:

  1. const esp_timer_create_args_t Timer_args = {
  2.       .callback = &timer_callback,
  3.       .name = "Timer",
  4.       .dispatch_method = ESP_TIMER_ISR,
  5.       .skip_unhandled_events = true};
  6.     esp_timer_handle_t timer_handler;
  7.     ESP_ERROR_CHECK(esp_timer_create(&Timer_args, &timer_handler));
  8.     ESP_ERROR_CHECK(esp_timer_start_periodic(timer_handler, 5000));      // 5ms

Using the visualization Software Impulse I can see that in general the Interrupt works on the specified 5ms. However, sometimes the main gets more than 20ms of continuous runtime and the interrupt doesn't get executed within this time. This is shown in the picture.

Can someone imagine what happens here and how to solve this?
Thanks!
Gabriel

Re: Interrupt can not interrupt main sometimes

Posted: Thu Jul 20, 2023 10:04 am
by ESP_Sprite
If any, if you need to get the timer 'no matter what', I'd suggest switching to a hardware timer, as esp_timer callbacks can 'get stuck' behind other bits of software that also use that callback. Aside from that, I have no clue; that certainly isn't behaviour I've ever seen.