Skip to content

Zero out ledc timer config in newChannel #3680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025

Conversation

nfreya
Copy link

@nfreya nfreya commented May 12, 2025

ledc.newChannel was broken for me on dev-esp32:

> pwm = ledc.newChannel({
>>   gpio = 4,
>>   bits = ledc.TIMER_10_BIT,
>>   mode = ledc.HIGH_SPEED,
>>   timer = ledc.TIMER_0,
>>   channel = ledc.CHANNEL_0,
>>   frequency = 1000,
>>   duty = 512,
>> })
 (421647) ledc: ledc_timer_del(589): LEDC is not initialized
Lua error: 	stdin:1: timer configuration failed code 259
stack traceback:
	[C]: in function 'ledc.newChannel'
	stdin:1: in main chunk
	[C]: in ?
	[C]: in ?

espressif/esp-idf#15806 indicates this is due to a (presumably) new field, zeroing out the struct fixes it.

@jmattsson
Copy link
Member

Hi and thank you for reporting and the PR! 😊

Yeah it looks like there's a new deconfigure field that's been added. I deliberated on whether it would be better to explicitly add that, or go with the zero-initialisation approach. I like the clarity of explicitly listing what's being set, but on the other hand, zero-init is good, clean practice 👍. Plus it's hopefully more future proof in case new fields are added again.

@jmattsson
Copy link
Member

Housekeeping note: I can't get the checks to build as it picks up the config from the PR branch, not the target branch; I've manually applied the PR on top of latest dev-esp32 on a personal branch, and had CI run that. Everything's happy there.

@jmattsson jmattsson merged commit 12bf48c into nodemcu:dev-esp32 May 13, 2025
0 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants