SSD1306 + Teensy MicroSD adapter SPI issues

Status
Not open for further replies.

tenkai

Well-known member
I am trying to connect both an SSD1306 module (from adafruit, https://www.adafruit.com/products/938 ) and a PJRC MicroSD adapter (https://www.pjrc.com/store/sd_adaptor.html)

When I connect just the microSD adapter to the teensy (using 11 - MOSI, 12 - MISO, 10- CS, 13, SCK) I can run the SdFat bench.ino test just fine.
It also runs fine when I connect most pins from the SSD1306 (except the SCK and DATA pin).

Code:
Use a freshly formatted SD for best performance.

Type any character to start
Free RAM: 58235
Type is FAT32
Card size: 31.91 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3
OEM ID: SD
Product: SL32G
Version: 8.0
Serial number: 0X8D4E026
Manufacturing date: 6/2014

File size 1 MB
Buffer size 1022 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
277.64,112593,223,3671

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1160.88,2220,431,879
1163.58,905,432,878
1162.23,905,431,878
1162.23,904,431,878
1163.58,905,431,878

Done

but when I connect the SCK teensy pin 13 to the SSD1306 SCK pin, bench.ino no longer succeeds. same when I connect the Data pin (to MOSI):

Code:
Type any character to start
Free RAM: 58235
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0XFF


I hooked up my oscilloscope to the SCK pin to check out whats going on:

when the SCK pin is NOT connected to the SSD1306:
IMG_5350.JPG

When the SCK pin IS connected to the SSD1306:
IMG_4805.JPG


It seems that connecting the SCK pin to the SSD slows down the clock somehow. I have tried pulling CS on the SSD1306 to 3.3v in order to make sure its not trying to grab the SPI signal, but to no avail. Also I soldered the 3.3v jumper on the SD slot.

Anybody have any troubleshooting advice? I have a logic analyzer, which I will use next. Will post when I have more info.
Thanks!

T
 
I hooked up a logic analyzer for both scenarios, and here are the results. not much that I can glean from it without going into the bit by bit SD protocol.

Successful bench.ino:
Screen Shot 2015-06-18 at 1.16.54 AM.jpg

Failed bench.ino:
Screen Shot 2015-06-18 at 1.20.00 AM.jpg



Also worth noting that this issue also affects the SD library when working with the SSD1306.

Additionally, I tested using the SD reader with another SPI device hooked up, and it worked just fine (it was an AD5676 DAC chip)

I feel like the SSD1306 is trying to pull the clock high or low, but I can't seem to figure it out. I might try the display, with the DAC chip simultaneously, as they both have a much simpler SPI implementation than the SD card.
 
The forum may have relevant posts - outside search engines may find better than native search - I saw refs to tristate buffer usage on other displays where the data line on the idle device wasn't - IIRC. Other questions you may answer / consider for others to help: how long are your wires - what's the code look like - i.e. 'forum rule' on header. I've used i2c versions of the small OLED 1306's - that might get you going if the speed is okay. There was also work I didn't do on my TFT display to short/remove to 0 ohm - inline resistors so it would run SPI with the flash - YMMV as that was a 320x240 color that ILI9341 PJRC sells. If you are flash read only the developing library update supports that now.
 
I might try the display, with the DAC chip simultaneously, as they both have a much simpler SPI implementation than the SD card.

can't be of help with the SD card, but this at least (DAC + oled) should work. i have a similar OLED (ebay/china) and a DAC (DAC8565) working happily together; using u8glib and spi4teensy though.
 
If you are not doing this for the academic fun of it then perhaps I can recommend I2C mode for the SSD1306 - I have modules (well, my work has modules) that did not come from Adafruit but the Adafruit library 'loves' them quite adequately in I2C mode - rather than touching anything in their example (or library), when I tried it with these modules, all I had to do was drive SA0 high (I2C addr 0x3D by memory) and it was marvellous.


Is SCK driven if you supply the module power without connecting SCK to anything other than a probe? If it is low when you probe it then does momentarily connecting a highish value resistor (>10K) between it and 3V3 bring it 'snap' up? Alternatively, if it high to start with then does similar resistor to GND make it 'snap' down?

Ummm, unlikely as I think; have you a meter that does capacitance? Maybe there is unusual capacitance on the line for some (reasonably dodgy) reason.
 
Well, I have determined that it is something weird that is in the Adafruit package of the SSD1306.

I found a 2.5" SSD1306 i had bought off ebay some months ago, wired it up, and it all works gravy.

Robsoles, I think you may be on to something. There is a 6 µf capacitance between SCK and GND on the Adafruit SSD1306 which is not present in the other package I have.

I2C mode was my next step. I think I will try it out and see what kind of performance I can get. I guess I always assume that I2C doesnt have the bandwidth I would need for something like a display, but maybe so! I just get such high refresh rates with SPI :D But when I need a MicroSD, OLED Display AND a DAC all operating at high speeds, its gonna get interesting...

Thanks for all the help!
 
I was expecting nanos at worst, hoping for picos - omg you got micros! lol, soz - love to know what turned into a cap in their assembly there if you ever figure it out with any sort of certainty :D
 
Maybe the two SPI devices need different settings, but neither library is using SPI transactions, so each is at the mercy of whatever the other did to configure the SPI hardware?

The quick not-very-effictive thing to try is initializing the libraries in a the other order.

Please try with the SD library. It uses transactions, so it should not be messed up by other SPI code. But Adafruit's library does not. I don't have a great answer there, other than hacking their library.
 
Paul, I think what we discovered is that we had a hardware issue that was hijacking the SPI clock.

When everything was connected, but the SSD1306 was not even initialized, it failed even using the SD library.

I discovered (at robsoles' suggestion) that there is 6 µf capacitance over CLK and GND on The Adafruit SSD1306 1.3" display. I have another SSD1306 display that works just fine. I have a SECOND Adafruit SSD1306 is exactly the same. The Adafruit module does not play nice with other SPI modules it would seem. Going to try the display and the DAC chip together next.
 
RE posts #8
SSD1306 data sheet says SPI clock can be a square wave of 40nSec. But there could be stuff on the PCB.

6 microfarads - that must be a typo?
 
If you hadn't mentioned finding much less capacitance on other module(s) then I would have asked you to try your capacitance meter across a 1K resistor and then a 'loose' capacitor (with clear enough markings, known capacitance) to try to verify your meter and probes (and leads etc etc).
 
my micrometer is pretty accurate. Just verified it with a 104m cap and 4.7kΩ resistor. its got 6µf on it! I measured two of them!
 
lol, taken literally your post could be taken to mean that the micrometer has 6µ on it but I have reasonable confidence you measured tiny pico reading on the resistor (if any, probably some tiny reading tho), the cap you measured came out in the range 85~115n and that 6µF is on that blasted SSD1306 module you first posted about :D
 
double checked my 104m reading this morning. yep, still ~100 nF. also double checked the display, definitely 6µf. And it works! ive used it a bunch.

Perhaps its intended as a low pass filter for the clock line?

IMG_5363.jpgIMG_5364.jpg
 
Hi everybody,

I ran into the very same issues. Both, Adafruit SSD1306 OLED and microSD adaptor work individually, but the moment I connect the OLED pins, I loose access to the SD card.
Has anyone found a solution to the problem?

Thanks a lot in advance!

Best,
Karg
 
Just for test, try this library I wroted time ago:
https://github.com/sumotoy/OLED_SSD1351

It use SPI Transactions.
Btw a 6uF in SCLK it's a massive failure, it simple nonsense since controller don't need any low pass or similar but from picture it looks an adafruit product, maybe there's schematics on their site, or can be a clone chinese?. In my experience I see many times chinese add useless resistors and capacitors in SPI lines and SD card SPi lines are weak and sensitive even to wire lenght.
If not work, try to isolate the whole display with a 75HC125 like below.
TeensyAdapter_schem3.png

I've used for RA8875 that has a similar problem with SCLK and MISO.
 
Last edited:
Adafruit SSD1306 OLED and microSD adaptor work individually, but the moment I connect the OLED pins, I loose access to the SD card.

Can you be more specific about exactly which boards you're using, and exactly how you've connected them? Adafruit makes multiple SSD1306 OLED boards with SPI interface. Several SD adaptors are available too.
 
This library has 3 different constructors. It matters greatly which one you're using. I don't see any code posted on this thread.

To share the SPI pins, you must use the 3 pin constructor. You must not use pins 11, 12 or 13 (for CS, D/C, RST). Pin 12 can't be used for any of these 3, since it's still needed by the SD card as MISO.

If you're using the 5 pin constructor, the library reconfigures the pins as normal digitalWrite(). That would cause them to no longer be controlled by SPI. I can't see your code, so this is my blind guess....
 
@PaulStoffregen: I actually experienced the very same problems as the initial posters, that is why I did not post code. Basically, all example programs of SD and SDfat libraries run fine. However, the moment I connect the OLED pins (not even initialising it in code) the SD stops working. However, I have tried different displays by now, and the problem seems to be specific to this one OLED from Adafruit. Since I want to proceed with my project, I left this problem for another time, and use a different OLED instead now...

Thanks for all replies!
 
I've got the same problem. Using Teensy3.2 and 4.2" OLED SSD1309_128X64 vs SD, SPI(Teensy) and U8g2lib libs. Same OLED with SD but Arduino DUE insted of Teensy works fine. Problem comes right after you connect SCK pin to OLED, even if OLED power is off(on) and no OLED librarys included to sketch. OLED work fine, SD stop responding.
To solve problem you have to change Teensy's CPU Speed to 72MHz. In my case it help to run sketch without any modifications.
 
Status
Not open for further replies.
Back
Top