Xinyuan-LilyGO / T-Display-S3

MIT License
731 stars 173 forks source link

Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled. #173

Closed redonkuless82 closed 2 months ago

redonkuless82 commented 11 months ago

So I'm not sure what is wrong here. I've googled & ChatGPT, basically im combining some examples ive seen for the esp32. If i remove the 23 image cycle, the code works with out crashing, however once i introduce the 23 image cycle into the touch feature everything crashes and the below error is what i receive. Now Ive tested the 23 image cycle by itself and does display animation, ive done the 2 display text features together, and i can use the touch to cycle through, again its only when I combine all three do i receive this crash.

Error:

ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) Saved PC:0x4202e99e SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3808,len:0x44c load:0x403c9700,len:0xbe4 load:0x403cc700,len:0x2a38 entry 0x403c98d4 E (228) gpio: gpio_set_level(226): GPIO output gpio_num error E (229) gpio: gpio_set_level(226): GPIO output gpio_num error Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core 1 register dump: PC : 0x00000000 PS : 0x00060c30 A0 : 0x82002ea5 A1 : 0x3fcebc70 A2 : 0x3fcebd1c A3 : 0x3fc97e44 A4 : 0x00000000 A5 : 0x00000008 A6 : 0x420025b4 A7 : 0x00000008 A8 : 0x820025f8 A9 : 0x3fc97e0a A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000008 A13 : 0x00000008 A14 : 0x3fc97e44 A15 : 0x0000000c SAR : 0x00000000 EXCCAUSE: 0x00000014 EXCVADDR: 0x00000000 LBEG : 0x42003450 LEND : 0x42003475 LCOUNT : 0x00000000

Backtrace: 0xfffffffd:0x3fcebc70 0x42002ea2:0x3fcebc90 0x42002747:0x3fcebd10 0x420027a7:0x3fcebdc0 0x42001cab:0x3fcebe00 0x42001e90:0x3fcebe40 0x420077e9:0x3fcebe60

ELF file SHA256: 3f67f06d2bf49e2c

Rebooting...

`#define TOUCH_MODULES_CST_SELF

include

include

include

include "Arduino.h"

include "OneButton.h"

include "TFT_eSPI.h" / Please use the TFT library provided in the library. /

include "TouchLib.h"

include "Wire.h"

include "pin_config.h"

define TFT_GREY 0x5AEB // Some grey color

//#define PIXEL_PIN 3 //#define PIXEL_COUNT 10

define LCD_MODULE_CMD_1

TFT_eSPI tft = TFT_eSPI();

warning Please confirm that you have purchased a display screen with a touch chip, otherwise the touch routine cannot be implemented.

if defined(TOUCH_MODULES_CST_MUTUAL)

TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, 0x01, PIN_TOUCH_RES);

elif defined(TOUCH_MODULES_CST_SELF)

TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, 0x1, PIN_TOUCH_RES);

else

error "Please choose the correct touch driver model!"

endif

// Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

define TOUCH_GET_FORM_INT 0

bool flags_sleep = false;

if TOUCH_GET_FORM_INT

bool get_int = false;

endif

OneButton button(PIN_BUTTON_1, true);

// Names to be displayed String names[] = {"Alice", "Bob", "Charlie", "Dave", "Eve", "Frank", "Grace"}; int namesCount = sizeof(names) / sizeof(names[0]); int currentNameIndex = 0; int imgNum = 0; // image number counter

if defined(LCD_MODULE_CMD_1)

typedef struct { uint8_t cmd; uint8_t data[14]; uint8_t len; } lcd_cmd_t;

lcd_cmd_t lcd_st7789v[] = { {0x11, {0}, 0 | 0x80}, {0x3A, {0X05}, 1}, {0xB2, {0X0B, 0X0B, 0X00, 0X33, 0X33}, 5}, {0xB7, {0X75}, 1}, {0xBB, {0X28}, 1}, {0xC0, {0X2C}, 1}, {0xC2, {0X01}, 1}, {0xC3, {0X1F}, 1}, {0xC6, {0X13}, 1}, {0xD0, {0XA7}, 1}, {0xD0, {0XA4, 0XA1}, 2}, {0xD6, {0XA1}, 1}, {0xE0, {0XF0, 0X05, 0X0A, 0X06, 0X06, 0X03, 0X2B, 0X32, 0X43, 0X36, 0X11, 0X10, 0X2B, 0X32}, 14}, {0xE1, {0XF0, 0X08, 0X0C, 0X0B, 0X09, 0X24, 0X2B, 0X22, 0X43, 0X38, 0X15, 0X16, 0X2F, 0X37}, 14}, };

endif

// Define the different states enum DisplayState { IMAGES, NAMES, DEAD_PROTOCOL }; // Initialize the state to IMAGES volatile DisplayState displayState = IMAGES;

volatile bool touchFlag = false; // Create a flag for touch

void IRAM_ATTR touchISR() { touchFlag = true; // Set the flag when the screen is touched }

void cycleImages() { if(imgNum > 23) { imgNum = 0; // reset to the first image if we've gone past the last image }

String imgPath = "/image_"; // base image path imgPath += imgNum; // add the image number imgPath +=".jpg"; // add the file extension

// Draw the jpg image from the filesystem // TJpgDec.drawFsJpg(x, y, filepath) draws a jpg image from the filesystem // at the specified x and y coordinates. // You'll need to replace "x" and "y" with the actual coordinates where you want to draw the image. TJpgDec.drawFsJpg(0, 0, imgPath.c_str()); // draw the image at coordinates (0, 0)

imgNum++; // move on to the next image for the next call to cycleImages() }

void displayNames() { // The code from the original loop() function in the second code goes here // Make sure to remove the delay at the end // for(int i=0; i<strip.numPixels(); i++) { // strip.setPixelColor(i, strip.Color(0, 0, 255)); // } // strip.show();

tft.fillScreen(TFT_WHITE); tft.setTextFont(4); tft.setTextSize(2); tft.setTextColor(TFT_BLACK,TFT_WHITE);

tft.drawString(names[currentNameIndex], tft.width() / 2, tft.height() / 2);

currentNameIndex = (currentNameIndex + 1) % namesCount; }

void displayDeadProtocol() { // The code for displaying "DP" goes here tft.fillScreen(TFT_WHITE); tft.setTextFont(4); tft.setTextSize(2); tft.setTextColor(TFT_BLACK, TFT_WHITE);

tft.drawString("DP", tft.width() / 2, tft.height() / 2); }

void setup(void) { if(!SPIFFS.begin(true)) {
Serial.println("SPIFFS Mount Failed"); return; } // strip.begin(); //strip.show(); // strip.setBrightness(255);

tft.begin();

if defined(LCD_MODULE_CMD_1)

for (uint8_t i = 0; i < (sizeof(lcd_st7789v) / sizeof(lcd_cmd_t)); i++) { tft.writecommand(lcd_st7789v[i].cmd); for (int j = 0; j < lcd_st7789v[i].len & 0x7f; j++) { tft.writedata(lcd_st7789v[i].data[j]); }

    if (lcd_st7789v[i].len & 0x80) {
        delay(120);
    }

}

endif

tft.setRotation(1); tft.setTextDatum(MC_DATUM);

// Configure the touch interrupt pin as an input pinMode(16, INPUT);

// Attach an interrupt to the touch pin attachInterrupt(digitalPinToInterrupt(16), touchISR, FALLING); // trigger when touch pin goes LOW }

void loop() {

if (touchFlag) { // If the touchFlag is set
displayState = static_cast<DisplayState>((displayState + 1) % 3); // Change the state
touchFlag = false; // Reset the flag

}

switch (displayState) { case IMAGES: cycleImages(); break; case NAMES: displayNames(); break; case DEAD_PROTOCOL: displayDeadProtocol(); break; } delay(500); }

`

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.