sukesh-ak / ESP32-LVGL8x-SDSPI

ESP32 / ESP32-S3 with LVGL widgets using LovyanGFX + SD SPI working with multiple display size support
MIT License
40 stars 10 forks source link

trying to get LVGL8.X + LOVYANGFX + SD card with ESP32 S3 up and running ( VSC-PlatformIO-Arduino ) #5

Closed Pepito-design closed 7 months ago

Pepito-design commented 7 months ago

Hi, I'm trying to get all together up and running. Bord: ESP32 S3 N16R8 Display: 3.5"TFT 320x480 V2.2 / ILI9488 FT6236 / SD card socket LovyanGFX version=1.1.12 lvgl version=8.3.11 Environment: VSC-PlatformIO-Arduino ( latest version )

Hardware connections ( PCB, soldered, no breadboard ) CS_LCD = GPIO_10

  cfg.pin_sclk = 12;            // SPIのSCLK
  cfg.pin_mosi = 11;            // SPIのMOSI
  cfg.pin_miso = 13;            // SPIのMISO
  cfg.pin_dc   = 41;            // SPIのD/C (-1 = disable)

  cfg.i2c_port = 1;
  cfg.i2c_addr = 0x38;
  cfg.pin_sda  = 38;
  cfg.pin_scl  = 39;
  cfg.pin_cs   = -1;
  cfg.freq     = 200000;

  cfg.bus_shared       =  true;

CS_SD card = GPIO_47

Status: LCD and touch are working fine. SD card is connected on same SPI, CS is separated on GPIO 47.

With oscilloscope ( THS730A ) I can see activities on GPIO 47, and SPI bus. But it fails to mount the SD card ( 3.3V power is there, can't find any diode in CS_LCD, so I expect, there is no conflict with MISO. I tried out a 3 wire SPI to LCD without MISO connected to LCD, LCD still works fine, SD card doesn't work.

Think there is something else wrong and I spent already x nights without any success. If I use the SD card alone in minimized testcase with SdFat.h, the card works fine ( same SPI connections, without LCD connected ).. BTW, finally I have to use exFAT with 64GB SD card.

Question: Is there an existing example / template available for VSC-PlatformIO-Arduino and ESP32 S3?

May be it is also a good solution, to use SPI3 for the SD card instead shared SPI ....

Thanks in advance for any useful hint

sukesh-ak commented 7 months ago

If SPI bus is same for display & sd card, configure cs pin for LovyanGFX and set shared to true.

After that use sd card without again initialising the bus.

Demo code is there in my ESP32-TUX project.

Pepito-design commented 7 months ago

Thank you very much for fast response on sunday :-) shared is set to true and I can see ( oscilloscope ) that the CS do not overlap. But MiSO is on low, all the time. Pull-up ( 2.2k ) did not help.

Pepito-design commented 7 months ago

Hi, still hanging, think there is something missing. CS, SCK and MOSI are visible at the SD card. MISO is low. But the SD card works fine with reduced SdFat example. Format is exFAT, but other SD card with FAT32 doesn't respond also. my setup() .... .... lv_init(); // Bedienoberfläche initialisieren Serial.println("lv_init erledigt"); lv_disp_draw_buf_init( &draw_buf, buf, NULL, screenWidth * 10 );

static lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); Serial.println("Display Init erledigt"); // * Bildschirmparameter übergeben **** disp_drv.hor_res = screenWidth; disp_drv.ver_res = screenHeight; disp_drv.flush_cb = my_disp_flush; disp_drv.draw_buf = &draw_buf; lv_disp_drv_register(&disp_drv); Serial.println("Display Parameter gesetzt"); // * Initialisierung vom (dummy) input Device Treiber static lv_indev_drv_t indev_drv; lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.read_cb = my_touchpad_read; lv_indev_drv_register(&indev_drv); gpio_pullup_en(GPIO_NUM_47); if (tft.getStartCount() > 0) { // Free the bus before accessing the SD card tft.endWrite(); } // LCD + touch are working fine

SD.end();
delay(1000);

if ( SD.begin(SDCARD_SS_PIN, 2500000))
     // Something to manipulate the SD card.
 {
  Serial.println("Mount SD ok");
 }
else
 {
  Serial.println ("Mount SD not ok"); 
 }
lv_fs_open(file, "/file", LV_FS_MODE_WR);
if ( file )
 {
  Serial.println("Open file ok");
  lv_fs_close(file);
 }
 else
  {
   Serial.println("cannot open file"); 
  }
sukesh-ak commented 7 months ago

Your LovyanGFX config show’s display CS pin set to -1.

sukesh-ak commented 7 months ago

@Pepito-design Just curious. Did changing the CS pin work?