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

AnalogWrite creates a PWM when value is 255 #388

Open
jpcornil-git opened this issue Oct 25, 2024 · 1 comment
Open

AnalogWrite creates a PWM when value is 255 #388

jpcornil-git opened this issue Oct 25, 2024 · 1 comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@jpcornil-git
Copy link

On legacy arduino platforms, when analogWrite value is 255, you get a DC/HIGH output (aliased to digitalWrite HIGH), see:

https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring_analog.c#L110

While on UNO R4/renesas platform, 255 is converted to 255/256 and you get a PWM signal, see:
https://github.com/arduino/ArduinoCore-renesas/blob/main/cores/arduino/analog.cpp#L819

To match behavior, value should either be normalized to 255 ((1 << _writeResolution) - 1) or aliased to a digitalWrite as well

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Oct 25, 2024
@jpcornil-git
Copy link
Author

Workaround for this one is to use digitalWrite(pin, HIGH) (following a pinMode(pin, OUTPUT) to address #58) but it is not very clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants