3.2" SPI ILI9325 TFT Touch Screen Compatible Library

Status
Not open for further replies.

wildview

Well-known member
Hi, I was wanting to try a 3.2" TFT Touch display with a ILI9325 controller on a Teensy 3.2 board. I noticed Paul has a library for the ILI9341 controller here https://github.com/PaulStoffregen/ILI9341_t3. Does anyone know if this library is compatible with the ILI9325 controller? If not, is there a library that is for the Teensy 3x boards? Or maybe this one could be modified with minimal work = ) I seen a post where someone had a TFT display with the ILI9325 package here https://forum.pjrc.com/threads/16798-2-8-quot-TFT-touchscreen-Teensy-3-0 but people where having trouble getting it to compile.

Tnx,
Rob
 
Last edited:
The ILI9325 controller supports parallel 8-/9-/16-/18-bit data bus MCU interface and serial peripheral interface (SPI).

The ILI9341_t3 library is for the SPI interface. I think the library is not compatible. The command codes are different in the two datasheets (ILI9325 and ILI9341).

The library mentioned in the second link Adafruit TFTLCD-Library is for the parallel 8-bit data bus. Two years ago, with the modifications from the thread, the library worked well with the Teensy 3.0 and the 2.8" 18-bit color TFT LCD with touchscreen breakout board (ILI9325 controller) from Adafruit.
 
Thanks for your reply. Yeah that's what I figured. I kind of cringe when doing projects with the Teensy boards. They are great boards and fast, but code support is so limited with this product compared to the arduino product and one has to spend hours finding or converting other code to work on it. Which I wish wasn't the case since I like this boards.

Does the ILI9341 replace the ILI9325 controller? Which is the better in your opinion to use?

I tried the code posted on my 2nd link above in topic #22, but that code has a lot of compile errors compiling the graphicstest.ino. There errors are below. Maybe this code doesn't support the Teensy 3.2. Does this compiler define #elif defined(__MK20DX128__) in the pin_magic.h file work for the 3.2 board since I noticed one of the errors below says the board is not supported.

C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_GFX\glcdfont.c:9:23: warning: 'font' defined but not used [-Wunused-variable]
static unsigned char font[] PROGMEM = {
^
In file included from C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:11:0:
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\pin_magic.h:271:3: error: #error "Board type unsupported / not recognized"
#error "Board type unsupported / not recognized"
^
In file included from C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/wiring.h:33:0,
from C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/wiring_private.h:7,
from C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:9:
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h: In function 'void digitalWriteFast(uint8_t, uint8_t)':
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h:1328:24: error: 'portSetRegister' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h:1328:51: error: 'digitalPinToBitMask' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
^
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h:1330:26: error: 'portClearRegister' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h:1330:53: error: 'digitalPinToBitMask' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
^
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h: In function 'uint8_t digitalReadFast(uint8_t)':
C:\Users\Mystuff\Projects\Arduino Software\arduino-1.6.3\hardware\teensy\avr\cores\teensy3/core_pins.h:1432:32: error: 'portInputRegister' was not declared in this scope
return *portInputRegister(pin);
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp: In constructor 'Adafruit_TFTLCD::Adafruit_TFTLCD(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)':
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:91:54: error: 'digitalPinToPort' was not declared in this scope
csPort = portOutputRegister(digitalPinToPort(cs));
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:91:55: error: 'portOutputRegister' was not declared in this scope
csPort = portOutputRegister(digitalPinToPort(cs));
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:95:38: error: 'digitalPinToBitMask' was not declared in this scope
csPinSet = digitalPinToBitMask(cs);
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::write8(uint8_t)':
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:765:21: error: 'write8inline' was not declared in this scope
write8inline(value);
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp: In member function 'uint8_t Adafruit_TFTLCD::read8()':
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:772:27: error: 'read8inline' was not declared in this scope
uint8_t d = read8inline();
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::setWriteDir()':
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:779:21: error: 'setWriteDirInline' was not declared in this scope
setWriteDirInline();
^
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::setReadDir()':
C:\Users\Mystuff\Projects\Arduino Software\MyArduino Projects\MyArduinoLibraries\libraries\Adafruit_TFTLCD\Adafruit_TFTLCD.cpp:785:20: error: 'setReadDirInline' was not declared in this scope
setReadDirInline();
 
Btw, the ILI9325 controller that I have has a 16bit data bus. I'm not an expert with the tft displays, but would I need to dedicate all 16 I/O lines on a Teensy to drive this display or can you just use the SPI interface to drive it?

Tnx.
 
The compiler define for Teensy 3.1 and Teensy 3.2 is __MK20DX256__. I think with the Teensy, the ILI9341 with SPI interface is the best solution (ILI9341_t3 library).

For the 16 bit bus you need 16 I/O lines + 4 or 5 for C/D CS WR RESET RD
 
Last edited:
Thanks for the quick replay. The pinout for the TFT ILI9325 controller I have below has an SPI interface. Can't I just use the SPI serial bus to communicate with the Touch display versus having to use all the 16Bit I/O lines?

Thanks again for you help,
Rob

PIN NO. SYMBOL DESCRIPTION FUNCTION
1 5V 5V power supply When powered from 5V supply,
Pin 1 & Pin 2 as power input,
Pin 33 & Pin 34 provide 3.3V output.
2 GND Ground GND
3 D0 Data lines D0-D15
4 D1
5 D2
6 D3
7 D4
8 D5
9 D6
10 D7
11 D8
12 D9
13 D10
14 D11
15 D12
16 D13
17 D14
18 D15
19 CS LCD chip select Low active
20 RS Instruction/Data register selection RS = 1 : Data Register
RS = 0 : Instruction Register
21 WR Write WR = 0, RD = 1
22 RD Read WR = 1, RD = 0
23 RESET Reset the controller chip Low active
24 NC Not connect Not connect
25 BLVCC 5V or 3.3V Backlight VCC
26 BLGND Ground Backlight GND
27 BLCNT Backlight brightness adjustment Control the backlight brightness via PWM
28 TP_IRQ Touch screen interrupt Low level while the touch screen detects pressing
29 TP_CS Touch screen chip select Low active
30 TP_SCK Touch screen SPI clock connects to SPI SCK
31 TP_SI Touch screen data input connects to SPI MOSI
32 TP_SO Touch screen data output connects to SPI MISO
33 3.3V 3.3V power supply When powered from 3.3V supply,
Pin 33 & Pin 34 as power input,
Pin 1 & Pin 2 keep NC.
34 GND Ground
 
Yes you can just use the SPI interface, but as far as I know there is no Teensy library for it.

With the modified Adafruit TFTLCD-Library you could use the ILI9325 in the 8 bit mode, with 8 I/O lines and 4 or 5 for control.
 
For the SPI interface you need the SDI and SDO pins from the display. It seems that these pins aren't broken out on your display board. The SPI interface in your pinout is for the touch screen controller and probably not connected to the ILI9325 display controller.

To switch from 16 bit to 8 bit bus you need the IM3 IM2 IM1 IM0 pins from the display.
 
Last edited:
Thanks for your help. It doesn't look good at making this display work with the teensy 3.2 without a lot of work. Here's the back of the ILI9325 display shield http://www.waveshare.com/img/devkit...Touch-LCD-C/3.2inch-320x240-Touch-LCD-C-4.jpg I don't see any IM Pins at all to configure the 8-bit mode.

So, in your opinion would there be a way to mod the pin_magic.h file for the Adafruit_TFTLCD library to make this work in the 8-bit mode? I don't really want to spend weeks on this project if you don't think it's possible. I might just have to order a display with the ILI9341 controller and SPI interface like this http://www.ebay.com/itm/191531963190?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT and wait a few weeks to get it from across the pond =)

Let me know what you think?

Tnx.
 
The ILI9325 display shield is configured for the 16-bit mode. The Adafruit_TFTLCD library supports only the 8-bit mode. The UTFT library seems to support the ILI9325 in 16-bit mode. UTFT is included in Teensyduino. Maybe it's worth a try? examples/UTFT/Teensy/UTFT_Demo_320x240. This example is for the ILI9325 based ITDB02-2.8 display from iteadstudio. But you need ~20 pins for it.

The ILI9341 display is good. The included SD card slot probably needs a small modification to work with the Teensy 3.2 (replace the 3 series resistors from the sd card slot)

http://pjrc.com/store/display_ili9341_touch.html
We do not recommend using the SD card socket on this display
 
Thanks guys. I should have dug more into what they sell at PJRC first since the stuff they sell is obviously supported with their boards. There's a ton of displays on eBay with so many different driver chips. Dang, you really need to research before you order anything. That was a lesson learned. Thanks so much for all the information.

I'm just going to use the 2.8 ILI9341 display they sell on PJRC. This will save me a lot of development time and from having to use a ton of extra I/O pins =) The display is cheaper online, but you have to wait a few extra weeks to get it.

Just curious about the SD card mods too. Why do the series resistors need to be changed, because of the 3.2 board speed? What values do they need to be changed to, do you know? Does the 3.1 Teensy have the same problem?

Tnx.
 
I have those ILI9341 PJRC Touch boards and have not yet modified the resistors to use the SD.

HWGuy - the link to 'fix' also shows a jumper needing closed - that same jumper seems to be present on the larger Touch board and I assume it needs closed there too - have you tried one?

Other benefit of PJRC purchase is they DOA test them before shipping. I got 3 and all powered up - one did stop working (all white) after a short number of a couple hours on time - worked a few minutes - now not at all. I'm waiting to hear if they warrant that as well. All three used on the same connector board - in turn the other two were off only a few nights these past 3 weeks. The one the dies still has working touch, but white display - the display is mounted askew on the PCB - I popped the tape off and the ribbon leads look to be soldered okay. The one working unit came un-taped to PCB so I added some.

Has anyone else gotten the PJRC OSH Touch Display board working? I socket soldered one tonight and same Teensy and display shows TOUCH, but only white display when put there - and works fine on return to my hand wired board. I put on the 100ohm and two 10K ohm resistors and sockets. Are any other parts critical? Is the new CAP to bridge the VCC & GND required? The OSH docs are not yet updated to the new board. And I didn't add power supply components yet,
 
I don't have a 2.8" touch display.

The jumper can be left open. Replacing the 3 resistors near the sd card slot should be enough. And maybe add a pull up resistor to the 3 chip selects (touch, display and sd card).
 
My hand built board didn't have the pullups and is working fine. The OSH touch board added two 10K pullups and that one is working as noted in p#14 - touch only no display colors on white LED backlight - I'm wondering if those pullups might be better removed? There is a pic - but those two resistors would be under the Teensy and not visible if they were on.
 
If the pullups are on the chipselects, they are ok.( I dont know were they are.)
You could measure all connections to check for shorts or bad soldering.
 
The oshpark board has pullups for T_CS and the chip select from the display. D/C doesn't need a pullup.
 
You are correct - I see the route crosses & angles under the D/C label and goes to TCS. I could get touch input - according to the USB spew - but no color.

Nothing smoked - same parts back on hand wired board still run fine. Will ring it out and inspect with better light/lenses. Assume the VCC&GND cap is optional?
 
@degragster you need to jumper power (3.3v) to the VCC pin if you have not populated the regulator section of the board, have 3 of the boards working fine.
 
defragster says Thanks cartere! IT WORKS! (jumpered CAP VCC hole to socket 3.3v pin bottom until I place/get my DigiKey order)

I hit the VCC pin a few times with no DVM continuity - but as a software guy I got bored when it didn't beep - so decided to just jump straight to smoke testing. Of course the 5v hits the LED, and the resistive circuit must steal power from elsewhere as it was live on SPI with data.
 
Status
Not open for further replies.
Back
Top