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.
ESP32 GPIO Interrupt
-
- Posts: 129
- 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
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP32 GPIO Interrupt
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 129
- 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
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.
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.
-
- Posts: 129
- 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
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.
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.
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP32 GPIO Interrupt
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 129
- 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
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.
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.
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP32 GPIO Interrupt
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 129
- 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
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
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
-
- Posts: 129
- 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
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.
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.
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: ESP32 GPIO Interrupt
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))
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))
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel