esp32: RMT timing glitches
I am getting semi-random glitches in the RMT output. I am trying to use it to drive Neopixels and I get wrong pulse lengths sometimes. The glitches occur less frequently when I have longer delays between writing the pulses and if I write less data. I say semi-randomly because when I am running an animation for the Neopixels it has a high tendency to glitch at the same time and the same LEDs seem to be glitching when repeating the run.
Here are two captures at the position that the glitch first occurs. The first 300 us are fine, then I start getting pulses that are longer than expected. In total it adds up to 70 us more (from 560 us).
Bad frame:
<img width="939" alt="Bildschirmfoto 2020-02-08 um 14 45 45" src="https://user-images.githubusercontent.com/11031419/74086417-f089fb80-4a82-11ea-9f96-d31a989ae814.png">
Good frame:
<img width="939" alt="Bildschirmfoto 2020-02-08 um 14 45 55" src="https://user-images.githubusercontent.com/11031419/74086421-f67fdc80-4a82-11ea-8555-22facd5c2f01.png">
Interestingly I also see the power go up at the end. Right now I have a level shifter attached to the output, because my first guess was that this was responsible for the glitches.
<img width="430" alt="Bildschirmfoto 2020-02-08 um 14 53 03" src="https://user-images.githubusercontent.com/11031419/74086436-0eeff700-4a83-11ea-8fdd-8c0c2008a983.png">
Some people here are reporting similar problems: https://esp32.com/viewtopic.php?f=2&t=3980&start=10
Disabling power management did however not resolve the it.
esp32: repeated RMT pulses when using `loop(True)`
As per original issue mattytrentini/micropython#11, in which this bug was more fully discussed, using loop(True) with the esp32 RMT object will cause repeated initial pulses.
Simple example:
from esp32 import RMT
from machine import Pin
pin = Pin(12, Pin.OUT)
rmt = RMT(0, pin=pin, clock_div=8)
rmt.loop(True)
rmt.write_pulses([2500, 7500, 5000, 5000, 7500, 2500])
With loop(False) this will produce the output show in Figure 1 below, but with loop(True) it will produce the – erroneous – output shown in Figure 2. The first of the three pulses is repeated.
<img width="1316" alt="72544860-04757f80-3880-11ea-9896-5416f9220e89" src="https://user-images.githubusercontent.com/591227/85015763-73714000-b160-11ea-9319-9c9969d6e8ad.png">
This, it turns out, is a bug in the ESP32 IDF (see espressif/esp-idf#4664) which has a fix committed for it. In the meantime, the accepted workaround is to call rmt_driver_install before rmt_config when initialising the RMT peripheral. This should still be fine after the fix makes a mainline IDF release.