2.8" Resistive Touch Shield Interrupt
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
2.8" Resistive Touch Shield Interrupt
As a simple test, I have removed the touch shield from the Mega and patched in a bread-boarded push-button to see if I can get the interrupt - the button connects PIN7 to ground. No interrupt. My test works fine on PIN 3. I must be missing a basic concept here. Any help would be appreciated.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 2.8" Resistive Touch Shield Interrupt
Only specific pins have the circuitry to generate interrupts.
On the Mega 2560, only pins 2, 3, 18, 19, 20, and 21 can detect rising edge, falling edge, or level-based interrupts. Only pins managed by ports B, J, and K can generate pin-change interrupts.
On the Mega 2560, only pins 2, 3, 18, 19, 20, and 21 can detect rising edge, falling edge, or level-based interrupts. Only pins managed by ports B, J, and K can generate pin-change interrupts.
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
Re: 2.8" Resistive Touch Shield Interrupt
I understand that. However, I see that the Adafruit documentation says that I should be able to get an interrupt on pin 7 if I solder in the appropriate jumper. Also, that same documentation led me on a long hunt that took me eventually to a library called EnableInterrupt-master. Along the way, I learned that, in addition to the hardware interrupts, there are also pin-change interrupts. I am beginning to think that this is a 'wild-goose' chase. Now I am thinking that I may have to patch the shield, again as indicated in the Adafruit documentation, by adding a 'little blue wire' to change the interrupt pin to any I wanted. I am not sure exactly how that would be done i.e. perhaps break the pin 7 solder connection and add a wire from one of the sides to a hardware interrupt pin - probably 2 or 3.
Here is the description from Adafruit:
Advanced users may want to get an interrupt on a pin (or even, just test a pin rather than do a full
SPI query) when the touchscreen is pressed. You can do that by jumpering the #7 solder jumper
labeled TS int. We didn't want it to connect to #2 or #3 since those are the Leonardo I2C pins. You
can use pin change interrupts to get an interrupt callback on #7. (http://adafru.it/d4h)Or, with a little
blue wire, advanced users can connect a wire from the TS interrupt pad to any pin they choose. We
find that querying/polling the chip is fast enough for most beginner Arduino projects!
Again, any help would be greatly appreciated.
Thank you
Here is the description from Adafruit:
Advanced users may want to get an interrupt on a pin (or even, just test a pin rather than do a full
SPI query) when the touchscreen is pressed. You can do that by jumpering the #7 solder jumper
labeled TS int. We didn't want it to connect to #2 or #3 since those are the Leonardo I2C pins. You
can use pin change interrupts to get an interrupt callback on #7. (http://adafru.it/d4h)Or, with a little
blue wire, advanced users can connect a wire from the TS interrupt pad to any pin they choose. We
find that querying/polling the chip is fast enough for most beginner Arduino projects!
Again, any help would be greatly appreciated.
Thank you
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
Re: 2.8" Resistive Touch Shield Interrupt
Ok, I've just rewired and tested it. I should have done this right away, instead of wasting my time on 'pin change' interrupts. I could make out the traces on the board, so I knew which pad to solder to. Guess I was just a bit leary of touching the shield. Anyway, I removed the jumpers from the interrupt and the backlight pads. Interrupt now goes to pin 2 and backlight to pin 7. This frees up another hardware interrupt.
You might think about revising the TFT shield documentation.
Thanks
You might think about revising the TFT shield documentation.
Thanks
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
Re: 2.8" Resistive Touch Shield Interrupt
I am having problems with the touch shield interrupt which I have rewired to digital pin 2. I get one interrupt the first time I touch the screen, then no more interrupts. Here is my test program:
Code: Select all
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ILI9341.h> // Hardware-specific library
#include <Adafruit_STMPE610.h> // Touch Screen library
#define SKETCH "InterruptTest Rev3"
#define PIN 2 // The interrupt pin
#define STMPE_CS 8
#define TFT_DC 9
#define TFT_CS 10
#define PINinterrupt digitalPinToInterrupt(PIN)
volatile bool TFTRising = false;
volatile bool TFTFalling = false;
volatile bool TFTChange = false;
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(F(SKETCH));
Serial.print("Interrupts on Pin ");
Serial.println(PIN);
Serial.flush();
tft.begin();
ts.begin();
pinMode(PIN, INPUT);
attachInterrupt(PINinterrupt, ISR_RISING, RISING);
// attachInterrupt(PINinterrupt, ISR_FALLING, FALLING);
// attachInterrupt(PINinterrupt, ISR_CHANGE, CHANGE);
}
void ISR_RISING()
{
TFTRising = true;
}
void ISR_FALLING()
{
TFTFalling = true;
}
void ISR_CHANGE()
{
TFTChange = true;
}
void loop()
{
if (TFTRising)
{
TFTRising = false;
Serial.println(F("TFTRising"));
}
if (TFTFalling)
{
TFTFalling = false;
Serial.println(F("TFTFalling"));
}
if (TFTChange)
{
TFTChange = false;
Serial.println(F("TFTChange"));
}
Serial.flush();
}
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 2.8" Resistive Touch Shield Interrupt
You need to empty the buffer of touchscreen events before it will generate interrupts for new ones.
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
Re: 2.8" Resistive Touch Shield Interrupt
Thanks, that did the trick.
- King_Loui
- Posts: 3
- Joined: Wed Apr 05, 2017 7:21 am
Re: 2.8" Resistive Touch Shield Interrupt
I have the same problem, and no idea how i can clear that buffer? where can i find those informations?
tried how showed in picture: it also doesnt jump into my testroutine... :(
tried how showed in picture: it also doesnt jump into my testroutine... :(
- dfbrown
- Posts: 52
- Joined: Fri Mar 06, 2015 10:00 pm
Re: 2.8" Resistive Touch Shield Interrupt
You clear the buffer as follows:
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
while (!ts.bufferEmpty()) ts.getPoint();
Hope this helps.
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
while (!ts.bufferEmpty()) ts.getPoint();
Hope this helps.
Please be positive and constructive with your questions and comments.