2025-07-30 1:53 AM
Hello,
I want to interface NHD-2.7-12864WDW3 OLED display with STM32H755 Nucleo and show some data in display
-4 wire SPI-. I had connected all OLED pins to STM32 correctly and than tried to flash this code (that I've attached). But i did not get any output, OLED display did not even glow.
I dont know where i am doing wrong, can you help me on this regard?
Pin 1 (VSS) → GND
Pin 2 (VDD) → +3.3 V
Pin 3 (NC / BC_VDD) → no connection
Pin 4 (D/C) → PA9 (GPIO Output)
Pin 5 (VSS) → GND
Pin 6 (VSS) → GND
Pin 7 (SCLK) → PB13 (SPI2_SCK, AF5)
Pin 8 (SDIN) → PB15 (SPI2_MOSI, AF5)
Pin 9 (NC) → no connection
Pin 10 (VSS) → GND
Pin 11 (VSS) → GND
Pin 12 (VSS) → GND
Pin 13 (VSS) → GND
Pin 14 (VSS) → GND
Pin 15 (NC / VCC sense) → no connection
Pin 16 (/RES) → PA10 (GPIO Output, active LOW reset)
Pin 17 (/CS) → PB2 (GPIO Output, active LOW chip‑select)
Pin 18 (/SHDN) → +3.3 V
Pin 19 (BS1) → GND (BS[1:0]=00 → 4‑wire SPI)
Pin 20 (BS1) → GND (BS[1:0]=00 → 4‑wire SPI)
Note: The pins seen as short circuit in the photo are GND pins.
Solved! Go to Solution.
2025-07-31 4:24 AM
I solved the problem, the problem was in the software. I am sharing the sample code. although not without problems, at least it gives an idea.
/* oled_ssd1322.h */
#ifndef OLED_SSD1322_H
#define OLED_SSD1322_H
#include "stm32h7xx_hal.h"
extern const uint8_t NHD_Logo[];
/* CubeMX ile üretilen SPI2 handle */
extern SPI_HandleTypeDef hspi2;
/* Kontrol pinleri */
#define SSD1322_DC_Port GPIOA
#define SSD1322_DC_Pin GPIO_PIN_9
#define SSD1322_RST_Port GPIOA
#define SSD1322_RST_Pin GPIO_PIN_10
#define SSD1322_CS_Port GPIOB
#define SSD1322_CS_Pin GPIO_PIN_2
/* Fonksiyon prototipleri */
void SSD1322_Init(void);
void SSD1322_Clear(void);
void SSD1322_FillCheckerboard(void);
void SSD1322_DisplayImage(const uint8_t *img);
void SSD1322_SetColumn(uint8_t start, uint8_t end);
void SSD1322_SetRow(uint8_t start, uint8_t end);
#endif /* OLED_SSD1322_H */
/* oled_ssd1322.c */
#include "oled_ssd1322.h"
/* Eğer logonuz büyükse, buraya extern olarak alın */
extern const uint8_t NHD_Logo[];
/* D/C#, CS# hızlı kontrol için inline */
static inline void CS_LOW (void) { HAL_GPIO_WritePin(SSD1322_CS_Port, SSD1322_CS_Pin, GPIO_PIN_RESET); }
static inline void CS_HIGH(void) { HAL_GPIO_WritePin(SSD1322_CS_Port, SSD1322_CS_Pin, GPIO_PIN_SET); }
static inline void DC_CMD (void) { HAL_GPIO_WritePin(SSD1322_DC_Port, SSD1322_DC_Pin, GPIO_PIN_RESET); }
static inline void DC_DAT (void) { HAL_GPIO_WritePin(SSD1322_DC_Port, SSD1322_DC_Pin, GPIO_PIN_SET); }
/* 8-bit komut gönderme */
static void SSD1322_Command(uint8_t cmd)
{
DC_CMD();
CS_LOW();
HAL_SPI_Transmit(&hspi2, &cmd, 1, HAL_MAX_DELAY);
CS_HIGH();
}
/* Veri bloğu gönderme */
static void SSD1322_Data(const uint8_t *buf, uint16_t len)
{
DC_DAT();
CS_LOW();
HAL_SPI_Transmit(&hspi2, (uint8_t*)buf, len, HAL_MAX_DELAY);
CS_HIGH();
}
/* /RST ile ~150 ms’lik reset palsi */
static void SSD1322_Reset(void)
{
HAL_GPIO_WritePin(SSD1322_RST_Port, SSD1322_RST_Pin, GPIO_PIN_RESET);
HAL_Delay(150);
HAL_GPIO_WritePin(SSD1322_RST_Port, SSD1322_RST_Pin, GPIO_PIN_SET);
HAL_Delay(150);
}
/* Kolon adres aralığı ayarı (0x15) */
void SSD1322_SetColumn(uint8_t a, uint8_t b)
{
SSD1322_Command(0x15);
SSD1322_Data((uint8_t[]){a, b}, 2);
}
/* Satır adres aralığı ayarı (0x75) */
void SSD1322_SetRow(uint8_t a, uint8_t b)
{
SSD1322_Command(0x75);
SSD1322_Data((uint8_t[]){a, b}, 2);
}
/* Write RAM komutu (0x5C) */
static void SSD1322_WriteRam(void)
{
SSD1322_Command(0x5C);
}
/* — Düzeltilmiş init sekansı — */
void SSD1322_Init(void)
{
SSD1322_Reset();
SSD1322_Command(0xAE); // Display OFF
SSD1322_Command(0xFD); SSD1322_Data((uint8_t[]){0x12},1); // Command Lock
SSD1322_Command(0xB3); SSD1322_Data((uint8_t[]){0x91},1); // Display Clock
SSD1322_Command(0xCA); SSD1322_Data((uint8_t[]){0x3F},1); // MUX Ratio
SSD1322_Command(0xA2); SSD1322_Data((uint8_t[]){0x00},1); // Display Offset
SSD1322_Command(0xAB); SSD1322_Data((uint8_t[]){0x01},1); // Function Select
SSD1322_Command(0xA1); SSD1322_Data((uint8_t[]){0x00},1); // Start Line
SSD1322_Command(0xA0);
SSD1322_Data((uint8_t[]){0x16,0x11},2); // Remap
SSD1322_Command(0xC7); SSD1322_Data((uint8_t[]){0x0F},1); // Master Contrast
SSD1322_Command(0xC1); SSD1322_Data((uint8_t[]){0x9F},1); // Contrast
SSD1322_Command(0xB1); SSD1322_Data((uint8_t[]){0x72},1); // Phase Length
SSD1322_Command(0xBB); SSD1322_Data((uint8_t[]){0x1F},1); // Precharge Voltage
SSD1322_Command(0xB4); SSD1322_Data((uint8_t[]){0xA0,0xFD},2);// External VSL
SSD1322_Command(0xBE); SSD1322_Data((uint8_t[]){0x04},1); // VCOMH
SSD1322_Command(0xA6); // Normal Display
SSD1322_Command(0xA9); // Exit Partial
SSD1322_Command(0xD1); SSD1322_Data((uint8_t[]){0xA2,0x20},2); // Display Enhancement
SSD1322_Command(0xB5); SSD1322_Data((uint8_t[]){0x00},1); // GPIO
SSD1322_Command(0xB9); // Default Grayscale
SSD1322_Command(0xB6); SSD1322_Data((uint8_t[]){0x08},1); // 2nd Precharge
SSD1322_Command(0xAF); // Display ON
}
/* Ekranı tamamen siyaha boyar */
void SSD1322_Clear(void)
{
SSD1322_SetColumn(0x1C,0x5B);
SSD1322_SetRow (0x00,0x3F);
SSD1322_WriteRam();
uint8_t z = 0x00;
for (int y=0; y<64; y++)
for (int x=0; x<64; x++)
SSD1322_Data(&z,1);
}
/* Satranç tahtası doldurma örneği */
void SSD1322_FillCheckerboard(void)
{
SSD1322_SetColumn(0x1C,0x5B);
SSD1322_SetRow (0x00,0x3F);
SSD1322_WriteRam();
uint8_t p=0xFF,q=0x00;
for (int i=0; i<32; i++){
for (int j=0; j<64; j++){
SSD1322_Data((j&1)?&q:&p,1);
SSD1322_Data((j&1)?&p:&q,1);
}
}
}
/* Arduino’dan gelen logo verisini gösterir */
void SSD1322_DisplayImage(const uint8_t *img)
{
SSD1322_SetColumn(0x1C,0x5B);
SSD1322_SetRow (0x00,0x3F);
SSD1322_WriteRam();
for (int i=0; i<64*16; i++, img++){
uint8_t b = *img;
for (int sh=6; sh>=0; sh-=2){
uint8_t px = (b >> sh) & 0x03;
uint8_t out = (px==3?0xFF: px==2?0xF0: px==1?0x0F:0x00);
SSD1322_Data(&out,1);
SSD1322_Data(&out,1);
}
}
}
2025-07-30 3:51 AM - last edited on 2025-07-30 3:57 AM by Andrew Neil
Hello,
I want to interface NHD-2.7-12864WDW3 OLED display with STM32H755 Nucleo and show some data in display
-4 wire SPI-. I had connected all OLED pins to STM32 correctly and than tried to flash this code (that I've attached). But i did not get any output, OLED display did not even glow.
I dont know where i am doing wrong, can you help me on this regard?
Pin 1 (VSS) → GND
Pin 2 (VDD) → +3.3 V
Pin 3 (NC / BC_VDD) → no connection
Pin 4 (D/C) → PA9 (GPIO Output)
Pin 5 (VSS) → GND
Pin 6 (VSS) → GND
Pin 7 (SCLK) → PB13 (SPI2_SCK, AF5)
Pin 8 (SDIN) → PB15 (SPI2_MOSI, AF5)
Pin 9 (NC) → no connection
Pin 10 (VSS) → GND
Pin 11 (VSS) → GND
Pin 12 (VSS) → GND
Pin 13 (VSS) → GND
Pin 14 (VSS) → GND
Pin 15 (NC / VCC sense) → no connection
Pin 16 (/RES) → PA10 (GPIO Output, active LOW reset)
Pin 17 (/CS) → PB2 (GPIO Output, active LOW chip‑select)
Pin 18 (/SHDN) → +3.3 V
Pin 19 (BS1) → GND (BS[1:0]=00 → 4‑wire SPI)
Pin 20 (BS1) → GND (BS[1:0]=00 → 4‑wire SPI)
Note: The pins seen as short circuit in the photo are GND pins.
2025-07-30 4:05 AM
I've changed data size from 4 bit to 8 bit but the result is same :(
2025-07-30 4:05 AM
I've changed data size from 4 bit to 8 bit but the result is same :(
2025-07-30 5:02 AM
Please don't poste duplicate threads.
Unable to Drive SSD1322 (NHD‑2.7‑12864WDW3) OLED M... - STMicroelectronics Community
2025-07-30 5:05 AM
Okay, I'll be more careful.
2025-07-30 6:11 AM - last edited on 2025-07-30 10:43 AM by Tesla DeLorean
Is there anybody who has an idea about it?
2025-07-30 12:24 PM - edited 2025-07-30 12:25 PM
I think you need to work with New Haven, and perhaps get a scope or analyzer on the signals.
I'd probably double check that the SPI Transmit completes before pulling the Chip Select High again. Need to make sure the last bit crosses the wire, I think SPI TransmitReceive function achieves that, whereas TXE is more relative to the first bit over the wire. Is there a BUSY or TC bit you can spin on?
>>I've changed data size from 4 bit to 8 bit but the result is same
Ok, what does that actually mean? SPI should be sending 8-bit bytes a bit at a time. You're not using the parallel modes.
I've tended to use I2C for my SSD13xx OLED displays, I don't have any SSD1322 3.12" panels to work with. It would cost time and materials for me to demonstrate a workable solution.
2025-07-30 12:46 PM
Thanks for answer @Tesla DeLorean
But
The SSD1322 controller does not support I²C natively—it only offers 4-wire SPI, 3-wire SPI, or 8-bit parallel interfaces. To use it over I²C you’d need an external I²C-to-SPI bridge (e.g. NXP SC18IS602), which adds hardware complexity and may reduce performance.
2025-07-30 1:15 PM
The 3-wire SPI mode uses 9-bit
I think my primary point was that you need to get the timing and completion of the SPI 4-wire mode correct, so the placement of C/D and -CS with respect to the data going out on the wire.
You could help do this with the SPI TransmitReceive method with a scratch buffer for the "returned" data, but this would at least ensure the function didn't return until AFTER the last transmit bit has crossed the wire. Otherwise you need to pay attention to the Transmit Complete for the last byte being sent.