Go Down

Topic: SSD1306 SPI Connections (Read 103 times) previous topic - next topic

Jeremyvnc

Hello,
   I've been using the 0.96" OLED using the i2C interface with the u8glib library and have been loving the simplicity of it all.  I'm having an issue with the display taking alot of time drawing a filled in graph and I also need to redesign my display pcb to better fit two separate enclosures I have.  Sadly, the new design requires me to use SPI for the display.  First question, has anyone noticed any noticeable draw rate increases between i2C and SPI?  I know SPI runs much faster so I would think so but wanted to see if anyone had experience comparing the two.

My second and more important issue is the SPI port that I'm plugging into only has the standard AVR ISP pins: MOSI, MISO, SCLK, Reset, 3.3V (on my board), GND.

The SSD1306 requires 3.3V, GND, CS, D/C, SCLK, MOSI (SDIN), and Reset (which I plan on tieing high).  The CS and D/C pins are my issue.  I can't find the d/c pin called out in the u8glib definitions at all.  Maybe a0 is the same as D/C?

From reading the datasheet on the SSD1306, it looks like I could run the display in 3 wire SPI mode (ground D/C) and the chip select cs pin will be active low, but then the datastream would be 9 databits instead of 8 where the D/C bit would be the msb.

My question is, would the display and library work if the cs pin was connected to the MISO pin and d/c was grounded?  Or, even simpler, since I do not plan on having any other spi devices, could I just ground the cs and d/c pins so that the device is always "active"?

jboyton

There is a speed increase but it depends on how much time the processor spends rendering the graphics. I use a text-only library and the speed difference is a factor of 10, but rendering text is simpler.

D/C selects between command and data. It's sometimes called A0. You can't just tie it high or low. 3-wire SPI moves the D/C bit into the data stream but would require at least some software intervention since the Atmega chips don't support 9-bits. You'd have some extra coding to do and you might end up with something that isn't any faster than I2C.

The reset line may require a low pulse for your board to work. The boards I've tried do. If so, it might be possible to generate a pulse using some hardware rather than a pin.

You wouldn't want to connect CS to MISO. In fact, you don't need MISO since you can't read the display memory. Unfortunately, once you enable SPI as master in the processor you can't use the MISO pin as general purpose I/O. It will be an input to the SPI register. So it's a wasted pin. You could recoup this by using software SPI but then your speed advantage would be gone.

I couldn't find anything in the datasheet that specifically disallows tying CS low for a system with only one SPI device. But the one time I tried this the display I was using would not function correctly.

Jeremyvnc

#2
Jun 10, 2015, 03:46 pm Last Edit: Jun 10, 2015, 03:53 pm by Jeremyvnc
As far as the reset line, the current system works fine with i2c and the reset line pulled high with a resistor with a capacitor going to ground for your pulse.

So based on what you are saying, software SPI would be the only way for me to go here?  I have no other hookup options at this point (it's a very small board with i2C and SPI/ISP ports only).

One thought I had was to use 4 wire SPI and just make an OR circuit to make cs OR d/c.  I doesn't seem like there are any times that cs and d/c are required to be signaled.

If I use software SPI, I could make my signals:
3.3V ->   3.3V
GND ->   GND
MOSI ->  MOSI (SDIN)
Reset -> N/C
MISO -> (cs OR d/c)?
SCK ->   SCLK

What do you think?

jboyton

There are software I2C libraries. By the way, the reason D/C is sometimes called A0 is because this pin is used to select bit 0 of the I2C address when the SSD1306 is configured for I2C.

If I2C is not an option, then the minimum number of pins would be achievable via software 3-wire SPI:

any pin --> MOSI
any pin --> SCLK
any pin --> CS (or tie low if it works for your display)

If that's too much trouble then use 4-wire software SPI which is probably supported by u8glib:

any pin --> MOSI
any pin --> SCLK
any pin --> D/C
any pin --> CS


There is no MISO for your display.

Go Up