Driving an ILI9341 Display with a Raspberry Pi Pico
In order to drive an ILI9341 display with their Raspberry Pi Pico, Redditor JermMX5 had to develop their own library.
The new Raspberry Pi Pico development board isn’t just exciting because it is affordable and capable; it is also exciting because it is based on a brand-new microcontroller, the RP2040, that Raspberry Pi designed themselves. That is unusual, as most development boards, including every board in the Arduino lineup, utilize existing microcontrollers. The RP2040 is a very capable and feature-packed microcontroller, but the downside of using a completely new design like this is that hardware support is somewhat lacking. If you’re using an Arduino, there are libraries available for most popular hardware. In order to drive an ILI9341 display with their Raspberry Pi Pico, Redditor JermMX5 had to develop their own library.
The ILI9341 is a very popular display driver that you’ll find in many smaller TFT LCD screens. If your TFT LCD is somewhere between 2”-3.5” and accepts SPI input, there is a very good chance that it is driven by an ILI9341. Because the ILI9341 is so popular, there are many libraries out there that you can take advantage of if you’re using an Arduino or another established development board. While both Arduino boards and the new Raspberry Pi Pico can be programmed in a combination of C and C++, there are differences that prevent you from simply using an Arduino library with your Pico. But if you know what you’re doing, you can adapt those libraries to make them work. JermMX5 did that and improved the frame buffer while they were at it.
When driving a display, the frame buffer is a portion of the RAM that is used to store all of the data for the pixels that will be sent to the screen the next time it is updated. Because Arduino boards like the UNO have a relatively small amount of RAM, the existing ILI9341 libraries have a frame buffer that breaks the screen up into small sections. Each time the display is updated, only one portion of the screen is actually changed. That results in flickering that looks pretty bad. Fortunately, the Raspberry Pi Pico’s RP2040 has a generous 264KB of RAM. That is more than enough for the frame buffer to contain the entire screen so it can be updated all at once, eliminating flickering. The frame buffer uses a total of 153KB of RAM, so there is plenty left over for the other tasks. JermMX5 plans to use this for a Game Boy emulator in the future, but we hope they release this ILI9341 library for the Raspberry Pi Pico soon so that we can all take advantage of it.