Skip to content

[LedC] ledc_handle.used_channels is never initialized #9213

Closed
@TD-er

Description

@TD-er

Board

ESP32 (classic)

Device Description

Hardware Configuration

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Windows 11

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

ledcAttach uses ledc_handle.used_channels to pick an unused channel.
However this is never initialized to 0.

This can lead to nearly impossible to reproduce issues where per build (or run?) the number of usable ledC channels can differ.

Suggested change:

bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution)
{
    if (!fade_initialized) {
        ledc_handle.used_channels = 0;
    }
...

Slightly related issue: #9212

Sketch

-

Debug Message

-

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

Labels

Status: Needs investigationWe need to do some research before taking next steps on this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions