Skip to content

ESP32 pwm.duty(1023) ends up with 65472 when read as duty_u16() #9445

@JohnMTu

Description

@JohnMTu

I would expect, that pwm.duty(1023) will be 100%, but it's not.
E.g. for 1000Hz signal it falls to 0V each 1 second for 1micro second... hence duty is only 99.9%.
When read using pwm.duty_u16() i got back 65472.

Tested on ESP WROOM-32 with "MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32".

I think correct would be, if duty(arg) impl should delegate to duty_u16 as 65535arg/1023. Similar reading function should read via 1023duty_u16()/65535.

Workaround is to use duty_u16 but that makes code incompatible with esp8266.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions