Forum: µC & Digital Electronics Need help running SSD1322 with ER-OLEDM032-1 OLED

von Alex Lynchosky (Guest)

Rate this post
0 useful
not useful
Here is the code I am using to initialize the OLED, per the instructions 
in the data sheet. I am using the 3-wire SPI configuration, and I have 
set BS0 and BS1 correctly.

For reference, here is the exact OLED I bought:


And here is my code:

void Initial(void) {
    timer_delay(5); /* in miliseconds */

    Write_Command(0xA6); /* All off or normal, Data sheet is inconsitent 

    Write_Command(0xFD); /*SET COMMAND LOCK*/
    Write_Data(0x12); /* UNLOCK */
    Write_Command(0xAE); /*DISPLAY OFF*/
    Write_Command(0xCA); /*multiplex ratio*/
    Write_Data(0x3F); /*duty = 1/64*/
    Write_Command(0xA2); /*set offset*/
    Write_Command(0xA1); /*start line*/
    Write_Command(0xA0); /*set remap*/
    Write_Command(0xB5); /* Set GPIO */
    Write_Command(0xAB); /* Funtion selection */
    Write_Data(0x01); /* Selection external vdd */
    Write_Command(0xB4); /* Enable External VSL */
    Write_Command(0xC1); /* Set contrast current */
    Write_Command(0xC7); /* Master contrast current control*/
    Write_Command(0xB9); /* Select default linear grey scale table */
    Write_Command(0xB1); /* SET PHASE LENGTH */
    Write_Command(0xD1); /*Enhance driving scheme capability*/
    Write_Command(0xBB); /*SET PRE-CHANGE VOLTAGE*/
    Write_Command(0xB6); /*SET SECOND PRE-CHARGE PERIOD*/
    Write_Command(0xBE); /* SET VCOMH */
    Write_Command(0xA4); /* normal display or all off, not sure which */
    Write_Command(0xAF); /*display ON*/

void Write_Command(unsigned char cmd) {
    uint16_t new_cmd = 0x0000; /* 9th bit = 0 for sending command */
    new_cmd |= cmd;

void Write_Data(unsigned char dat) {
    uint16_t new_data = 0x0100; /* 9th bit = 1 for sending data */
    new_data |= dat;

void main(void) {
    BOARD_Init(); /* Init code for my personal board */
    INITPIN29; /* Initialize the reset pin */
    Gui_Init(); /* Initializes SPI, Timers, and empty arrays */
    Write_Command(0xA6); //--all Display off
    while (1) {
        Write_Command(0xA5); //--all display on
        Write_Command(0xA6); //--all Display off


The OLED will not even turn on, not once. No screen flicker, nothing. I 
have triple checked everything on the hardware side over and over again, 
so I am convinced that it is software. Any help would be appreciated.


von Frank M. (frank_m35)

Rate this post
0 useful
not useful
I'm familiar with this display and currently use it in an active 
project, but I use the parallel interface and never tried the serial 

Thus I can't give you some exact suggestions, however,

have you tried a different simpler SPI device, like an EEPROM to check 
if your SPI Bus works at all?

Have you tried the simpler looking 4-wire SPI mode which sends 8-bits, 
thus 1 byte, instead of the 3-wire SPI mode which sends 9-bits, a mode 
few microcontrollers support natively. Additionaly you do send a full 
WORD, 16-bits instead of just 9 bits (do you have 16-bit mode activated 
in the SPI-hardware at all?), in which you changed the 9th bit. I'm not 
sure if this works. You probably have to implement it more accurately. 
This means either to implement 9-bit SPI in software by bit banging or 
sending an 9th bit manually and then falling back to the integrated 
SPI-hardware. All in all, the 9-bit mode is difficult (just do a google 
search) and I highly suggest to use either the 4-wire SPI mode, or, if 
you also want to read from the display (depending on how much RAM your 
microncontroller has, you probably don't want to waste too much RAM for 
a display buffer) use the parallel mode.

If you're using a PIC24 I can provide a working display driver which 
uses the parallel mode.

von Alex Lynchosky (Guest)

Rate this post
0 useful
not useful
Thank you very much for the quick reply.

I do not know how to check to see if the SPI bus is working on the OLED. 
I do, however, know that I have a working 16 bit SPI working on my 
pic32. Right now I am just sending over 16 bits at a time, and hoping 
that the OLED shift register will chop off the higher order bits, like 

SPI message = 0x01FF
OLED shift register gets 0x1FF (9 bits)

If this logic if clearly wrong, please let me know.

Also how would I use the parallel mode with the pic32? I have not been 
able to find any helpful code on this. The OLED I bought comes with an 
integrated pcb, so i'm not sure if this makes a difference.

I would really appreciate the code you have working for the pic24.

Thank you again for your help!

von Frank M. (frank_m35)

Rate this post
0 useful
not useful
A short web search also brought up the idea of hoping that the LCD chops 
of not needed bits. But no one wrote if it really worked.

So I still suggest you just try the 4-wire SPI mode. It shouldn't be 
that much work (just one additional wire) and a minor code change 
(implementing the D/C# pin). The wiring and jumper settings on the PCB 
are nicely illustrated on the accompanying PDF: 
The PIC most probably has two or three SPI devices integrated, so you're 
free to use a second one exclusively for the display in 8-bit mode, so 
you can keep the 16-bit mode SPI for other devices in 16-bit mode.

The PIC microcontrollers have a Parallel Master Port (PMP), which you 
can (and should) use for the parallel mode.
Here's the code for the SSD1322:
a few posts above is the driver for the SSD1325 in case you also use 
different displays.

The PIC32 might have enough RAM to use an extra internal display buffer 
without problems. The mentioned code however does not use a buffer and 
only uses the display RAM, making things a bit slower and drawing 
operations a bit more complicated, because of the odd pixel adressing. 
(one has to update 4 pixels in one rush always)

The PCB just seems to contain all necessary capacitors, diodes and most 
importantly the Step-Up converter to create the necessary 12V, all this 
in an easy to handle package, no need for ZIF-connectors. I only use the 
naked display (without display), but I doubt that there's any other 

von JIMMY J. (jimmy_sayavong)

Rate this post
0 useful
not useful
Alex Lynchosky,

Have you been able to solve the issue?
I have the same problem. I just went line-by-line on initialization 
instruction according to the datasheet and I still have nothing
on the display !!  I am very interesting to know if your issue is 




Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.