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:
Logic analyser output for USE_HW_SPI 0:
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:
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
to0
(in order to use SW mode) works fine, but setting it to1
(in order to use HW mode) stops working (the display stays blank):Logic analyser output for
USE_HW_SPI 1
:Logic analyser output for
USE_HW_SPI 0
: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 with0x60, 0x4D, 0xA0, ...
I've also confirmed SPI is working in general using this code and same Digital Analyser setup:
Ask for help
I can't rule out I'm doing something wrong, any support pointing me into the right direction is much apprechiated!