1
\$\begingroup\$

I'm trying to run the SSD1306 128x32 on a NUCLEO board. But I can't get the thing to properly initialize. This is my initialization sequence.

'''

ssd1306_WriteCommand(0xAE); //display off

ssd1306_WriteCommand(0xA8); //Set MUX Ratio
ssd1306_WriteCommand(0x1F); //sets to 31

ssd1306_WriteCommand(0xD3);//Set display offset
ssd1306_WriteCommand(0x00);//no offset

ssd1306_WriteCommand(0x40 | 0x00);//Memory Start


ssd1306_WriteCommand(0xA0); //column address mapped to 127 //Start left or right

ssd1306_WriteCommand(0xC8); //COM output mode //Start top or bottum

ssd1306_WriteCommand(0xDA); //COM pin hardware configuration
ssd1306_WriteCommand(0x02); //configuration

ssd1306_WriteCommand(0x81); //contrast control
ssd1306_WriteCommand(0x7F); //set to

ssd1306_WriteCommand(0xA4); //Entire Display ON

ssd1306_WriteCommand(0xA6); //Normal/Inverse A7 for inverse

ssd1306_WriteCommand(0xD5); //set oscolation frequency
ssd1306_WriteCommand(0x01); //set to

ssd1306_WriteCommand(0x8D); //set charge pump
ssd1306_WriteCommand(0x14); //enable charge pump

ssd1306_WriteCommand(0xAF); //turn on screen

'''

But whenever I run the this all I get is a bunch of randomly active pixels. Am I missing something?

\$\endgroup\$
  • \$\begingroup\$ I guess, the ssd1306_WriteCommand() is a derivative of SPI_write(), well some ssd1306 commands are more than 1 byte long, so you should use a SPI write, also check the SPI phasing. \$\endgroup\$ – Marko Buršič Apr 8 at 12:50
  • \$\begingroup\$ Random pixels may be normal. I don't see a clear command in your code. I have a slightly different OLED, it powers on with random pixels. \$\endgroup\$ – Mattman944 Apr 8 at 16:42
0
\$\begingroup\$

An example of similar OLED display, see that commands are more than one byte long.

write_reg(par, 0xFD, 0x12);
write_reg(par, 0xAE);
write_reg(par, 0xB3, 0xF3);
write_reg(par, 0xCA, 0x3F);
write_reg(par, 0xA2, 0x00);
write_reg(par, 0xA1, 0x00);
write_reg(par, 0xA0, 0x14, 0x11);
write_reg(par, 0xAB, 0x01);
write_reg(par, 0xB4, 0xA0, 0xFD);
write_reg(par, 0xC1, 0xFF);
write_reg(par, 0xC7, 0x0F);
write_reg(par, 0xB1, 0xF0);
write_reg(par, 0xD1, 0x82, 0x20);
write_reg(par, 0xBB, 0x0D);
write_reg(par, 0xBE, 0x00);
write_reg(par, 0xA6);
write_reg(par, 0xAF);

For example your code:

ssd1306_WriteCommand(0xA0); //column address mapped to 127 //Start left or right

ssd1306_WriteCommand(0xC8); //COM output mode //Start top or bottum

ssd1306_WriteCommand(0xDA); //COM pin hardware configuration

Should be something like this:

ssd1306_WriteCommand(0xA0, 0xC8, 0xDA ); 

And so, also the other commands that require operands.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.