Skip to content

ESP32-C3 board hangs during neopixel.write in loop #10554

Open
@RetiredWizard

Description

@RetiredWizard

I'm using the latest nightly GENERIC-C3-USB build on an Adafruit Qt Py C3

MicroPython v1.19.1-831-g4f3780a15 on 2023-01-20; ESP32C3 module with ESP32C3

When running a tight loop that includes a NeoPixel.write() operation the board appears to hang after somewhere between 50 and 200 writes. Adding a time.sleep(.015) before the write() prevents the hang (.01 is not long enough and still hangs).

This code hangs:

import neopixel
import machine
p = neopixel.NeoPixel(machine.Pin(2),1)
rgb = (0,10,10)
for i in range(500):
    if i%10 == 0:
        print(i)
    p[0] = rgb
    p.write()

Leaving out the p.write() doesn't cause the board to hang, but the neopixel obviously doesn't light up. The following code runs without the hang, but also takes a few seconds to complete:

import neopixel
import machine
import time
p = neopixel.NeoPixel(machine.Pin(2),1)
rgb = (0,10,0)
for i in range(500):
    if i%10 == 0:
        print(i)
    p[0] = rgb
    time.sleep(.015)
    p.write()

I've tested this on a Feather RP2040 and a ESP32-S3 dev kit and neither of those boards hang in the loop without the time delay so this seems to be specific to the ESP32-C3 board.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions