Open dekutree64 opened 1 month ago
ooh, thanks for spotting this! Definitely a bug :-(
I think we will switch to my new "HAL only" PWM driver for all the STM32 MCUs (including Arduino Portenta) in our next release.
In the "HAL only" branch, I think the error is already fixed: https://github.com/runger1101001/Arduino-FOC/blob/4d8fa4a6c15c3bce15d536235e0516851359fb34/src/drivers/hardware_specific/stm32/stm32_searchtimers.cpp#L19
This bit of code in stm32_mcu.cpp reads off the end of the pinTimers array if there is more than one motor. It doesn't always crash, which made it very difficult to narrow down where the problem was.
I think this is the proper fix for it, but hopefully whoever wrote the original can verify that the logic is correct.