Interrupt can not interrupt main sometimes

Gabriel_Simmann
Posts: 4
Joined: Thu Jul 20, 2023 7:16 am

Interrupt can not interrupt main sometimes

Postby Gabriel_Simmann » Thu Jul 20, 2023 7:39 am

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
Attachments
ImpulseVisualization.png
ImpulseVisualization.png (31.8 KiB) Viewed 519 times

ESP_Sprite
Posts: 9619
Joined: Thu Nov 26, 2015 4:08 am

Re: Interrupt can not interrupt main sometimes

Postby ESP_Sprite » Thu Jul 20, 2023 10:04 am

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.

Who is online

Users browsing this forum: Google Adsense [Bot] and 64 guests