-
Notifications
You must be signed in to change notification settings - Fork 975
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
analogWrite() on low numbered digital pins not working #1
Comments
Hi madman,
Don't forget to extend the enum in variant .h to match the digital pin number:
I have tried to find a better solution to not duplicate it but I didn't find it. |
Analog pins are supposed to be referred to as Ax always from what I know? Where does it say that you can drop the A prefix? |
IMHO its not ever going to be possible to strictly replicate the whole Arduino API, which was developed for 8 bit AVR hardware, to completely different MCU's, like the STM32. In terms of this restriction, AFIK it is mainly because the method that the Core uses to map Arduino API style pin numbers, to the physical Port & Pin. On the F1 core, an alternative approach was evolved, e.g. fpistm/Arduino_Core_STM32F1@8fba3e8 and But I'm not sure if this approach would resolve your issue |
I will correct it like that: 0 will be D0 for analog api and not A0. |
An alternative would have been to always treat A0 as analog, D0 as digital, and without prefix depending on the API being used. My problem was that using D0 somehow aliased into the same number as 0, and thus ending up being analog. |
For analog api 0 is now D0. Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Fix BLUEPILL_F103C6 definition
I have a Nucleo64 L476RG, and i noticed i cannot do PWM using the analogWrite() function when using D2, while i can with D8. D2 being wired to PA10 should have this capability.
I found this in variant.h which looks suspicious:
// Convert an analog pin number Axx to a PinName Pxy
#define analogToPinName(p) ((p < NUM_ANALOG_INPUTS) ? digitalToPinName(p+A0) : digitalToPinName(p))
This function is then used by analogWrite()
The text was updated successfully, but these errors were encountered: