ESP8266: option to use NMI for PWM
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.
ESP8266: PWM glitches when doing DHT measure
When using a PWM channel in parallel of a DHT measure, there can be some glitches on the PWM channel at the measure time. This is because the DHT drivers locks interrupts for accurate protocol timing handling, and the PWM driver relies on these interrupts.