IQR pin On "Lolin TFT 2.4" with

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Jerremy09
Posts: 26
Joined: Wed May 08, 2019 7:40 am

IQR pin On "Lolin TFT 2.4" with

Post by Jerremy09 » Sat Jan 18, 2020 6:14 pm

I have "Lolin TFT 2.4" and Lolin D32 Pro 2.0.0, Libraries for TFT "ILI9341" and touch "XPT2046" work fine, I also use TFT connector to connect both devices. I have only 1 issue with IQR pin on TFT display.

IQR pin is used on TFT display used as signal which has:
3.3V - When not touched
0V - When touched

When I connect board to battery then "IQR" pin on TFT starts sends 3.3V to Board (PIN0 - set as input), then when I press touch screen nothing happen (IQR - still sends 3.3V).

When I connect board to USB to PC then "IQR" pin on TFT starts sends 3.3V to Board (PIN0 - set as input), then when I press touch screen also nothing happen. But when I connect board with REPL (using VS Code and PYMAKR plugin) then display change Voltage on "IQR" pin to "0V" when is touched (as it is supposed to be).

Don´t any one from you know why this happen? Why IQR change voltage only after connecting to REPL? I need to have "IQR" be used right after I start charging Board and TFT.

Thank you

Jan

User avatar
Roberthh
Posts: 1894
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: IQR pin On "Lolin TFT 2.4" with

Post by Roberthh » Sun Jan 19, 2020 9:30 am

If you talk about Pin0, ist that the Pin labeled on the LoLin board with 0? If yes, that one, GPIO0, is also used for switching the device mode between run and bootload. Try to use another Pin of the LoLin.

Jerremy09
Posts: 26
Joined: Wed May 08, 2019 7:40 am

Re: IQR pin On "Lolin TFT 2.4" with

Post by Jerremy09 » Sun Jan 19, 2020 2:19 pm

Hello Roberthh,

thank you for post , I tried your suggestion, but with same results. I tried to read a bit more about SPI bus in general. I read that communciation should start that Master device starts to send "CLK" signal to bus. During run of boot.py "clk" is sent correctly and display shows everythoig as should. But I noticed that "clk" signal drops down and do not continue during "main.py".

clk signal is in normal sent this way: (measured on osciloskope)
Once per 100kHz is sent a 24x times a signal of 2MHz (which is my boudrate)

Link to page: https://cs.wikipedia.org/wiki/Serial_Pe ... _Interface

Notes:
1) boot.py
- contain definition of Touch screen and screen itself
- contain code (as a function from other file) to display initial page
- clock signal is sent

2) main.py
- contain only function to read touch and run other function (also in other file)

code boot.py:

Code: Select all

#/-----------------------------Display Home Page-----------------------------/#
import sys
sys.path.insert(1, '/Display')

import machine
import ili9341
import xpt2046
spi = machine.SPI(1, baudrate=2000000, miso=machine.Pin(19), mosi=machine.Pin(23), sck=machine.Pin(18))
display = ili9341.ILI9341(spi, cs=machine.Pin(14), dc=machine.Pin(27), rst=machine.Pin(33))
ts_touch = xpt2046.XPT2046(spi = spi, confidence=5, margin=50, delay=10)

ts_bussy = machine.Pin(0, machine.Pin.IN)
ts_cs = machine.Pin(12, machine.Pin.OUT)
sd_cs = machine.Pin(4, machine.Pin.OUT)

import _1_Home_Page_mod
_1_Home_Page_mod._1_Home_Page(display)

gc.collect()
#/-----------------------------Display Home Page-----------------------------/#
code main.py:

Code: Select all

#/-----------------------------main-----------------------------/#
def touch_ON(pin):
    #Touch
    ts_cs.value(0)
    stisk = ts_touch.raw_touch()
    ts_cs.value(1)
      
    #Search
    import Find_Page_mod
    if stisk!=None:
        Find_Page_mod._1_Find_Page(stisk, display)

#Setup
import gc

sd_cs.value(0)
ts_bussy.irq(handler=touch_ON)
sd_cs.value(1)

gc.collect()
#/-----------------------------main-----------------------------/#

User avatar
Roberthh
Posts: 1894
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: IQR pin On "Lolin TFT 2.4" with

Post by Roberthh » Sun Jan 19, 2020 3:04 pm

The IRQ-output of the XPT2046 does not need a clock signal. Can you check with an oscilloscope, whether there is any acticity on the IRQ pin when you push the screen. It is more or less an analog output, so transition may be too slow.

Jerremy09
Posts: 26
Joined: Wed May 08, 2019 7:40 am

Re: IQR pin On "Lolin TFT 2.4" with

Post by Jerremy09 » Mon Jan 20, 2020 7:29 am

Hello Roberthh,

that is right place where I found the issue. IQR pin on Display do not change output voltage, this stay "3.3V" (measured on Voltmetter), only when connect REPL (I think that master stars to send "CLK" signall) then IQR starts work (3.3v state for non-touched and 0V for Touched).

Jerremy09
Posts: 26
Joined: Wed May 08, 2019 7:40 am

Re: IQR pin On "Lolin TFT 2.4" with

Post by Jerremy09 » Mon Jan 20, 2020 8:03 am

Hello Roberthh,

I even tried to add a one line code into "main.py" to display one pixel on display (same color as bacground on address X=1, Y=1), this also didnt helped. I hoped that recuring main.py will trigger "CLK" signal.

Jan

User avatar
Roberthh
Posts: 1894
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: IQR pin On "Lolin TFT 2.4" with

Post by Roberthh » Mon Jan 20, 2020 8:14 am

The display controller and the touch controller are distinct devices. Therefore any action to the display will not affect the touch device. And the touch IRQ pin does not require a clock signal. Anyhow, the clock is only needed and active during data transfers.
Looking at the data sheet, it may however happen that the touch controller is waiting for the last clock cycle form a previous action. Until that happens, the IRQ output is not active. So you may change the phase parameter of the SPI device.
The busy signal has to be high after the transmission cycle has finished.

Jerremy09
Posts: 26
Joined: Wed May 08, 2019 7:40 am

Re: IQR pin On "Lolin TFT 2.4" with

Post by Jerremy09 » Mon Jan 20, 2020 5:13 pm

Hello Roberthh,

I tried:
1 )spi = machine.SPI(1, baudrate=2000000, polarity=0, phase=0, miso=machine.Pin(19), mosi=machine.Pin(23), sck=machine.Pin(18))
- same issue

2) spi = machine.SPI(1, baudrate=2000000, polarity=0, phase=1, miso=machine.Pin(19), mosi=machine.Pin(23), sck=machine.Pin(18))
- display has only white color with no chance to touch or see anything

3) spi = machine.SPI(1, baudrate=2000000, polarity=1, phase=0, miso=machine.Pin(19), mosi=machine.Pin(23), sck=machine.Pin(18))
- same like at point 1

4) spi = machine.SPI(0, baudrate=2000000, polarity=0, phase=0, miso=machine.Pin(19), mosi=machine.Pin(23), sck=machine.Pin(18))
- same like point 2

Jan

Post Reply