Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)
User avatar
By RFZ
#67689 Hi,
I want to drive/multiplex a given LED matrix using the ESP8266. I obviously don't want to bitbang in software, so I'm seeking your help to decide on what hardware features of the ESP8266 might be used and if it is even possible to drive the LED matrix with the ESP (while using its CPU for a nice Web-GUI ;))

The LED matrix basically has four input pins. A serial input with clock (SCK) and data (SDA), a latch input (RCK) and an input to turn the LEDs of the selected row on (LED).

The matrix has 18 rows, 288 LEDs each, controlled via shift registers. The row is selected by the last byte I shift into the registers, so I have to send 36+1 bytes of data for each row, latch the input and flash the LEDs.

The serial clock should be around 4MHz at least. Latch is on falling edge. LEDs should pulse HIGH for about 6µs and everything should repeat with about 10 kHz, cycling through the 18 rows

It is very important that the LED pin never is HIGH for a longer period or the LEDs might geht damaged, so I want to manage that in hardware too....

I'm pretty new to hardware programming. I successfully drove the LED matrix with an Atmega328P using SPI and a timer interrupt (RCK/LED done in software within the timer interrupt).

What hardware would you use to implement that?
The ESP8266 has SPI (HSPI?), I2S and UART available, right? I've done some research on the hardware available, but I don't know much about their limitations and configuration options so far. I hope you can help with that.

Would you use a timer (I've gotten different information about the esp having hardware timers or not...) for the 10kHz base interval? Or maybe use the I2S interface with a DMA loop (I've read somewhere this can be done?) to generate the LED puls with a 10kHz interval and fire an interrupt? At 2 MHz I could adjust the LED pulse width in 0.5µs increments and only need 25 bytes of ram for the whole interval.
I guess I can fire an interrupt on each I2S loop to initiate the SPI hardware to send a data row for the matrix to display?

I'm using a WeMos D1 mini and Arduino IDE / Visual Studio (with Arduino IDE plugin) most of the time because of the libraries available.

One problem might be that the I2S data pin is also the UART RX pin, right? So I won't be able to drive the matrix while the USB is plugged in AND I would also have to disconnect the matrix while programming via USB/UART, or the LED pin might get driven HIGH for too long ... Is that right? Any Ideas for that?

Thx for your help/ideas :)
User avatar
By RFZ
#67710 I don't want to use additional hardware/ICs, nor is the MAX7219 capable of driving a led matrix with serially interfaced shift registers (the MAX7219 interfaces LEDs directly). I'm looking for ways to use the ESPs internal hardware as efficient as possible.
User avatar
By RFZ
#68160 Okay, maybe I have to simplify my question:

What is the best way (least jitter/CPU usage possible) to generate a 10kHz signal with a HIGH pulse duration of about 5-15µs (configurable) on a GPIO and also fire an interrupt?

I don't want to use SPI because I'll need that for the actual data. UART would be okay, but I prefer to not use it, because I program via UART and my design will have a USB 2 UART chip on it.