A fast STM32 ILI9163C SPI LCD driver using HAL

A short proof of concept that demonstrates how to use a frame buffer to drive SPI displays at faster-than-video rates


Over the past few years, compact 1.8" 160x128 LCDs with an SPI interface, such as the one in this article, using almost-compatible controllers, have become incredibly cheap.
However, due to their SPI interface, with an official maximum speed of 15MHz, they are often disregarded as too slow for high performance projects, such as mini game consoles and embedded devices with serious user interfaces.
To demonstrate that they can run at full video speeds, I created a proof of concept driver for STM32 microcontrollers using HAL, which allows speeds of over 80 frames per second - far more than is necessary for good UI.

Technical info

The driver creates an array of 160x128x2 bytes, with the x2 multiplier being used for full 16-bit color. At the beginning of every frame, the buffer is (optionally) cleared. Then, the necessary graphical functions are called, and finally a call is made to a command that starts a DMA transfer of the entire buffer into the display.
The command is blocking to prevent buffer corruption, but if the CPU is sufficiently loaded, the DMA transfer can be let run completely in the background.
Comparing DMA to non-DMA at the same clock rates, the frame rate increases from around 10-15 to 80-81, while the CPU load drops several orders of magnitude, leaving time for other tasks.
Frame rate counter(hardware timer) showing 81.1fps


Code and instructions

The code and instructions are available from my GitHub. It's a bit raw and crudely written, but it serves its purpose as a proof of concept.
Go to GitHub page