ILI9341 TFT-module generic informations

External hardware connected to the STM32 board
Post Reply
User avatar
madias
Posts: 1198
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

ILI9341 TFT-module generic informations

Post by madias » Mon Mar 26, 2018 9:53 am

I started the thread, because there are many informations, code, tricks and hints spread over this forum.
Date of information: 26.03.2018

Hardware information:
The ILI9341 TFT can be bought on EBay/Aliexpress for cheap in different configurations and hardware layouts, but there are many similarities:
Screen size: 2.2 up to 2.8 inch
Screen resolution: 320x240px
Interfaces TFT: Parallel or SPI (=most common and only the SPI library is supported by our adapted library in the repo)
Additional Hardware
SD-Card Adapter
Touchscreen controller (XPT2046) - optional! (sold as "with touch")
Schematic of the board (without touch controller): https://drive.google.com/file/d/1AsquTx ... bikfs/view

Problems with hardware:
Common:
The whole circuit is a little bit weird, because parts of them are ready for 5V, but the communication pins are not, anyway we only use 3.3V on our STM32!
3.3V permanent modification: On some boards there is a little single 65Z5 LDO and a a jumper link marked "J1". Closing this jumper bypasses the LDO, so 3.3V can directly connected to the VCC Pin

SD-Card
There are 3 resistors near the SD-Card-slot: R1-R3. Solder them out and jumper them with small plain wires. Otherwise the SD-Card will not work with STM32

LED-Pin
It seems that on some board layouts there is no resistor protecting the LED backlight.

optional hardware modifications
On a fully developed board we have 3x SPI: TFT, SD-Card, touch controller: I managed to use TFT and SD-card on one SPI port (Port 1) with some code hacks (see section "Problems with software") So the Pins TFT and SD-Card: MOSI,MISO,SCK can be soldered together on the module. This can also be done with the touch controller pins (CLK,DIN,DO) - but not tested.
If there is an resistor for the backlight the Pin: "LED" and "VCC" can also be soldered together.

Software
TFT:
Adafruit_ILI9341_STM (served with the repo):
Special adapted for STM32duino with DMA support - very fast!
Restricted to SPI1 {edited by @stevestrong}
Configurable SPI instance and frequency.

SD Card
Dont look further and take this one: https://github.com/greiman/SdFat The standard SD-Arduino library is also supported

XPT2046 Touch controller:
There are several libraries:
Serasidis_XPT2046_touch (within our repo)
XPT2046_Touchscreen by Paul Stoffregen: More advantaged with measuring the pressure so you don't need much oversampling getting precise inputs. Download: https://github.com/PaulStoffregen/XPT2046_Touchscreen BE CAREFUL! This library works only with SPI2! An adapted version for SPI1 is attached to this post.

Problems with Software
At the time of writing, there are some pitfalls with our TFT-library leaving SPI1 in 16-bit mode. So you have to manually change it before calling another SPI device, quote from stevestrong:
You can try to execute

Code: Select all

SPI.beginTransaction(SPISettings(18000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));
before calling any other shared SPI function not belonging to Adafruit_ili9341 lib.
For the next function group dealing with Adafruti_ILI9341 lib you have to again execute:

Code: Select all

SPI.beginTransaction(SPISettings(36000000, MSBFIRST, SPI_MODE0, DATA_SIZE_16BIT));
for the ILI9341 lib to work.
Useful links:
Monochrome Icons from FLASH: viewtopic.php?f=18&t=3395
TFT-library for SPI2 (very outdated!): viewtopic.php?f=13&t=1024&hilit=ili9341+spi2
Attachments
XPT2046_Touchscreen.zip
(86.18 KiB) Downloaded 34 times

Post Reply