-->
Page 1 of 1

How to use the SPI Overlap mode

PostPosted: Tue Jul 23, 2019 9:22 am
by zMoo
Hi!
I'm trying to use the SPI overlap mode that is now available on Esp/Arduino (here is the little documentation about the implementation and the new SPI.pins() function : https://arduino-esp8266.readthedocs.io/ ... I.pins#spi).

Here is a little sketch that implement a little initialization test for the SSD1306 OLED display. It just activates the inverse mode and switch the display ON, so every pixels become activated.
The sketch works in normal HSPI mode (with pins SCK=14, MOSI=13, CS=0, for example) but, I can not make it working in Overlap mode (with pins SCK=14, MOSI=13, CS=0).

Code: Select all#include <SPI.h>

#define CMD_DISPLAY_OFF 0xAE
#define CMD_DISPLAY_ON 0xAF
#define CMD_CHARGE_PUMP 0x8D
#define CMD_INVERSE_DISPLAY 0xA7

#define PIN_DC 5
#define PIN_RST 4

//#define SPI_OVERLAP
#ifdef SPI_OVERLAP
   #define PIN_SCK 6
   #define PIN_MOSI 7
   #define PIN_MISO 8 //Unused
   #define PIN_CS 0
#else
   #define PIN_SCK 14
   #define PIN_MOSI 13
   #define PIN_MISO 12 //Unused
   #define PIN_CS 0
#endif

#define MODE_DATA HIGH
#define MODE_CMD LOW

void setup() {
   pinMode(PIN_DC, OUTPUT);
   pinMode(PIN_RST, OUTPUT);
   #ifndef SPI_OVERLAP
      pinMode(PIN_CS, OUTPUT);
   #endif

   digitalWrite(PIN_RST, LOW);
   delay(3);
   digitalWrite(PIN_RST, HIGH);
   
   SPI.pins(PIN_SCK, PIN_MISO, PIN_MOSI, PIN_CS);
   SPI.begin();
   
   uint8_t buffer[] = {
      CMD_DISPLAY_OFF,
      CMD_CHARGE_PUMP, 0x14,
      CMD_INVERSE_DISPLAY,
      CMD_DISPLAY_ON
   };

   digitalWrite(PIN_DC, MODE_CMD);
   #ifndef SPI_OVERLAP
      digitalWrite(PIN_CS, LOW);
   #endif

   SPISettings settings(1000000, MSBFIRST, SPI_MODE0);
   SPI.beginTransaction(settings);
   SPI.transfer(&buffer[0], sizeof(buffer));

   
   #ifndef SPI_OVERLAP
      digitalWrite(PIN_CS, HIGH);
   #endif
}

void loop() {
}


Does anyone have experience about the SPI overlap mode?
Regards,

Re: How to use the SPI Overlap mode

PostPosted: Fri Jun 03, 2022 7:14 am
by eriksl
I am not sure if it's still relevant, but in the meantime I've gathered some experience there. I still have some questions too, though. Not using Arduino though, plain NONOS SDK.