Page 1 of 2

ESP32 GPIO Interrupt

Posted: Wed May 18, 2022 2:12 pm
by jollybv
Hi Guys

I have not worked with touch screens before so a bit confused. What I'm trying to do is use the IRQ pin of the XPT2046 to trigger an interrupt and read the screen coordinates if the pressure is above a certain level but what is happening is that every time I touch the screen and generate the interrupt it resets the ESP32. I am using GPIO35 to generator the interrupt when it is pulled low.

What I have noticed if I disconnect the interrupt from the screen and pull it up to 3.3v with resistor then trigger it the same thing happens the ESP32 is reset so looks like there might be something up with the GPIO interrupt.

Any help will be appreciated.
ili9341_Test_touch.fcfx
(27.46 KiB) Downloaded 56 times

Re: ESP32 GPIO Interrupt

Posted: Wed May 18, 2022 3:33 pm
by BenR
Hello,

I wonder if it's the amount of code that was happening inside the interrupt routine. I've modified your program a little to move the interrupt code into the main and call this using a flag set by the interrupt. Hopefully this will work a bit better but let us know if it makes a difference.
ili9341_Test_touch.fcfx
(29.09 KiB) Downloaded 54 times

Re: ESP32 GPIO Interrupt

Posted: Wed May 18, 2022 4:20 pm
by jollybv
Hi Ben

Thanks that worked for the resetting. Now if I touch the screen it reads the touch once then the T-IRQ pin stays high and wont toggle when i touch the screen. If I remove the T-CLK then rest the ESP32 by removing then restoring power the T-IRQ line toggles but obviously I cannot read the coordinates without a clock. It seams to me that every time the XPT2046 reads it stops the T-IRQ for some reason. Also the X & Y coordinates are always the same and I assume that is wrong because the display is 240 x 320.

This is the results i get when I trigger the interrupt manually while touching the screen, it only seems to be reading one access. As I have the screen turned 270 degrees it looks like the x access is the missing one.
Coord.png
Coord.png (5.29 KiB) Viewed 2086 times

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 8:19 am
by jollybv
Hi Guys

I would like to work on my projects over the weekend but cant go forward until this issue is resolved. Please let me know if there is something I can do or is it a bug in the XPT2046 component.

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 10:23 am
by BenR
Hello,

Looking at the current program the prescale on the XPT2046 is set to 80MHz which is far too fast, If you haven't already then please try a lower speed.

Send us your current program and we can take a look for you.

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 11:24 am
by jollybv
Hi Ben

Yes I picked the prescale up and changed it to 100 KHz with no luck, I haven't changed the program much just the CS pin also i have tried the Analog Mode Single ended and Differential no difference.
ili9341_Test_touch1.fcfx
(29.12 KiB) Downloaded 62 times

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 1:12 pm
by BenR
Hello,

What if you set TouchFlag to be true in the wile 1 loop before you test it, this should force a constant poll of the sensor and only send new coordinates when a new touch event is detected.

I'll have a look in the component source to see if I can spot anything that might be disabling the interrupt output from firing.

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 2:00 pm
by jollybv
Hi
I have trid to poll the ReadTouch macro in the while loop every second just to test with out the interrupt but the X & Y coordinates are still the same

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 3:20 pm
by jollybv
Hi Ben

The x y problem is solved, In the test program I noticed that I was sending the x value to the y when printing to the UART
I will try work around the interrupt problem for now.

Re: ESP32 GPIO Interrupt

Posted: Fri May 20, 2022 3:27 pm
by BenR
Hello,

It might be worth adding brackets around your comparisons like this to force what's being compared.

((Y > 100) && (Y < 110)) && ((X > 10) && (X < 20))