Hello Felix,
After reviewing everything, I have discovered that the issue lies in the initialization performed in the Arduino_ST7789 library. In the Arduino_ST7789.cpp file, SPI.begin(); is used when to utilize hardware SPI, it should be initialized with SPI.begin(TFT_SCLK, TFT_MISO, TFT_MOSI, TFT_CS);
"// Constructor when using hardware SPI. Faster, but must use SPI pins
// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
// Parece que solo vale para 4-wire. Adaptar a 3-wire.
Arduino_ST7789::Arduino_ST7789(int8_t dc, int8_t rst, int8_t cs)
: Adafruit_GFX(ST7789_TFTWIDTH, ST7789_TFTHEIGHT) {
_cs = cs;
_dc = dc;
_rst = rst;
_hwSPI = true; //THIS LINE APPLY HARDWARE SPI
_SPI9bit = false;
_sid = _sclk = -1;
}"
After call
"// Initialization code common to all ST7789 displays
void Arduino_ST7789::commonInit(const uint8_t *cmdList) {......."
in this part into
"if(_hwSPI)
{ // Using hardware SPI
#if defined (SPI_HAS_TRANSACTION)
//SPI.begin(); //THIS LINE IS BAD FOR HARDWARE INIT
SPI.begin(TFT_SCLK, TFT_MISO, TFT_MOSI, TFT_CS); // BY ME
mySPISettings = SPISettings(48000000, MSBFIRST, SPI_MODE2); // BY ME"
Always in the file.ino define pins:
"
#define TFT_MISO -1
#define TFT_MOSI 7
#define TFT_SCLK 6
#define TFT_CS 5
#define TFT_DC 4
#define TFT_RST 0
"
call with:
"Arduino_ST7789 tft = Arduino_ST7789(TFT_DC, TFT_RST, TFT_CS); //for display with CS pin // <--- MODO SPI HARDARE (4-wire)"
In summary... I think that It wasn't working because the SPI was not initialized with the pin parameters and Mode 2 (function 2 of the IO_MUX) that activates pins 4, 5, 6, 7 (see page 169 of the ESP32-C3 datasheet). In the schematic, it can be seen that M5stack associates the SPI with pins 19, 20, 21, 22, 23, 24 in Mode 0 (function 0 of the IO_MUX), which needs to be initialized correctly...
For drawing text or lines, etc., using Software SPI isn't a problem. However, if images, fillscreen();, or other graphical elements are displayed, then Hardware SPI is necessary (not necesary 48Mhz, i put in the code), or else everything will be very slow on the screen.
Schematic M5Stack Stamp C3:
https://docs.m5stack.com/en/core/stamp_c3
I am happy!! It works now!!.
Thank you for your time and attention.
Best regards,