I have an esp 32 TTGO T display and whenever i upload code and when terminal says doing hard reset it gets stuck esp 32 lights shows
What happens if you press the Reset key?
Show us the compile log in code tags and the serial log in code tags.
Sketch uses 308177 bytes (23%) of program storage space. Maximum is 1310720 bytes.
Global variables use 24984 bytes (7%) of dynamic memory, leaving 302696 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM4
Connecting....
Chip is ESP32-D0WDQ6-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: a0:dd:6c:73:24:b0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0005bfff...
Compressed 18992 bytes to 13112...
Writing at 0x00001000... (100 %)
Wrote 18992 bytes (13112 compressed) at 0x00001000 in 0.5 seconds (effective 302.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 372.7 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 488.2 kbit/s)...
Hash of data verified.
Compressed 308544 bytes to 170645...
Writing at 0x00010000... (9 %)
Writing at 0x0001a740... (18 %)
Writing at 0x000282fd... (27 %)
Writing at 0x0002d83d... (36 %)
Writing at 0x00032d9f... (45 %)
Writing at 0x00038720... (54 %)
Writing at 0x0003da8b... (63 %)
Writing at 0x0004309a... (72 %)
Writing at 0x000485d4... (81 %)
Writing at 0x00050e35... (90 %)
Writing at 0x00058fae... (100 %)
Wrote 308544 bytes (170645 compressed) at 0x00010000 in 3.3 seconds (effective 756.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
reset key shows no effect
That is the normal last statement before the code starts running. In the future, all code, logs, etc, are to be in code tags
Let's see the code.
im using the tft sample code that the startup guide told me to
// Diagnostic test for the displayed colour order
//
// Written by Bodmer 17/2/19 for the TFT_eSPI library:
// GitHub - Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
/*
Different hardware manufacturers use different colour order
configurations at the hardware level. This may result in
incorrect colours being displayed.
Incorrectly displayed colours could also be the result of
using the wrong display driver in the library setup file.
Typically displays have a control register (MADCTL) that can
be used to set the Red Green Blue (RGB) colour order to RGB
or BRG so that red and blue are swapped on the display.
This control register is also used to manage the display
rotation and coordinate mirroring. The control register
typically has 8 bits, for the ILI9341 these are:
Bit Function
7 Mirror Y coordinate (row address order)
6 Mirror X coordinate (column address order)
5 Row/column exchange (for rotation)
4 Refresh direction (top to bottom or bottom to top in portrait orientation)
3 RGB order (swaps red and blue)
2 Refresh direction (top to bottom or bottom to top in landscape orientation)
1 Not used
0 Not used
The control register bits can be written with this example command sequence:
tft.writecommand(TFT_MADCTL);
tft.writedata(0x48); // Bits 6 and 3 set
0x48 is the default value for ILI9341 (0xA8 for ESP32 M5STACK)
in rotation 0 orientation.
Another control register can be used to "invert" colours,
this swaps black and white as well as other colours (e.g.
green to magenta, red to cyan, blue to yellow).
To invert colours insert this line after tft.init() or tft.begin():
tft.invertDisplay( invert ); // Where invert is true or false
*/
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
void setup(void) {
tft.init();
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
// Set "cursor" at top left corner of display (0,0) and select font 4
tft.setCursor(0, 4, 4);
// Set the font colour to be white with a black background
tft.setTextColor(TFT_WHITE);
// We can now plot text on screen using the "print" class
tft.println(" Initialised default\n");
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
}
void loop() {
tft.invertDisplay( false ); // Where i is true or false
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
tft.setCursor(0, 4, 4);
tft.setTextColor(TFT_WHITE);
tft.println(" Invert OFF\n");
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
// Binary inversion of colours
tft.invertDisplay( true ); // Where i is true or false
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
tft.setCursor(0, 4, 4);
tft.setTextColor(TFT_WHITE);
tft.println(" Invert ON\n");
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
}
Edit you post and put it in code tags. Then I will look at it.
You might have to do a Tools/Auto Format first, let's see what it looks like.
// Animates white pixels to simulate flying through a star field
// updated 2020-11-09 for 135x240 TFT display of TTGO T-Display
#include <SPI.h>
#include <TFT_eSPI.h>
// Use hardware SPI
TFT_eSPI tft = TFT_eSPI();
int16_t h = 135;
int16_t w = 240;
// With 1024 stars the update rate is ~65 frames per second
#define NSTARS 1024
uint8_t sx[NSTARS] = {};
uint8_t sy[NSTARS] = {};
uint8_t sz[NSTARS] = {};
uint8_t za, zb, zc, zx;
// Fast 0-255 random number generator from http://eternityforest.com/Projects/rng.php:
uint8_t __attribute__((always_inline)) rng() {
zx++;
za = (za ^ zc ^ zx);
zb = (zb + za);
zc = ((zc + (zb >> 1)) ^ za);
return zc;
}
void setup() {
za = random(256);
zb = random(256);
zc = random(256);
zx = random(256);
Serial.begin(115200);
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
// fastSetup() must be used immediately before fastPixel() to prepare screen
// It must be called after any other graphics drawing function call if fastPixel()
// is to be called again
//tft.fastSetup(); // Prepare plot window range for fast pixel plotting
}
void loop() {
unsigned long t0 = micros();
uint8_t spawnDepthVariation = 255;
for (int i = 0; i < NSTARS; ++i) {
if (sz[i] <= 1) {
sx[i] = w / 2 - h / 2 + rng();
sy[i] = rng();
sz[i] = spawnDepthVariation--;
} else {
int old_screen_x = ((int)sx[i] - w / 2) * 256 / sz[i] + w / 2;
int old_screen_y = ((int)sy[i] - h / 2) * 256 / sz[i] + h / 2;
// This is a faster pixel drawing function for occassions where many single pixels must be drawn
tft.drawPixel(old_screen_x, old_screen_y, TFT_BLACK);
sz[i] -= 2;
if (sz[i] > 1) {
int screen_x = ((int)sx[i] - w / 2) * 256 / sz[i] + w / 2;
int screen_y = ((int)sy[i] - h / 2) * 256 / sz[i] + h / 2;
if (screen_x >= 0 && screen_y >= 0 && screen_x < 320 && screen_y < 240) {
uint8_t r, g, b;
r = g = b = 255 - sz[i];
tft.drawPixel(screen_x, screen_y, tft.color565(r, g, b));
} else
sz[i] = 0; // Out of screen, die.
}
}
}
unsigned long t1 = micros();
//static char timeMicros[8] = {};
// Calcualte frames per second
Serial.println(1.0 / ((t1 - t0) / 1000000.0));
}
Edit that sketch and add some Serial.println( debug msg here ); The first one should be after the Serial.begin, the next after the tft.init
Add a delay(2000); after the Serial.begin and before the debug.
already tired debug it doesnt do anything all serial messages didnt show up
Hi @abi11453.
I'm not sure I understood correctly what you mean by this. Please provide a more detailed description of what you mean by this in a reply on this forum topic to help us to understand it. Make sure to include the following information:
- What did you do?
- What were the results you expected from doing that thing?
- What were the results you observed that did not match your expectations?
Just to verify. The code is uploaded, but pressing the reset button afterwards also doesn't make it run ?
Ok something in your code (possibly icw the core version) or your wiring causes the ESP to crash.
So :
- What core version have you used (consider rolling back a bit as 3rd party libraries may not be on par just yet)
- What is your board selection
- What is you actual board and how have you connected it
Can you probably add a video of the Serial Monitor after the upload? That's the usual message after uploading to ESP32. You might be looking at the incorrect baud rate in Serial Monitor.
Did you add some capacitor in the EN pin for automatic download mode? I have experienced this stuck previously when I tried adding a CAP because pushing the boot button every upload is just so inefficient. So I removed that cap and reverted to manual download mode and it resolved mine.