Description
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
int pwmpins[10] = {15,2,4,16,17,5,18,19,21,22};
void setup() {
Serial.begin(115200);
for (int i=0; i< 10; i++) {
Serial.print("Attaching ");
Serial.println(i);
ledcAttach(pwmpins[i], 5000, 8);
}
}
void loop() {
}
### Debug Message
```plain
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1448
load:0x40078000,len:14844
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Attaching 0
[ 10][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 15 (channel 0, resolution 8)
Attaching 1
[ 21][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 2 (channel 1, resolution 8)
Attaching 2
[ 31][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 4 (channel 2, resolution 8)
Attaching 3
[ 41][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 16 (channel 3, resolution 8)
Attaching 4
[ 51][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 17 (channel 4, resolution 8)
Attaching 5
[ 62][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 5 (channel 5, resolution 8)
Attaching 6
[ 72][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 18 (channel 6, resolution 8)
Attaching 7
[ 82][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 19 (channel 7, resolution 8)
Attaching 8
E (91) ledc: ledc_get_duty(736): channel argument is invalid
[ 93][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 21 (channel 8, resolution 8)
Attaching 9
E (107) ledc: ledc_get_duty(736): channel argument is invalid
[ 109][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 22 (channel 9, resolution 8)
Allocated Bytes : 22972 B ( 22.4 KB)
Minimum Free Bytes: 351708 B ( 343.5 KB)
Largest Free Block: 118772 B ( 116.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 4194304 B (4 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Bus Mode : QIO
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 1280.0 KB, type: APP, subtype: OTA_0
app1 : addr: 0x00150000, size: 1280.0 KB, type: APP, subtype: OTA_1
spiffs : addr: 0x00290000, size: 1408.0 KB, type: DATA, subtype: SPIFFS
coredump : addr: 0x003F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : May 14 2024 20:46:54
Compile Host OS : windows
ESP-IDF Version : v5.1.4-51-g442a798083-dirty
Arduino Version : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : ESP32_WROOM_DA
Arduino Variant : esp32da
Arduino FQBN : esp32:esp32:esp32da:PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=debug,EraseFlash=none
============ Before Setup End ============
Attaching 0
[ 502][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 15 (channel 0, resolution 8)
Attaching 1
[ 512][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 2 (channel 1, resolution 8)
Attaching 2
[ 523][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 4 (channel 2, resolution 8)
Attaching 3
[ 533][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 16 (channel 3, resolution 8)
Attaching 4
[ 543][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 17 (channel 4, resolution 8)
Attaching 5
[ 554][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 5 (channel 5, resolution 8)
Attaching 6
[ 564][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 18 (channel 6, resolution 8)
Attaching 7
[ 574][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 19 (channel 7, resolution 8)
Attaching 8
E (583) ledc: ledc_get_duty(736): channel argument is invalid
[ 585][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 21 (channel 8, resolution 8)
Attaching 9
E (599) ledc: ledc_get_duty(736): channel argument is invalid
[ 600][I][esp32-hal-ledc.c:117] ledcAttachChannel(): LEDC attached to pin 22 (channel 9, resolution 8)
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 387244 B ( 378.2 KB)
Free Bytes : 354692 B ( 346.4 KB)
Allocated Bytes : 24988 B ( 24.4 KB)
Minimum Free Bytes: 349056 B ( 340.9 KB)
Largest Free Block: 118772 B ( 116.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
GPIO : BUS_TYPE[bus/unit][chan]
--------------------------------------
1 : UART_TX[0]
2 : LEDC[0][1]
3 : UART_RX[0]
4 : LEDC[0][2]
5 : LEDC[0][5]
15 : LEDC[0][0]
16 : LEDC[0][3]
17 : LEDC[0][4]
18 : LEDC[0][6]
19 : LEDC[0][7]
21 : LEDC[1][8]
22 : LEDC[1][9]
============ After Setup End =============
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Type
Projects
Status