TTGO-T-display + SD card
TTGO-T-display + SD card
GGTO-T-diplay use SPI for screen (ESP32 + IPS ST7789V 1.14")
SCLK = 18, MISO = 19, MOSI = 23, SS = 5... (VSPI)
Can I use an other SPI for SD module ? HSPI ?
How ?
+
SCLK = 18, MISO = 19, MOSI = 23, SS = 5... (VSPI)
Can I use an other SPI for SD module ? HSPI ?
How ?
+
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: TTGO-T-display + SD card
Yes. The SPI pins of both user SPI peripherals are freely remappable.
Re: TTGO-T-display + SD card
It is the first time that I have to use 2 SPI at the same time ...
I very often read that the ports are mappable on the esp32 but it is a very fuzzy concept for me ... Should we enter the libraries?
In addition not all ports are available on all ESP32 modules and most of the time they are never the same.
Code: Select all
#include <TFT_eSPI.h>
#include <SPI.h>
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
#define TFT_BL 4
#include <SD.h>
SPIClass spiSD(HSPI);
#define SD_CS 13
#define SDSPEED 16000000
// Set SD Card SPI
spiSD.begin(?,?,?,?);//SCK,MISO,MOSI,CS
if(!SD.begin( SD_CS, spiSD, SDSPEED)){ // use only 12, 13, 14, 15 ou 25 26 if possible
Serial.println("Card Mount Failed");
return;
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: TTGO-T-display + SD card
From a technical PoV, the 'all ports are freely remappable' statement is exactly that: for most peripherals (UART, SD, I2C, I2S, ...) you can pick the GPIO the signals are routed from/to using the GPIO matrix. How that's implemented obviously depends. Also, not all ports make sense to map to: you don't want to repurpose your GPIOs that are connected to the internal flash, you can only use GPIO34 and higher as inputs, not outputs, and obviously if your board connects something else to the GPIO that you're routing to as well, that may interfere.
Re: TTGO-T-display + SD card
Test :
insults at download
is pin 12 the cause ?
I don't understand very well " Also, not all ports make sense to map to: you don't want to repurpose your GPIOs that are connected to the internal flash, you can only use GPIO34 and higher as inputs, not outputs"
Which pin to take for example ?
Code: Select all
#include <TFT_eSPI.h>
#include <SPI.h>
#include "WiFi.h"
#include <Wire.h>
#ifndef TFT_DISPOFF
#define TFT_DISPOFF 0x28
#endif
#ifndef TFT_SLPIN
#define TFT_SLPIN 0x10
#endif
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
#define TFT_BL 4 // Display backlight control pin
#define ADC_EN 14
#define ADC_PIN 34 // prise du voltage
#define BUTTON_1 35
#define BUTTON_2 0
TFT_eSPI tft = TFT_eSPI(135, 240); // Invoke custom library
Button2 btn1(BUTTON_1); // bouton de gauche
Button2 btn2(BUTTON_2);
#include "FS.h"
#include "SD.h"
#include "SPI.h"
SPIClass spiSD(HSPI);
#define SD_CS 13
#define SDSPEED 27000000
ch
void setup()
{
Serial.begin(115200);
spiSD.begin(13,12,15,2); //SCK,MISO,MOSI,ss
if(!SD.begin( SD_CS, spiSD, SDSPEED))
{ Serial.println("Card Mount Failed");
return; }
Code: Select all
Arduino : 1.8.10 (Windows 10), Carte : "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
Le croquis utilise 730810 octets (55%) de l'espace de stockage de programmes. Le maximum est de 1310720 octets.
Les variables globales utilisent 40552 octets (12%) de mémoire dynamique, ce qui laisse 287128 octets pour les variables locales. Le maximum est de 327680 octets.
esptool.py v2.6
Serial port COM8
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 24:6f:28:25:4c:68
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
Compressed 8192 bytes to 47...
A fatal error occurred: Timed out waiting for packet content
A fatal error occurred: Timed out waiting for packet content
Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.
I don't understand very well " Also, not all ports make sense to map to: you don't want to repurpose your GPIOs that are connected to the internal flash, you can only use GPIO34 and higher as inputs, not outputs"
Which pin to take for example ?
Re: TTGO-T-display + SD card
With and
I have SD ok...
Code: Select all
pinMode(2, OUTPUT);
Code: Select all
spiSD.begin(13,26,15,2); //SCK,MISO,MOSI,ss
if(!SD.begin( SD_CS, spiSD, SDSPEED))
{ Serial.println("Card Mount Failed");
return; }
else Serial.println("SD ok");
Re: TTGO-T-display + SD card
If I add
SD ok
initialization done.
error opening test.txt
error opening test.txt
Code: Select all
File myFile;
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile)
{ Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
myFile.close();
Serial.println("done."); }
else Serial.println("error opening test.txt");
myFile = SD.open("test.txt");
if (myFile)
{ Serial.println("test.txt:");
while (myFile.available())
{ Serial.write(myFile.read()); }
myFile.close(); }
else Serial.println("error opening test.txt");
SD ok
initialization done.
error opening test.txt
error opening test.txt
Re: TTGO-T-display + SD card
All is OK if use the sample SD-test of library SD for esp32
-
- Posts: 3
- Joined: Sun Feb 16, 2020 6:51 pm
Re: TTGO-T-display + SD card
Hi! Can you help me, please, with sample code
I have the same board and trying to use SD card via HSPI - nothing works
Thanx in advance
I have the same board and trying to use SD card via HSPI - nothing works
Thanx in advance
Re: TTGO-T-display + SD card
Hi,
My program is now well developed and extract that the part for the sd is complex.
It will be easier to correct your code
My program is now well developed and extract that the part for the sd is complex.
It will be easier to correct your code
Who is online
Users browsing this forum: No registered users and 13 guests