Repository navigation
Description
TLDR; There is is bug in the FastLED RMT driver when running on the ESP32-C3. With an ESP-IDF version of the test sketch using their RMT driver, the C3 works OK.
Gory details follow.
===================
Hi all. Wrote a sketch to test an 8 × 8 WS2812B matrix panel.
When loaded on to an ESP32-C3, it doesn't work:
- leds[1], leds[2] flash brightly on startup
- pixel walk test; leds[0] is never written
- row test; leds[] data is offset by + 1, i.e. leds[0] is at leds[1], etc.
- column test; leds[0] never lights
- panel fill test; leds[0] never lights
C3 (failed) tests on:
seed studio XIAO ESP32C3
- Chip is ESP32-C3 (revision v0.3)
ESP32-C3 DEV
- Chip is ESP32-C3 (revision v0.3)
When run on a ESP32 or an ESP32-S3 all is tickity boo. Successful tests on:
M5Stack ATOM Matrix
- Chip is ESP32-PICO-D4 (revision v1.0)
ESP32 DEV Kit
- Chip is ESP32-D0WD-V3 (revision v3.0)
seed studio XIAO ESP32S3
- Chip is ESP32-S3 (revision v0.1)
Tested using Arduino v1.8.9 & Arduino IDE v2.1
Using arduino-esp32 core v2.0.7 and 2.0.8
FastLED library v3.50
Tried with two panels. Type is here.
Let me know if any other info would be of use.
Edit: retried with the #define NO_HARDWARE_PIN_SUPPORT declaration. No change to the result. C3 chips fail, others work.
Edit: Wrote a version using ESP-IDF. It works with the C3 boards listed above. Suggesting there is a bug in the invocation of the RMT driver for the C3. Used ESP-IDF v 4.4.4. Project Included below.
Sketch:
// 8 by 8 Matrix panel test
// #define NO_HARDWARE_PIN_SUPPORT // does not change the test results
#include <FastLED.h>
// Define LED matrix parameters
// pick a GPIO pin...
// #define LED_PIN 26 // for std ESP32
// #define LED_PIN 22 // for ATOM MATRIX
// #define LED_PIN 5 // for ESP32-C3
// #define LED_PIN 3 // alternate test pin for ESP32-C3
// #define LED_PIN 5 // for XIAO ESP32-S3
#define LED_NUM 64
#define LED_TIPE WS2812B
#define L_RED 0x00ff00
#define L_GREEN 0xff0000
#define L_BLUE 0x0000ff
#define L_WHITE 0xffffff
#define L_BLK 0x000000
#define A_DELAY 200UL // # of ms delay between animations
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
CRGB leds[ LED_NUM ];
CRGB tColours[] = { L_RED, L_GREEN, L_BLUE, L_WHITE };
uint8_t culrCount = sizeof( tColours ) / sizeof ( CRGB );
void setup() {
// Initialize LED matrix
FastLED.addLeds<LED_TIPE, LED_PIN>( leds, LED_NUM );
FastLED.clear( true );
FastLED.setBrightness( 10 );
Serial.begin(115200);
delay( 250 );
Serial.println("\r\n\r\n");
Serial.println( "=======================");
Serial.println( "8 x 8 Matrix Panel Test");
Serial.print( " LED Type = " ); Serial.println( TOSTRING( LED_TIPE ) );
Serial.print( " Data Pin = " ); Serial.println( LED_PIN );
Serial.print( " Colour Count = " ); Serial.println( culrCount );
Serial.println( "=======================");
}
void loop() {
// pixel walk - sequentially light up each pixel
for ( uint8_t culr = 0; culr < culrCount; culr++ ) {
for ( uint8_t pxl = 0; pxl < LED_NUM; pxl++ ) {
leds[ pxl ] = tColours[ culr ];
FastLED.show();
leds[ pxl ] = L_BLK;
delay( A_DELAY ); // pause before moving to the next pixel
}
}
FastLED.clear( true );
delay( 500 );
// row test - sequentially light up each row
for ( uint8_t culr = 0; culr < culrCount; culr++ ) {
for ( uint8_t i = 0; i < 8; i++ ) {
for ( uint8_t j = 0; j < 8; j++ ) {
leds
[matrix_test.zip](https://github.com/FastLED/FastLED/files/11357873/matrix_test.zip)
[ i * 8 + j ] = tColours[ culr ];
}
FastLED.show();
FastLED.clear();
delay( A_DELAY ); // pause before moving to the next row
}
}
FastLED.clear( true );
delay( 500 );
// column test - sequentially light up each column
for ( uint8_t culr = 0; culr < culrCount; culr++ ) {
for ( uint8_t i = 0; i < 8; i++ ) {
for ( uint8_t j = 0; j < 8; j++ ) {
leds[ i + j * 8 ] = tColours[ culr ];
}
FastLED.show();
FastLED.clear();
delay( A_DELAY ); // pause before moving to the next column
}
}
FastLED.clear( true );
delay( 500 );
// fill test - light up all pixels
for ( uint8_t culr = 0; culr < culrCount; culr++ ) {
for ( uint8_t i = 0; i < LED_NUM; i++ ) {
leds[ i ] = tColours[ culr ];
}
FastLED.show();
FastLED.clear();
delay( A_DELAY * 4 );
}
FastLED.clear( true );
delay( 3000 ); // pause before repeating the tests
}
// EOF
Activity
[-]ESP32-C3 Offset Issue[/-][+]ESP32-C3 leds Buffer Offset Issue[/+][-]ESP32-C3 leds Buffer Offset Issue[/-][+]ESP32-C3 RMT Driver Bug (with possible fix?)[/+]Xylopyrographer commentedon Apr 28, 2023
ESP-IDF version of the test sketch.
matrix_test.zip
taseraul commentedon May 27, 2023
I have also encountered this issue, and from my findings i concluded that some of the c3 pins are default high after the buffer is sent and the RMT relinquishes control so the pixles actually detect a ghost pixel (sometimes white, sometimes closed)
colincross commentedon Jun 19, 2023
I have a similar problem driving the neopixel on an Adafruit QT Py ESP32-C3, which has a 10k pullup on the data line. Scoping the data line shows that it rises slowly at the end of the data sequence, and is never held low for 50uS to trigger the reset state. Commenting out the
gpio_matrix_outline that disconnects the output pin from the rmt controller keeps the data line low between data sequences, triggering the reset correctly.colincross commentedon Jun 24, 2023
Removing
gpio_matrix_outcompletely causes other problems, if multiple output pins are in use it leaves them all connected to the RMT controller, causing everything that is sent to be sent to all LED strings.I tracked the problem down to a documentation issue (espressif/esp-idf#11737),
gpio_matrix_out(pController->mPin, 0x100, 0, 0);is only correct for some ESP32 platforms, on ESP32-C3 it needs to begpio_matrix_out(pController->mPin, 0x80, 0, 0);to reconnect the pin to the GPIO controller. Passing0x100selects peripheral 0 (theSPIQ_outline) with its output inverted. Since I'm not using the SPI controller it's output enable is not set, so the pin ends up floating.There doesn't seem to be an easy way to find the right value to pass to gpio_matrix_out for each platform. One option would be to
#ifdefthe platforms that use 0x80 instead of 0x100. The other option is to assume that the value will always be just the top bit of the field set, and compute it with(GPIO_FUNC0_OUT_SEL_M+1)>>1.Use correct cancel value for gpio_matrix_out on esp32c3
Use correct cancel value for gpio_matrix_out on esp32c3
colincross commentedon Jun 25, 2023
espressif/esp-idf#11737 pointed out
SIG_GPIO_OUT_IDX, which has the correct value on all platforms, so I've updated the pull request.ammoniak commentedon Jul 8, 2023
thx for the PR! (The fix works... hope this gets merged soon)
samm928 commentedon Nov 30, 2023
What exactly was the fix in this case ? .. Flashing a new Bootloader ? .. I'm seeing the same issues on third party ESP32 -C3 and -S3 SuperMini and Zero from Tenstar Robot and Waveshare
fusionliquid commentedon Sep 1, 2024
I also have similar problem with esp32 s3. when adding a motionsensor with FastLED, the system crashes reportedly saying RMT driver problem. But using the same code with cheaper arduino nano, it has no problem running...