ESP32 GPIO Interrupt

For general Flowcode discussion that does not belong in the other sections.
jollybv
Posts: 125
http://meble-kuchenne.info.pl
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

ESP32 GPIO Interrupt

Post 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 53 times

BenR
Matrix Staff
Posts: 1726
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 438 times
Been thanked: 602 times

Re: ESP32 GPIO Interrupt

Post 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 50 times

jollybv
Posts: 125
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

Re: ESP32 GPIO Interrupt

Post 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 1998 times

jollybv
Posts: 125
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

Re: ESP32 GPIO Interrupt

Post 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.

BenR
Matrix Staff
Posts: 1726
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 438 times
Been thanked: 602 times

Re: ESP32 GPIO Interrupt

Post 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.

jollybv
Posts: 125
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

Re: ESP32 GPIO Interrupt

Post 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 57 times

BenR
Matrix Staff
Posts: 1726
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 438 times
Been thanked: 602 times

Re: ESP32 GPIO Interrupt

Post 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.

jollybv
Posts: 125
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

Re: ESP32 GPIO Interrupt

Post 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

jollybv
Posts: 125
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 40 times
Been thanked: 11 times

Re: ESP32 GPIO Interrupt

Post 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.
Last edited by jollybv on Fri May 20, 2022 3:28 pm, edited 1 time in total.

BenR
Matrix Staff
Posts: 1726
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 438 times
Been thanked: 602 times

Re: ESP32 GPIO Interrupt

Post 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))

Post Reply