driver: adc_esp32: protect the adc reading against core migration.#495
driver: adc_esp32: protect the adc reading against core migration.#495askuric merged 1 commit intosimplefoc:devfrom
Conversation
On dual core esp32 the either the interrupts and the FoC task may migrate to a different core, making the ADC registers subject to corruption if the other core tries to manage the ADC while current core owns it, so add a spinlock around the ADC to avoid that. On single core devices this is call is a NOOP. Signed-off-by: Felipe Neves <[email protected]>
|
@askuric @runger1101001 PTAL :) |
|
Hey, once again thank you! AFAIK, in Arduino there is the ARDUINO_RUNNING_CORE and that one should keep the loop() function? How about the interrupts, that has been a question I wanted to look into… generally speaking I think users would expect the interrupts to run on the same core as the loop, so prevent concurrency issues? Some users, especially on single core systems would like to run their motor loops exclusively, disabling other tasks - there’s a couple of threads on the forum recently related to this on C3 and C6 MCUs. So I guess I have the question whether we can ensure that motor task and its interrupts don’t migrate and thereby perhaps also avoid the need for locking? |
|
Hey @runger1101001, the idea of this change is to cover custom cases where ESP32 users don't want to pin the FoC loop into the arduino loop or a particular task, this is particular advantageous on ESP32 with dual core support because it increases the scheduler throughput but at cost of the loop or or any concurrent access of the ADC to happen at different cores. This will just translate to an In respect of your question the only way to guarantee that is to also control the interrupt allocation using the |
|
@runger1101001 just a friendly reminder, will we follow with this PR? No pressure, just following-up. Thank you 😃 |
|
@runger1101001 @askuric just a friendly ping. |
|
Hello @runger1101001 @askuric , just doing another friendly follow-up |
1 similar comment
|
Hello @runger1101001 @askuric , just doing another friendly follow-up |
|
Hey @uLipe, |
On dual core esp32 the either the interrupts and the FoC task may migrate to a different core, making the ADC registers subject to corruption if the other core tries to manage the ADC while current core owns it, so add a spinlock around the ADC to avoid that. On single core devices this is call is a NOOP.