ESP32 - SPI OLED and bit bang causing an issue

Evening all..

I am trying to run a SSD1322 OLED (using the U8g2 library) and a PGA2311 audio pre-amp IC on a ESP32.

The PGA2311 works fine but the issue is when I include the PGA2311's pinModes, it prevents the OLED from displaying anything. If I comment out the pinMode lines, the OLED works - but obviously the PGA2311 now doesn't.

I've enabled U8G2_16BIT in u8g2.h file.

My guess is something around the HW SPI and I've researched the hell out of this and tried a million different things but seem to be missing something.

Can anyone please point me in the right direction, even if it's what to read or research...

#include <U8g2lib.h>

//#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
//#endif
//#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
//#endif

// PGA2311 Pre Amp Pins
#define PGA_SCLK_PIN   18
#define PGA_CS_PIN     22
#define PGA_SDI_PIN    23

U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 14, /* reset=*/ 27);	// Enable U8G2_16BIT in u8g2.h

void setup(void) {
  u8g2.begin();

  //PGA2311 Pins
  pinMode(PGA_CS_PIN, OUTPUT); //initialize pins
  pinMode(PGA_SCLK_PIN, OUTPUT);
  pinMode(PGA_SDI_PIN, OUTPUT);
  digitalWrite(PGA_CS_PIN, HIGH);
  digitalWrite(PGA_SCLK_PIN, HIGH);
  digitalWrite(PGA_SDI_PIN, HIGH);
}

void loop(void) {
  u8g2.clearBuffer();					// clear the internal memory
  u8g2.setFont(u8g2_font_ncenB08_tr);	// choose a suitable font
  for (int i = 0; i < 200; i++) {
    u8g2.drawStr(i, 10, "Hello World!");	// write something to the internal memory
    u8g2.sendBuffer();					// transfer internal memory to the display
  }
}

SDI sounds to me like SPI Data INPUT.

1 Like

Hi DrDiettrich

Yes, SDI is the input for the PGA2311..

Here is my circuit:

CN1 goes to a connector on an external PCB that holds the PGA2311. The PGA's pins are brought out directly to that connector.

GPIO_NUM_22 is the natural SCL pin for I2C, GPIO_NUM_23 is the natural SPI_MOSI pin, GPIO_NUM_18 is the natural SPI SCK pin.

May I suggest using the ESP32's Arduino cores natural SPI and I2C pins?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.