← index #6555Issue #5965
Related · high · value 0.428
QUERY · ISSUE

ESP8266: option to use NMI for PWM

openby Winkelkatzeopened 2020-10-17updated 2024-05-18
port-esp8266

Hi,
I detected some instabilities in the PWM output of the ESP8266 when the controller is handling WiFi traffic. Of course, that's no surprise, since the PWM is done in software. However, I figured out, that the issues can be mostly mitigated by using the NMI interrupt for the PWM. I guess, that's not something we want to be default, but as an option it would be nice.

The issue can be replicated by setting up a PWM output with an LED at a duty cycle of 50%. Then a simple script is needed, that echoes data on a TCP socket. When lots of data is thrown at the ESP, the LED will begin to flicker visibly.
The issue easiest to reproduce with heavy network traffic, but it will also occur more sporadically in lighter traffic environments.

Further, I'd suggest to replace the gpio_output_set calls in the interrupt handler with direct writes to the W1TC / W1TC registers to reduce time wasted in the interrupt.

CANDIDATE · ISSUE

ESP8266: PWM glitches on a channel when setting duty on another one (ESP8266)

closedby EddieParisopened 2020-04-24updated 2020-06-10
port-esp8266

When having a PWM channel set on and changing the PWM duty on another channel, the first channel experiences glitches.

This is very visible when driving leds.

This is due to software PWM handling, the toggle between the current timing scheme and the prepared timing scheme can occur anytime.

Solution is to move the switch inside the interrupt when the last timer of the cycle occurs.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied