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

Recent Port of Code from ESP32-C3 to ESP32-S3 Has Issues #2251

Open
Fishbone69 opened this issue Aug 27, 2023 · 11 comments
Open

Recent Port of Code from ESP32-C3 to ESP32-S3 Has Issues #2251

Fishbone69 opened this issue Aug 27, 2023 · 11 comments

Comments

@Fishbone69
Copy link

Ollie:
I took that digital watch code I showed you and tried to port it to WEMOS Lolin ESP32-S3 mini controller and the display was a garbled mess. So I Started a new project and only ran the GraphicsTest.ino that comes with U8g2. It was also a garbled mess. I am using the following constructor:
U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=/ 10, / DC=/ 13, / reset=*/ 43);

I have checked to make sure all of the pins are correct -
CLK=12
MOSI=11
MISO=DC=13 (see constructor)
CS=10

Have you had any other issues with this board or with esp32-s3 in general? I checked the pins.arduino.h file as well and the default pins seem to match.

Any help is appreciated.

Fish

@Fishbone69
Copy link
Author

Fishbone69 commented Aug 27, 2023


Follow-up


I tried a different constructor for a "similar" display but one that specifies the clock and data through SW SPI:
U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=/ 12, / data=/ 11, / cs=/ 10, / dc=/ 13, / reset=*/ 43);

This produces a somewhat correct display - but "wraps" by 3 or 4 pixels. Also the graphics are VERY slow. I am going to do more digging. This seems to me like there may be an issue with the default hardware spi pins for this board.


Follow-up


I went into setup and had the board print the default SPI pins. I got:
MOSI: 11
MISO: 13
SCK: 12
SS: 10

This seems to match the above and also matches the datasheet for the esp32-S3.
How does U8g2 select the default pins? Is there a way to print to the serial monitor the pins that U8g2 is using? Also, esp32-s3 has 4 SPI modes (modes 0,1,2,3) while the esp32-c3 only has 3 (modes 0,1,2). Both should be using mode 2. Could u8g2 be selecting mode 3?

@Fishbone69
Copy link
Author

Fishbone69 commented Aug 29, 2023


Follow-up


Tried a different esp32-s3 mini microcontroller (same brand) - screen still garbled.
Tried a different SH1106 display - screen still garbled.
The fact that the software SPI constructor for SSD1306 worked is the key.

@olikraus
Copy link
Owner

U8g2 will use the default pins from the Arduino Environment: Same pins as SPI object would use.

@Fishbone69
Copy link
Author

Fishbone69 commented Aug 29, 2023

Another difference between the esp32-S3 and C3 is the cpu clock speed (240MHz on the S3 vs 160 MHz on C3)...could that be relevant?

Note I set the cpu speed at 160 MHz on the S3 and still didn't work....very frustrating. I am at a loss. Is there a way for me to easily bypass the constructor logic and specify CLK and data gpios for 4 wire HW SPI?

@Fishbone69
Copy link
Author

Dumb question: Do I have to set pinMode for any of the SPI pins or does the constructor do that? I didn't have to do that before...reaching for straws.

@Fishbone69
Copy link
Author

20230829_170711
The black "band" is from the camera and is not visible.

@olikraus
Copy link
Owner

olikraus commented Aug 29, 2023

Dumb question: Do I have to set pinMode for any of the SPI pins or does the constructor do that? I didn't have to do that before...reaching for straws.

No, this is done by u8g2

The black "band" is from the camera and is not visible.

If the display shows up with some content, then at least some communication has happend. I assume there is a wiring issue. Especially check the A0 (=CD) wire.

In general: Avoid using such protoboards. They are very unreliable.

@Fishbone69
Copy link
Author

I understand but here it is with this constructor: U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=/ 12, / data=/ 11, / cs=/ 10, / dc=/ 13, / reset=*/ 43);
20230829_180204

It is not a SSD1306, but I have a hard time thinking this is wiring if I change the constructor and get these results.

@Fishbone69
Copy link
Author

I found the issue. It is not U8g2. This esp32-S3 dev board has an issue with GPIO13 being used for DC. It says on the datasheet this gpio13 is FSPIQ. Is this not typically MISO? I assumed that should be used for DC. In fact, U8x8lib.cpp has some comments where it looks like there is some confusion on the matter:

 /* ESP32 has the following begin: SPI.begin(int8_t sck=SCK, int8_t miso=MISO, int8_t mosi=MOSI, int8_t ss=-1); */
      /* not sure about ESP8266 */
      if ( u8x8->pins[U8X8_PIN_SPI_CLOCK] != U8X8_PIN_NONE && u8x8->pins[U8X8_PIN_SPI_DATA] != U8X8_PIN_NONE )
      {
	/* SPI.begin(int8_t sck=SCK, int8_t miso=MISO, int8_t mosi=MOSI, int8_t ss=-1); */
	/* actually MISO is not used, but what else could be used here??? */

At any rate, I changed this pin to any other in the constructor and it seems to work. I would like to know if in general MISO != DC or if it is just this DEV board? Maybe someone can shed some light. I recommend leave the status OPEN for comments.

Fish

@olikraus
Copy link
Owner

olikraus commented Aug 30, 2023

At any rate, I changed this pin to any other in the constructor and it seems to work. I would like to know if in general MISO != DC or if it is just this DEV board? Maybe someone can shed some light. I recommend leave the status OPEN for comments.

Like written in the comment, u8g2 does not require any information from the display. As a consequence the MISO input wire to the uC is not required. However some uC will occupy both MISO and MOSI pins once the hardware driven SPI is activated.
It is like this: You want hardware accelerated SPI with MOSI only, but you also get MISO pin occupied. As a consequence the DC pin can not be used on the MISO pin, they would distrub each other (DC = Data Command output line has nothing todo with MISO SPI line)
I can not speak for the ESP 32, but at least this is also true for AVR systems (Arduino R3), where we can not use pin 12 (which is the MISO pin on AVR systems).
Note: With software emulated SPI, this problem is bypassed and the pin can be used.

It is not a SSD1306

Indeed, it seems to be a SH1106

@Fishbone69
Copy link
Author

There are a couple of other pins used on the ESP32 in SPI...particularly for use of SPI with Flash memory like FSPIWP (write protect) and FSPIHD. Those do not seem to cause a conflict when used as DC output for the display...but I'm thinking if I have extra pins....maybe I avoid those as well?

Ollie - sorry to cause a fuss. Your explanation makes perfect sense and has been a real learning experience for me.

Thank you for all that you do!

Fish

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