Skip to content

Conversation

@uLipe
Copy link

@uLipe uLipe commented Oct 10, 2025

Hello folks, after years following / and using simpleFoC, I finally found some spare time to contribute to it , I have been hacking ESP32 for doing motor control for a couple of years (and besides that I'm an ex-Espressifer) so I'd like to join the party here and try to help on making ESP32 usage more and more smooth.

Now, my first PR, I started with this small one after finding some crashes when using simpleFoC (and my own FoC lib) with LVGL, when the ESP32 cache is disabled plus the control torque is enabled, because the mcpwm uses a lambda for the on_full callback it is not placed in the IRAM, so if cache is disabled a crash is raised.

This PR address the issue, by removing the lambda expression and proper declaring the MCPWM hanlder at the iRAM, making sure that all processing of the MCPWM iSR happens at the IRAM.

Please let me know if I'm violating any rules of contribution.

@uLipe uLipe changed the base branch from master to dev October 10, 2025 22:53
@uLipe uLipe force-pushed the feature/esp32_adc_iram branch from b83adfa to 59468f4 Compare October 10, 2025 22:54
@uLipe
Copy link
Author

uLipe commented Oct 10, 2025

Just rebased to dev, it seems the master branch is not intended to be the target of PRs.

It will ensure that all the ADC processing triggered by the MCPWM
ISR can run if the ESP32 cache is disabled, preventing the application
to crash.

Signed-off-by: Felipe Neves <[email protected]>
@uLipe uLipe force-pushed the feature/esp32_adc_iram branch from 59468f4 to 3abbbfc Compare October 10, 2025 22:58
@runger1101001
Copy link
Member

Hi @uLipe , thank you so much for this!

Its wonderful to have an ESP32 expert help us with difficult details like this, your contribution is greatly appreciated.

@runger1101001 runger1101001 self-assigned this Oct 11, 2025
@runger1101001 runger1101001 added the bug Something isn't working label Oct 11, 2025
@runger1101001 runger1101001 added this to the 2.3.6_Release milestone Oct 11, 2025
@askuric
Copy link
Member

askuric commented Oct 11, 2025

Thanks for this! This one literally takes an expert to catch and solve 🙃

@uLipe
Copy link
Author

uLipe commented Oct 11, 2025

Thank you @runger1101001 and @askuric , I also have a WIP of adding the adc digi which results on a async and faster sample rate.

For esp32 variant with some tricks it is possible to achieve +1MSPS delivered by DMA.

@runger1101001
Copy link
Member

Thanks a bunch for this! I will merge it now.

@runger1101001 runger1101001 merged commit 7f45dca into simplefoc:dev Oct 14, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants