Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By joostn
#5206 Has anyone gotten hardware timers / PWM to work?

I came across this code:
https://github.com/mattcallow/esp8266-s ... iver/pwm.c

and this actually works quite nicely. Only problem is if I arm the timer from user_init(), the ESP no longer attempts to connect to my access point. If I arm the timer after connection has been established, it works nicely for a few minutes but it eventually loses connection and wifi_station_get_connect_status() keeps returning 4.

This might mean I'm out of luck because the timer1 is actually used in the ESP's wifi code.

The OS timer functions (os_timer_arm / ets_timer_arm) don't work well, timer callbacks are often suspended for fractions of a second. It seems to be implemented through an event queue from the main thread, not directly from a timer interrupt. I'm really looking for a low latency/jitter PWM source to drive an RGB led at a couple of 100 Hz.
User avatar
By nicoverduin
#5218 Joost
Ever thought of using a separate chip? WS2811? Just pump 24 of info in bits and it will go on forever.....I did a similar thing in a led string of ws2812B connected to a Atmel328P and somewhere in the middle we needed some PWM to control Volume and video switching. the ws2811 is compatible with the ws2812 so we just put that chip in between the strip where we needed it.
my 2 cents :)
User avatar
By nicoverduin
#5272
joostn wrote:Yes that might just be the easiest solution. But that's kind of cheating ;)
So? :mrgreen:
Apparently the chip has 3 timers. Can't find anything about timer3. maybe not used yet. ? Seems the standard timer function is based on a list of timer interrupts. Thus that might cause a conflict when receiving data.