4.0" ST7796S tft irq is triggered continuously using esp32

Hi,

I'm trying to design a tft interrupt code using esp32.

The code is working fine in polling code.
When using interrupt, the main function is triggered continuously without touching the tft module.

I checked the signal at the irq pin of the tft and the signal seems to be triggered in a way it's like a spi signal which isn't actually.

Without enabling interrupt, the tft irq works as expected.

This is my code:

  1. main:
#include <SPI.h>
#include <TFT_eSPI.h>
#include <PNGdec.h>
#include "system_variables.h"

void IRAM_ATTR tft_irq_isr(void);

TFT_eSPI tft = TFT_eSPI();

void setup(void) {
  Serial.begin(115200);
  Serial.println("\n\nStarting...");
  delay(100);

  tft.init();
  tft.setRotation(0);
  attachInterrupt(36, tft_irq_isr, FALLING);
  main_menu();
}

void loop() {
}
  1. isr code:
void read_menu_buttons(void){
  if(main_index == MAIN_MENU){
    main_index |= read_button(f1);
    main_index |= read_button(f2);
  }
  else if(main_index == FUNCTION1){
    main_index |= read_button(f1b1);
    main_index |= read_button(f1b2);
    main_index |= read_button(main_menu_b);   
  }
  else if(main_index == FUNCTION2){
    main_index |= read_button(f2b1);
    main_index |= read_button(f2b2);
    main_index |= read_button(main_menu_b);    
  }
}

void IRAM_ATTR tft_irq_isr(void) {
    detachInterrupt(tft_irq.tft_irq_pin);

    read_menu_buttons();
    
    switch(main_index){
      
      case MAIN_MENU:
        main_menu();
      break;
  
      case FUNCTION1:
        function1();
      break;
  
      case FUNCTION2:
        function2();
      break;
      

    }

  attachInterrupt(tft_irq.tft_irq_pin, tft_irq_isr, FALLING);
}

OK, one note until now is that I have to remove any function like, read_menu_buttons(); which is using SPI interrupt which is using another interrupt vectoring inside the current interrupt.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.