SPI OLED Questions

Board: ProMicro (ATmega 32U4)
Display: 0.96" SSD1306 7-pin SPI OLED
Library: Greiman's SSD1306Ascii (Hoping to use Hardware SPI)

Connections:

OLED     Arduino
GND      GND
VCC      VCC
D0       15
D1       16
RES      RESET
DC       9
CS       10
  1. Did I hook it up correctly?
  2. Can I effectively make this a 6-pin SPI? I've read that I may be able to tie one of the pins to ground. I'm out of pins and getting one back would be helpful.
  3. Most of the time when it starts up, I get white snow/noise. I read something about a reset procedure? If I move the RES pin from RESET to VCC, it starts up successfully more often, but still not 100%. What might I be doing wrong?
  4. The 32U4 runs at 16MHz. What is the fastest SPI I can use? By default, the SSD1306AsciiSpi.h runs at 8MHz. Can I use 16MHz successfully?
  5. Anyone used the OPTIMIZE_AVR_SPI flag? It looks like it runs at 8MHz, but I don't know if it's better or not.
  6. Instead of DC at pin 9, can I use the MISO pin of 14? (It'd make PCB layout a bit easier.)

Long story short: I had used the I2C variants of this display, and it introduced hella noise into my audio. When I hooked up the SPI variant this weekend, the noise was greatly reduced, but it still existed. A friend said running the SPI higher could help even further.

OK, maybe someone can at least answer #6? Can I use MISO pin 14 for my DC pin?

  1. Did I hook it up correctly?

I have no idea. What do your pin numbers mean? What Port Pins do they use?

  1. Can I effectively make this a 6-pin SPI? I've read that I may be able to tie one of the pins to ground. I'm out of pins and getting one back would be helpful.

SPI uses 4 pins. DC and RES are extra.
These controllers are generally write-only. If you do want to read registers or GRAM, the SDA (DI) pin is bi-directional.
The AVR SPI peripheral can not use bi-directional.

  1. Most of the time when it starts up, I get white snow/noise. I read something about a reset procedure? If I move the RES pin from RESET to VCC, it starts up successfully more often, but still not 100%. What might I be doing wrong?

I have not looked at your library or constructor.
Constructors often have an optional RES argument. Examples often omit it. Ignore it at your peril.

  1. The 32U4 runs at 16MHz. What is the fastest SPI I can use? By default, the SSD1306AsciiSpi.h runs at 8MHz. Can I use 16MHz successfully?

The maximum SCK frequency is 8MHz. The SPI peripheral has gaps. The USART_MSPI can do gapless transmission. Your library probably does not support USART_MSPI. (and a Mega2560 has been carefully designed to have 4 USARTs and no XCK pins)

  1. Anyone used the OPTIMIZE_AVR_SPI flag? It looks like it runs at 8MHz, but I don't know if it's better or not.

No idea. Read your docs.

  1. Instead of DC at pin 9, can I use the MISO pin of 14? (It'd make PCB layout a bit easier.)

It would stop every other device on the SPI bus. If your OLED is the only SPI device, this does not matter.

David.

Thanks David. I really appreciate your time.

  1. I think I set it up correctly. I mean, I get it to work. :smiley:
  2. I was able to successfully test to see that tying CS to LOW seems to work.
  3. Regarding the reset pin, I read somewhere about using a cap to help? Do you know anything about that? (Obviously using a real RESET pin helps tremendously, but I am almost out of pins.)
  4. Kind of a bummer about 8MHz being the max, but I can live with that. I think using something like ferrite beads or something may help get the remaining noise out of my audio.
  5. I'm going to scrap this question for now. It's not a big deal.
  6. I don't have any other SPI devices. Everything else is I2C (FRAM, expander, LED driver).

A note on #6, I was unable to use the hardware SPI with this pin. I think I found extra reading about the way the SPI.h library takes control of the MISO pin. However, using the Software SPI variant of this library, it was able to work.

Follow up question: If I don't plan on doing super fast screen updates, is there a downside to using the software SPI?

I scoured the internet trying to find how some of the I2C OLEDs tied their RESET pin and FINALLY found one that seems to work for me:

https://www.sunfounder.com/wiki/index.php?title=OLED-SSD1306_Module#Schematic

He has

  • 10uF from RES# to GND
  • 4k7 from RES# to VCC
  • 1N4148 from RES# to VCC