Open zdila opened 4 years ago
Thanks for the praise, let me return it - finally, a well done bug report ...
As the PWM is done in software, there is always the possibility for some other interrupt handler to delay the PWM interrupt handler. Are there any other interrupt routines?
One possible mitigation is to lower the PWM frequency, 20kHz is quite high for lighting applications.
Are the long pulses isolated, or do they appear in groups? Can you do a trace including several pulses?
Thank for your prompt reply.
Are there any other interrupt routines?
None I am aware of. Testcase only uses ESP8266_NONOS_SDK, your PWM implementation and the code from this report.
I also had to add following definition as ICACHE_RAM_ATTR
is not defined in ESP8266_NONOS_SDK:
#define ICACHE_RAM_ATTR __attribute__((section(".text")))
I set it up using PlatformIO.
I am observing the same problem in my project based on Mongoose OS which internally uses ESP8266_NONOS_SDK 2.1.0. (BTW there ICACHE_RAM_ATTR is known).
One possible mitigation is to lower the PWM frequency, 20kHz is quite high for lighting applications.
I've tried to set period to 1200 for the same duty (20) but the problem is still there.
Are the long pulses isolated, or do they appear in groups? Can you do a trace including several pulses?
They seem to be isolated. I captured a trace with many pulses and focused on that wide one, then checked cca 10 on both sides and they were of "normal" width.
As I mentioned our product uses Mongoose OS. After we added Azure IoT functionality, the PWM quality rapidly decreased.
Surprisingly (for me) #define PWM_USE_NMI 1
fixed the problem.
Hello,
First thanks for the library which I consider to be the best OSS PWM library for ESP8266 I found.
I am observing soft LED flickering when using this PWM implementation.
The complete code:
Measurements with oscilloscope shows that most of the pulses take 4.07 μs:
But if I set trigger to pulse width of higher values, then it often triggers:
Original firmware of the device, which is closed source, doesn't have this issue. But according to strings in the binary blob it seems to be build with RTOS.
Is there anything I can do to prevent this?