ESP3hursday2 (late ESP32uesday): Poking DMA With a Stick
Normally I blog about ESP32 on Tuesdays, but was super exhausted after a trip to a monster-themed convention, so this one’s late. Saw some excellent monsters though!
Recap: I’ve been tasked with learning the intricacies of the ESP32 family, as they’re more available than other parts during this chip shortage. A pressing need is to get the Adafruit_Protomatter RGB matrix library working with the LCD peripheral unique to the ESP32-S3. Not quite there yet, but making headway. Part 1. Part 2.
The S3’s LCD peripheral requires using DMA (direct memory access), which I was dreading as another steep learning curve…but as it turns out, it’s not entirely unfamiliar, somewhat resembling the DMA implementation on Atmel SAMD chips, which I’ve used quite a bit! Much of the jargon and concepts are exactly the same…channels, descriptors, linked lists and so forth…
Left: ESP32-S3 Technical Reference Manual. Right: SAMD51 Datasheet. Both use linked lists of DMA descriptor structures.
The ESP32-S3 is a bit different from prior ESP32 generations. The new “General DMA” (GDMA) allows somewhat arbitrary mapping between channels and peripherals, whereas prior ESP32’s tended toward peripheral-specific DMA instances and channels…
Left: ESP32-S2 DMA Modules. Right: ESP32-S3 Channels and Modules. Nice.
The only place it gets peculiar compared to SAMD is that RAM-to-RAM DMA transfers (e.g. like a background memcpy()) require two channels, an “inlink” and “outlink” with GDMA as the middleman. That’s not something needed in Protomatter, just an interesting tidbit learned along the way.
Additionally, ESP32-S3’s GDMA supports “round-robin” scheduling (cycling through DMA channel transactions, rather than each in turn)…again, not vital for Protomatter, but I could see this being helpful for other projects like NeoPXL8 (not currently ESP32-compatible) and am eager to explore this later. SAMD51 is supposed to support round-robin scheduling but I could never get it to work, unsure if ineptitude on my part or a documentation or silicon errata issue.
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.