I got from ebay a 2.2" 320x240 display with ILI9341 controller at the price of around 5$. I did not have much expectations from this display because of the price.
The display looks like this:
This version does not have a touchscreen. There are versions with touchscreen and here are also versions with larger display (3.2") with the same controller.
The ILI9341 controller can be interfaced in many parallel and serial ways but the PCB version I got had connections for SPI.
Onboard, there is also a SD card connector which I didn't try and a 3.3V LDO which you can bypass if you already have a 3V or 3.3V supply. At the connector, the "LED" pin is the backlight "+" of the LED backlight of the TFT. The "-" of the backlight is GND.
For successful communication you need:
SDO (MISO) - SPI MISO (I didn't use this pin in my SW driver)
SCK - SPI Clock
SDI (MOSI) - SPI MOSI
CS - SPI Chip Select
D/C - Data / Command line
RESET - Reset LCD
GND - Ground
SPI Configuration
void Config_SPI1()
{
SPI_InitTypeDef SPI_InitStructure;
/* Enable the SPI periph */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
/* SPI configuration -------------------------------------------------------*/
SPI_I2S_DeInit(SPI1);
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Hard;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_SSOutputCmd(SPI1, ENABLE);
SPI_Cmd(SPI1, ENABLE);
}
I tried this display on a ST discovery board with STM32F051R8. I used the SPI peripheral of this MCU which has a maximum SPI clock of 24MHz and a four level FIFO for RX and TX.
Using 24MHz SPI clock and taking advantage of the SPI FIFO I could fill the entire screen with pixels of the same color in the format (5-6-5) in around 50ms.
In fileexplorer.c and h you can find some helper functions to display more easily strings and numbers on ILI9341 screen.
In stm32f0_ili9341.c and h you can find the optimized ili9341 driver for STM32F0 SPI peripheral. The original files were created by Tilen Majerle.