SPI microSD card not found on Teensy 3.2

Elf

Well-known member
If I use a Teensy 3.5, the SPI microSD card is found and I'm able to read the files on it. With a Teensy 3.2, SD.begin(9) returns 0. I've tried using pin 10 for CS with the same results.

p.s. I would switch to Teensy 4.1, but the code is using the TeensyStep library which isn't compatible with the 4.1.
 
Might help to have a lot more information....

Like what all is on the T3.2? What example code that is failing. What version of Arduino and Teensyduino are you using?
A picture of the hardware often helps.
 
You're asking us to help you troubleshoot the SD card with a board that doesn't have a built in SD socket, but regarding the way you've connected a SD card, you didn't show photos or a diagram or even give a link to which hardware you've connected. Sometimes we manage to figure out problems by guesswork, but this is really a case of knowing almost nothing to even begin guessing. Start by showing photos so we can see how what you're doing for connecting the SD card.
 
The project is a controller for a 5 axis rose engine(lathe). The board is a custom pcb which can accept Teensy 3.2 through Teensy 4.1. It can use DRV8825 stepper drivers or external stepper drivers. There are two 74HCT245 level shifters between the drivers and the Teensy. It also has a Pololu 2595 bidirectional level shifter between the Teensy and a Nextion touchscreen.

Arduino: 1.8.19
TeensyLoader: 1.56
Full project: https://github.com/elfren/RoseEngine_SpindleAndAxis
Unpopulated board: https://github.com/elfren/RoseEngin...PCB/Five_Axes/V003_Black/20220629_184014c.jpg
Board with Teensy 3.5:
20220726_150312s.jpg
Board with Teensy 3.2:
20220726_150517s.jpg
SPI-MicroSD board:
20220726_160439c.jpg

The code:

Code:
        #include "SD.h"
        #include "SPI.h"

	pinMode(PIN_SPI_CS_9, OUTPUT);
	digitalWrite(PIN_SPI_CS_9, HIGH);
	bool sdBegin9 = SD.begin(PIN_SPI_CS_9);
	Serial.print("sdBegin9:");
	Serial.println(sdBegin9);

Output: sdBegin9:0

There are no issues using this board with the SPI microSD adaptor and a Teensy 3.5. The Teensy 3.2 can drive all of the steppers simultaneously. The only issue is that it cannot find the SPI microSD card.
 
Wires to SD adapter seem quite long 10"? Maybe on the edge and T_3.5 works and T_3.2 fails?

Do any of the provided SD Examples act any differently when run alone on the T_3.2?
 
Examples work the same. SD.init or SD.begin fail on the 3.2 and work on the 3.5. I'll try shorter wires.
 
is there anything connected to the IO pins on the 3.5 that would not be connected by the 3.2 because it does not have those pins?
Example SPI device where CS pin is on one of those pins. Where on 3.5 maybe is pulled high before the SD is initiialized, but is floating when 3.2 is plugged in?
 
The code is identical for both. It's using pin 9 or 10 for CS, 13 for SCK, 12 for MISO, and 11 for MOSI. All five stepper drivers' pins plus two serial ports and two SPI ports fit in the 23 pins available on the 3.2. Only one SPI port is expected to be active at any one time.
 
The code is identical for both. It's using pin 9 or 10 for CS, 13 for SCK, 12 for MISO, and 11 for MOSI. All five stepper drivers' pins plus two serial ports and two SPI ports fit in the 23 pins available on the 3.2. Only one SPI port is expected to be active at any one time.

What two SPI ports on T3.2? you may want to map out the 23 pins for the different boards, and make sure the functionality is hooked up the way you think.

For example you may want to go through the SPI pins. For example, which pins are used on the display? what about touchscreen?
If these are on the SPI buss, you then need to make sure that all of the CS pins are High except the one you are talking to.

For example sometimes need to setup the CS to be high before you try to init any of the devices. Unless they have external PU resistors. But just guessing
 
Pinouts for the first 23 pins are the same on all Teensies. CS pins, 9 and 10, are set high. I moved their initialization to just after Serial1 and Serial3 initialization and before initializing the stepper drivers' pins. Same result. T3.5 works and T3.2 doesn't.
 
I tried using the alternate SPI pins, but still no joy. I also borrowed a friend's 3.2 and it failed as well. I found an old thread of Paul's which mentioned reducing the CPU speed to 24mhz. Miraculously, it worked. Originally, the CPU speed was set to 96. I increased the speed from 24 to 48 then to 72 and it still worked. Setting it to 96, it fails.
 
What if you left the speed the same and put a delay in setup before you tried accessing the card? I'd err on the generous side with the delay, it's in setup. Maybe it's all down to the slightly faster speed of the 3.5...
 
If it were me, I would use a different SD Adapter. One that does not have level shifters on to convert 5v signals to 3.3v...

Although I have found that some of them may work fine. Are you connecting the VCC pin of the adapter to +5v or 3.3v?

As a side note: this morning, I pulled out T3.2 and an Audio board and plugged them both into a board that has 3 sets of pins, for testing...

And I used the ListFiles SD example, and it works fine on Pin 10 (after I changed the SPI pins as needed by the Audio board.
And it ran at full speed.

I will now pull out another SD adapter and see if any issue shows up
 
I have now tried with two different Sparkfun adapters.
One that is not level shifted: https://www.sparkfun.com/products/544
And another that is: https://www.sparkfun.com/products/13743
Screenshot.jpg

I ran the SD list files example... Edited pin 10 to 9.
Code:
Initializing SD card...initialization done.
prealloc.txt                                    40960    08:38  July 21, 2022
FOUND.000/
  FILE0000.CHK                                  32768    10:23  July 30, 2022
2001/
  stop.wav                                     200844    04:15  September 23, 2017
  operational.wav                              772140    04:15  September 23, 2017
  one_moment.wav                               202236    04:15  September 23, 2017
  functional.wav                               237356    04:15  September 23, 2017
  enough_info.wav                              513388    04:15  September 23, 2017
  dangerous_to_remain.wav                      372892    04:15  September 23, 2017
  completed.wav                                276460    04:15  September 23, 2017
  calculations.wav                             426300    04:15  September 23, 2017
Audacity/
  Welcome_Christmas.mp3                       2985790    09:20  December 2, 2021
  Take_My_Breathe_Away.mp3                    5740819    09:20  December 2, 2021
  Dont_Rain_on_My_Parade.mp3                  3943937    09:20  December 2, 2021
  Away_in_a_Manger.mp3                        2014737    09:20  December 2, 2021
annie1.bmp                                     230454    04:33  January 16, 2022
house.gif                                      206364    06:43  April 11, 2005

Note: I ran this on today's daily IDE2 build using the 1.57 install..
In both cases I run 3.3v to the VCC in to the adapter
 
Back
Top