3.3.1. Interfacing SPI TFT displays with touch¶
This document describes how to connect a SPI interface based TFT display with touch support to the E2 connector, without the need for specific FPGA code. The given setup has advantages and drawbacks.
- It uses only
MIOsignals so it can be used with any FPGA image.
- Only extension connector E2 is used.
- SPI is not wired through the FPGA so maximum clock speeds can be used.
- MIO signals shared with SPI, I2C and UART are consumed. So this interfaces can not be used for other purposes.
- On board I2C EEPROM cna not be accessed. This might cause issues in programs which store calibration data in the EEPROM.
- Backlight control is not supported.
220.127.116.11. Hardware setup¶
It is possible to reconfigure Zynq MIO signals using the
pinctrl kernel driver.
This TFT display setup takes advantage of this by repurposing SPI, I2C and UART signals
on the E2 connector as SPI and GPIO signals which are required by the TFT display interface.
The reconfiguration is performed by including the
tft-E2 device tree.
|SPI TFT+touch||MIO||function||pin||pin||function||MIO||SPI TFT+touch|
|TFT RESETn||51||I2C SDA||
Since some of the signals share the I2C bus which already contains an EEPROM, there is a possibility there will be functional conflicts. Although the probability of the I2C EEPROM going into an active state are low. I2C devices only react after an I2C start condition is present on the bus. The start condition requires both SDA and SCL signals to be low at the same time. Here it is assumed TFT display RESETn (active low) will not be active at the same time as the touch controller SPI SSn (active low) signal.
Attempts to access the I2C EEPROM will not interfere with the display, but they will return a timeout. This might (probably will) cause issues with applications using the I2C EEPROM, for example calibration access from Oscilloscope app.
There is no MIO pin left for backlight control, the easiest solution is to hard wire the display backlight pin to VCC.
18.104.22.168.2. SPI clock speed¶
Only a limited set of SPI clock speeds can be set depending on
the clock driving the SPI controller.
The SPI controller itself provides only power of 2 clock divider options.
See the Zynq TRM
(section B.30 SPI Controller (SPI) register
BAUD_RATE_DIV) for details.
The next table provides available frequencies for two SPI controller clock settings. The maximum clock speed for this SPI controller is 50MHz.
|SPI controller clock||f/4||f/8||f/16||f/32||f/64||f/128||f/256|
22.214.171.124. Software setup¶
Instructions for starting XFCE on the TFT display.
A script which can be used to generate an image with full support
is available on GitHub
A set of Ubuntu/Debian packages should be installed:
apt-get -y install \ python3 python3-numpy build-essential libfftw3-dev python3-scipy \ xfonts-base tightvncserver xfce4-panel xfce4-session xfwm4 xfdesktop4 \ xfce4-terminal thunar gnome-icon-theme \ xserver-xorg xinit xserver-xorg-video-fbdev
An X11 configuration file should be added to the system
Over SSH start the X server:
126.96.36.199. Tested/Supported devices¶
The next table lists supported devices and corresponding of device tree files each supporting a set of displays depending on the used TFT and touch drivers.
|screen name||specifications||technical details||device tree|
|size||resolution||touch||TFT controller||touch controller|
|MI0283QT Adapter Rev 1.5||2.8”||240x320||ILI9341||ADS7846||
|Adafruit PiTFT 3.5” Touch Screen for Raspberry Pi||3.5”||480x320||resistive||HX8357D||STMPE610||
188.8.131.52.1. MI0283QT Adapter Rev 1.5¶
The device is powered by +5V, and it generates 3.3V using an on board LDO. Therefore all IO are 3.3V, so there are no conflicts.
|SPI TFT+touch||pin||pin||SPI TFT+touch|
Backlight control is not available on the E2 connector. A simple solution is to connect the LCD_LED signal to +5V VCC, this can be done with a simple jumper between the two display connector pins. Otherwise it would be possible to repurpose a LED on Red Pitaya.
95-ads7846.rules> UDEV rule will create a
184.108.40.206.2. Adafruit PiTFT 3.5”¶
There are two versions of this display the older Assembled (sometimes called Original and the newer Plus.
- PiTFT - Assembled 480x320 3.5” TFT+Touchscreen for Raspberry Pi (high resolution image)
- PiTFT Plus 480x320 3.5” TFT+Touchscreen for Raspberry Pi (high resolution image)
While the newer Plus version can be used out of the box, The older Assembled requires hardware modifications, for details see below <assembled_hw_mods>.
The device is powered by +5V (for backlight LED) and +3.3V for TFT and touch controllers (should be taken from the E1 connector on Red Pitaya). Therefore all IO are 3.3V, so there are no conflicts.
|SPI TFT+touch||pin||pin||SPI TFT+touch|
95-stmpe.rules UDEV rule will create a
A calibration file should be added to the system
220.127.116.11.2.1. Block diagram¶
18.104.22.168.2.2. Assembled version hardware modifications¶
The device is powered by a single +5V supply, and it generates 3.3V using an on board LDO. So 3.3V interfaces between Red Pitaya and the display have a different power source on each side. Since the two power sources do not wake up at the same time there is a race condition affecting touch controller SPI interface configuration during power-up reset. The LDO on the TFT board is faster then the switcher on Red Pitaya.
The STMPE610 touch controller datasheet (section 5.2) describes how CPOL/CPHA SPI configuration options depend on the power up reset state of a pair configuration pins.
|CPOL_N (I2C data/SPI CS pin)||CPOL||CPHA (I2C address/SPI MISO pin)||Mode|
On the original setup (before
pinctrl device tree is applied)
for the E2 connector the touch chip SPI CS signal is used as I2C_SCK.
The SPI MISO pin is not affected by
There appears to be a race condition between:
- the configuration read event timed by the STMPE610 power coming directly from the +3.3V LDO (5V USB power connector)
- and waking up of the 3.3V power supply on Red Pitaya, which powers the pull up resistors on the I2C pins and FPGA pull-ups for the SPI MISO pin on the E2 connector
In most cases the LDO on the TFT board would wake
before the switcher on Red Pitaya, so the
would be detected as
0, which inverts the SPI clock polarity.
As an unreliable fix, the
spi-cpol attribute can be provided
in the device tree.
It is not yet confirmed the power supply race condition is responsible for touch not working in certain setups, more testing might be necessary.
The provided oscilloscope image shows a 3.3V power up sequence and its relation to SPI configuration signals. It is evident configuration signals are stable.
- CPHA (the signal is low during power-up),
- CPOL_N (the signal is linked to 3.3V with a pull-up and rising simultaneously),
- 3.3V (it takes about 1.5ms to ramp up from 0V to 3.3V).
To avoid the power supply race condition, the LDO on the Assembled TFT board can be disabled, and instead +3.3V from Red Pitaya is used. This makes the Assembled power supply similar to the Plus version.
The next modifications have to be done:
- Remove the +3.3V LDO, or at least rise the power output pin off the board.
- Connect pin 1 on the JP1 connector to a +3.3V power line.
The next image shows a TFT board with a rised LDO power output and pin 1 on the JP1 connector connected to an unmounted resistor pad.
pinctrl, GPIO and interrupts¶
To see current
pinctrl settings try:
$ cat /sys/kernel/debug/pinctrl/pinctrl-maps
To see the status of GPIO signals try:
$ cat /sys/kernel/debug/gpio
To see the status of interrupts try:
$ cat /proc/interrupts
evtest can be used to see low level touch events (and keyboard/mouse):
sudo apt-get install -y evtest