My SPI does not seem to be working on a custom board based on the DUE

I have a custom board based on the arduino due schematics with some additions and subtractions. But it would seem that SPI is not working for some reasons. I have 3 devices on my SPI lane.

A digitPot TPL0202
An OLED lcd
A SDcard slot
(there are technically 3 more but those will not be used and the pads left unsoldered)

First is an oled lcd usng the ssd1351 chip upon using adafruits library (code too long to post here). If you notice the example file lets you choose two initialization either using any pins or the SPI pin. I wired my LCD using the spi pins. Choosing line 58(using the real SPI) of the example code as the initilization the display wont work. But when using the init on line 52 the display works perfectly. This lead me to believe that the culprit is not the connections, because i did not change pins when running those two inits.

Second is the digital Pot i first though that i made the digit pot work but it was just a coincidence that the value i set it with is the default value on powerup. Here is my code on this one and the datasheeet. I based the code on this one on a previous question on this forum

#include <SPI.h>

const int DIGI_POT_CS_PIN = 71;

void setup() {

  pinMode(DIGI_POT_CS_PIN, OUTPUT);
  SPI.begin();

  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
  digitalWrite(DIGI_POT_CS_PIN, LOW);
  SPI.transfer(0x02);
  SPI.transfer(0xFF);
  //SPI.transfer16(0x02FF);
  SPI.endTransaction();
  digitalWrite(DIGI_POT_CS_PIN, HIGH);
}

void loop() {
}

finally is the SD card this one is i have not soldered yet, because it was supposedly the last i would test. BUT ONE IMPORTANT THING is the SD card needs pull-up resistors on all lines including the SPI lines. I have already soldered these pull-up resistor 10k Ohms on MOSI, MISO,SCLK. So are these pull-up interfering with the normal operation of the other devices? How do i fix it? I need the sd card and the other 2 devices. Is there anything in the SPI library that i should change?

Whats does the DIGI-POT output?

Railroader:
Whats does the DIGI-POT output?

It has two channels and both channels outputs exactly half the voltage of the source, im amazed at how accurate its rato is.

And what is the ordered value?
Maybe You can use loop() and a for loop that once per second, per 10 seconds... sends an increasing value between min and max.

Use Serial Monitor to print out what loop is sending the POT.

i did not quite understood what you said there, but what i get is send an increasing value with a delay on each send. It kinda worked now :smiley: for some reason ...

So SPI IS working, that leaves the OLED display

Good! Do some exercizing with the functioning stuff! That makes You more fit to handle oncoming needs and so on.
Can You supply this last working code?

I am getting really inconsistent results. sometimes the code works and after a resset it does not. will update back if i can make it run consistently

Something is still out of order.
Attache code and wiring and let's see what helpers can find out.

I think i have made it stable now, i changed the IC to a newer one, it would seem that might have been damaged somehow.

here is a guaranteed working code

#include <SPI.h>

const int DIGI_POT_CS_PIN = 71;

void setup() {

  pinMode(DIGI_POT_CS_PIN, OUTPUT);
  SPI.begin();

  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
  digitalWrite(DIGI_POT_CS_PIN, LOW);
  SPI.transfer(0x03);   // sets both wipers of the digipot
  SPI.transfer(0xFF);
  //SPI.transfer16(0x02FF);
  SPI.endTransaction();
  digitalWrite(DIGI_POT_CS_PIN, HIGH);
}

void loop() {
}

Thanks for spending time on helping me good sir

Okey, not tons of code to check up. Can You make a drawing showing powerdistribution and logical wiring?
Pen and paper and a photo often works. Show voltage sources clearly.

Where/What is the issue for the moment?

The schematics is quite big and if i take a snapshot of it the components names and values cannot be read anymore. But here is the schematics of all the SPI devices. The devices on the bottome row wont be soldered anymore and their pads will be left hanging.

After the TPL0202 problem the one remaining is the SPI initialization of the OLED. Where upon using the true SPI the example code wont work, but using an alternate initialization of the class it works

Fight one problem at the time. I assume that the digi-Pot is working now.
I've used I2C but SPI is a white spot for me.

John41234:
The schematics is quite big and if i take a snapshot of it the components names and values cannot be read anymore. But here is the schematics of all the SPI devices. The devices on the bottome row wont be soldered anymore and their pads will be left hanging.

In the CAD program you should be able to EXPORT a jpg image for posting.
Can you post a picture of your PCB please.
Thanks.. Tom.. :slight_smile: