Arduino-FOC-drivers
Arduino-FOC-drivers copied to clipboard
Type casting bug in STM32HWEncoder fixed
Hello,
Found this bug while trying to get this code to work:
STM32HWEncoder e(1000, PA0, PA1);
This is the related part of my platformio.ini config:
platform = ststm32
board = nucleo_g474re
framework = arduino
In this case, PA0 is 192 and PA1 is 193. Currently, when you pass pins to the STM32HWEncoder constructor, they're trimmed down to the int8_t, which is incorrect. In my case 192 and 193 do not actually fit into the int8_t, and trimming then leads to incorrect operation of the digitalPinToPinName function. So I just changed int8_t to int
Hey, thanks a lot for this contribution! I’ll look more closely tonight when I’m not on my phone but it looks like a good find…