Skip to content

AnalogWrite creates a PWM when value is 255 #388

Open
@jpcornil-git

Description

@jpcornil-git

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions