Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type casting bug in STM32HWEncoder fixed #52

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

AntonEvmenenko
Copy link

@AntonEvmenenko AntonEvmenenko commented Dec 16, 2024

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

@runger1101001
Copy link
Member

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…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants