"ledc_get_duty(): channel argument is invalid" error for more than 8 PWM channels on ESP32 with ledcAttach #9633
Labels
Area: Peripherals API
Relates to peripheral's APIs.
Status: Review needed
Issue or PR is awaiting review
Milestone
Board
ESP32 WROOM DA
Device Description
Commonly available ESP32 third party DevKit
Hardware Configuration
None
Version
latest development Release Candidate (RC-X)
IDE Name
Arduino IDE
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
yes
Upload speed
115200
Description
Attempting to configure more than 8 PWM channels using ledcAttach() results in the error "ledc: ledc_get_duty(736): channel argument is invalid" for all channels greater than 8.
I believe this might be due to the fact that in the ledcAttachChannel() function, the "channel" parameter is passed directly into ledc_get_duty() whereas in other calls to ledc_get_duty() the required parameter is "channel % 8".
The call fails the check in ledc_get_duty() against LEDC_CHANNEL_MAX which is part of the enum ledc_channel_t defined in components/hal/include/hal/ledc_types.h in the ESPIDF and presumably ends up with the value 8 (given there are 8 previous entries in the enum definition).
Note: I don't believe this stops the channel from being configured, as the code follows through regardless - it is just additional erroneous error messages, but I don't know the impact of "duty" being invalid when next passed into ledc_channel_config() in the ledcAttachChannel() function.
Sketch
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: