Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ERC240160 in ESP32S3 SPI HW mode does not work #2437

Open
sebastianmach opened this issue Apr 29, 2024 · 1 comment
Open

Using ERC240160 in ESP32S3 SPI HW mode does not work #2437

sebastianmach opened this issue Apr 29, 2024 · 1 comment

Comments

@sebastianmach
Copy link

sebastianmach commented Apr 29, 2024

I'm trying to use an ERC240160 on an ESP32S3 using SPI in Hardware mode because in Software mode it takes ~1s to update the display which is too slow for my purpose.

Using u8g2 in SW mode works flawlessly, but in HW mode it doesn't.
I've already tried all sorts of things and boiled it down to the most basic code base for testing.

Using a digital analyser, the SPI signals in HW mode look quite strange, I've attached some examples down below. I've also tried using pure SPI sending basic bytes and that looked fine on the digital analyser. For my board, I'm using alternative SPI pins, but using the default SPI pins does not change anything about the behaviour.

This is the code I'm trying to run. Setting USE_HW_SPI to 0 (in order to use SW mode) works fine, but setting it to 1 (in order to use HW mode) stops working (the display stays blank):

#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>

const int pin_config_spi_clk = 18;
const int pin_config_spi_mosi = 17;
const int pin_config_display_cs = 15;
const int pin_config_display_reset = 16;

#define USE_HW_SPI 1

void setup()
{
    Serial.begin(9600);
    Serial.println("SETUP");
    delay(1000);

#if USE_HW_SPI
    // HW mode does not work

    SPI.begin(pin_config_spi_clk, MISO, pin_config_spi_mosi, SS);  // Set custom CLK and MOSI pins

    U8G2_ST7586S_ERC240160_F_3W_HW_SPI *u8g2 = new U8G2_ST7586S_ERC240160_F_3W_HW_SPI(
        U8G2_R2, /* rotation */
        pin_config_display_cs, /* chip_select*/
        pin_config_display_reset /* reset*/
    );
#else
    // SW mode works fine

    U8G2_ST7586S_ERC240160_F_3W_SW_SPI *u8g2 = new U8G2_ST7586S_ERC240160_F_3W_SW_SPI(
        U8G2_R2, /* rotation */ 
        pin_config_spi_clk, /* clock */
        pin_config_spi_mosi, /* data*/
        pin_config_display_cs, /* chip_select*/
        pin_config_display_reset /* reset*/
    );
#endif

    u8g2->begin();
    u8g2->setFont(u8g2_font_fub11_tr);
    u8g2->drawStr(20, 20, "TEST");
    u8g2->drawStr(120, 120, "TEST");
    u8g2->sendBuffer();
}

void loop()
{
    Serial.print("LOOP");
    delay(100);
}

Logic analyser output for USE_HW_SPI 1:

image

Logic analyser output for USE_HW_SPI 0:

image

Observation

I've noticed that the data transferred in HW and SPI mode differ. HW mode starts with 0x00, 0x84, 0x45, ... while SW mode starts with 0x60, 0x4D, 0xA0, ...

I've also confirmed SPI is working in general using this code and same Digital Analyser setup:

#include <Arduino.h>
#include <SPI.h>

const int pin_config_spi_clk = 18;
const int pin_config_spi_mosi = 17;
const int pin_config_display_cs = 15;
const int pin_config_display_reset = 16;

void setup()
{
    Serial.begin(9600);
    Serial.println("SETUP");
    delay(1000);

    SPI.begin(pin_config_spi_clk, MISO, pin_config_spi_mosi, SS);
    SPI.transfer(0x00);
    delay(10);
    SPI.transfer(0x01);
    delay(10);
    SPI.transfer(0x02);
    delay(10);
    SPI.transfer(0x03);
}

void loop()
{
    Serial.print("LOOP");
    delay(100);
}
image

Ask for help

I can't rule out I'm doing something wrong, any support pointing me into the right direction is much apprechiated!

@olikraus
Copy link
Owner

3-wire mode has not been tested so much. I personally would suggest to use 4-wire mode. It will be also much faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants