I play with 240×320 (targeting ~ 6 Mpixels/second) and 320×480 (targeting ~ 12 Mpixels/second) panels, typically using 16-bit color (RGB565), which would require 96 MHz and 192 MHz SPI clock rates. It would be much nicer to use (DMA to) an 8-bit parallel bus; this is natively supported by ILI9341, ILI9488, ST7789 variants, and most others; not all display panels do expose all the mode select pins, though. (BuyDisplay
2.4" 240×320,
2.8" 240×320,
3.2" 240×320,
3.5" 320×480, for example do.)
You'll want your DMA to be slaved to the /WR strobe, so that on falling edge the DMA sets up the 8 data pins, and on a rising edge the display controller will latch the data. All this is relatively straightforward thus far. The two annoying things are A) generating exactly the correct number of /WR strobes (falling and rising transitions), and B) the D/C or data/command strobe. For a command byte, D/C should follow /WR strobe. For parameter and data bytes, it should stay high.
Thus far, the best method I can think of is to actually output the command byte when setting up the next DMA transfer, manipulating the D/C as a GPIO pin. This is suboptimal, because each command must be a separate DMA transfer. For example, to update a rectangular
H×
W region, you need three commands: a
Column Address Set command with two parameter words (starting and ending columns), a
Partial Area command with two parameter words (starting and ending lines), and a
Write command with
H×
W pixels of data (two bytes per pixel for RGB565). You then need to generate the correct number of /WR strobes. Any excess, and you'll overwrite the beginning of the region. Using SPI CLK or MOSI line, padding the pixel data with 8 extra pixels (copied from the beginning of the region), rounding the length up to a multiple of 8, and DMA'ing 0x55 = 01010101₂ to SPI is the "best" way I've found.
A small 8-bit parallel to 8/16-bit parallel expander with a pulse counter would be very useful. The MCU supplies a suitable clock, and an open collector control output that is pulled high by the expander. Whenever the MCU pulls it low, the expander connects the clock to the MCU DMA trigger line (so this is
slave DMA, triggered by GPIO pin), and starts by reading four bytes. This specifies the 24-bit length (in bytes or byte pairs) of the data to follow, and the mode (read from or write to the external display controller). If the length is zero, the expander disconnects the clock to the MCU, and stops, pulling the control high. Otherwise, it passes through that many byte pairs from/to the display controller, then reads the next four bytes. D/C is low for the first word only. At minimum, it would have 11 data lines to the MCU (clock out, clock in, control, D0..D7), and 12 or 20 data lines to the display controller (/CS, /WR, /RD, D/C, D0..D7 or D0..D15). I'd also connect TE pin from display controller to MCU, for detecting vertical retrace. 12 pins for a display module would not be too much.
If implemented in a small CPLD or FPGA, it probably would have enough resources left to implement a write-through lookup. The idea is to add two more modes: one reads 256 pixels into cache (palette), and the other reads 8-bit indexes from the microcontroller, and does an 8-bit lookup for each pixel.
Unfortunately, all this added complexity is just not worth the component and development cost for a hobbyist like me. You still need a microcontroller with a minimum of 320×480×16bit = 307,200 bytes of RAM for the display alone.
Now, I can buy a full
Milk-V Duo for about 10€, or a
Sipeed LicheeRV Nano-B (basic, without Ethernet or WiFi) for about 12€, shipped including taxes, from AliExpress. These have a dual-core 64-bit RISC-V processor with 64M/256M of RAM, and a high-speed (480 Mbit/s) USB 2.0. They have just enough I/O pins for a parallel 8-bit 8080-style bus, so that the simpler core can be a glorified display controller, combining the output graphics from multiple planes with transparency and blending, and the bigger core can do all the rendering. Lots of memory for pixmap caches, too. And a high-speed microSD card socket for the firmware and reading graphics resources from. LicheeRV Nano-B is
tiny, but still has a 31-pin MIPI DSI (2-lane) connector for displays, a backlight LED driver, and a 6-pin I²C connector for capacitive touch controllers, plus the four-lane CSI connector has 10 consecutive GPIO pins at 1.8V logic. Which is not a problem; a SN74LVC8T245 and similar translators are cheap. The documentation on these is not complete, but the schematics show exact connections, and Sipeed and MilkV try to be friendly to open source, so I'm basically happy enough. (It turns out that even though LicheeRV Nano-B is smaller, it maybe much better suited for my needs, if I map the I/O pins differently. I already do have some Milk-V Duo 64M and 256M boards to play with.)
Is this utter overkill for a glorified HMI or programmable display?
YES, definitely. But I don't care. I haven't gotten it to the demo stage yet, though; I'm not in any hurry.
I know from doing the software-display-controller/renderer on Teensy 4.0 (Cortex-M7 running at 600 MHz) that this approach works well for me. I can cache 4-bit (opacity) anti-aliased pixmap fonts, do paletted "sprites" and blitting, and so on. Frame-sync'd animation is no problem. I can even implement a
nanosvg renderer, and have some/all graphics assets in SVG, rather than pixmaps. My host is always a Linux machine, so USB is perfect, but otherwise using one of the UARTs at a suitably high baudrate would work too.