Arduino-FOC-drivers icon indicating copy to clipboard operation
Arduino-FOC-drivers copied to clipboard

Type casting bug in STM32HWEncoder fixed

Open AntonEvmenenko opened this issue 1 year ago • 1 comments

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

AntonEvmenenko avatar Dec 16 '24 02:12 AntonEvmenenko

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…

runger1101001 avatar Dec 16 '24 11:12 runger1101001