Skip to content

[BUG] ESP32 MCPWM remove unnecessary interrupt yields #562

Description

@HamzaYslmn

Describe the bug

In SimpleFOC 2.4.0, the ESP32 MCPWM current-sense callbacks return true in three places.

In ESP-IDF, the callback return value indicates whether a higher-priority task was woken and whether a context switch may be required after the ISR.

These callbacks only sample ADC data and update internal buffers; they do not appear to wake any FreeRTOS task. Therefore these returns should be false.

Proposed change

diff --git a/src/current_sense/hardware_specific/esp32/esp32_mcpwm_mcu.cpp b/src/current_sense/hardware_specific/esp32/esp32_mcpwm_mcu.cpp
--- a/src/current_sense/hardware_specific/esp32/esp32_mcpwm_mcu.cpp
+++ b/src/current_sense/hardware_specific/esp32/esp32_mcpwm_mcu.cpp
@@ -112,7 +112,7 @@
 #ifdef SIMPLEFOC_ESP32_USE_ADC_DEBUG
   gpio_set_level((gpio_num_t)debug_pin, 0);
 #endif
-  return true;
+  return false;
 }
 
@@ -120,7 +120,7 @@
   if(edata->direction != MCPWM_TIMER_DIRECTION_UP){
-    return true;
+    return false;
   }
 
@@ -140,7 +140,7 @@
 #ifdef SIMPLEFOC_ESP32_USE_ADC_DEBUG
   gpio_set_level((gpio_num_t)debug_pin, 0);
 #endif
-  return true;
+  return false;
 }

This should not change ADC sampling behavior; it only avoids reporting an unnecessary ISR task wakeup/yield.

Hardware

  • ESP32-S3
  • DRV8353
  • 3-phase BLDC
  • Sensorless FOC
  • Low-side current sensing
  • PlatformIO
  • SimpleFOC 2.4.0

Sources

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions