Code stops when calling TSPoint p = ts.getPoint() from an interrupt routine Arduino UNO with Open Smart LCD, Adafruit_GFX and MCUFRIEND_kbv

Hi,

I am having an issue when trying to call TSPoint p = ts.getPoint() from TIMER2 ISR in Arduino UNO.
The code is implementing 5 buttons. Here is the function i am calling from ISR:

bool Touch_getXY(void)
{
    TSPoint p = ts.getPoint();
    pinMode(YP, OUTPUT);      //restore shared pins
    pinMode(XM, OUTPUT);
    digitalWrite(YP, HIGH);   //because TFT control pins
    digitalWrite(XM, HIGH);
    bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
    if (pressed) {
        //LANDSCAPE
        pixel_x = map(p.y, TS_LEFT, TS_RT, 0, tft.width()); 
        pixel_y = map(p.x,TS_BOT , TS_TOP, 0, tft.height());
    }
    return pressed;
}

The code is inspired from the button example implemented by .kbv.
The interrupt gets called once every second.

Any help is appreciated!

Regards,
Mohammed

I'm having difficulty impressing on people the importance of posting code.

Any help is appreciated.

Don’t call it from ISR, simples

That will be a fairly slow function since getPoint does multiple analogReads as well as pinModes and digitalWrites. We need to see the rest of the code, the problem may be in the ISR itself, or elsewhere in the code. The YP and XM pins are shared with the display, so its possible an interrupt might occur while they are in use.