I have a Teensy++ 2.0 and a MicroSD card slot purchased from PJRC, but I cannot seem to get the Teensy to see the SD card slot. The test code I am using is as follows...
#include <SD.h>
void setup() {
//Pause for 1 second
delay(1000);
//Needs to be set for the SD library to function
pinMode(10, OUTPUT);
//Check to make sure SD card is functioning, if not set red LED
if (!SD.begin(20)) {
analogWrite(16, 1023);
}
}
void loop() {
}
I have tried multiple variations, but all I get is the red LED (pin 16). Pins 20, 21, 22 and 23 are hooked to SS, SCLK, MOSI and MISO in that order and GND and 5v are also attached to the SD card reader. When testing voltages for the pins at the SD card reader and the Teensy I get...
SS - 5
SCLK - .02
MOSI - 5
MISO - 3.3
5v - 5
Any thoughts would be greatly appreciated... thanks!
pinMode(10, OUTPUT);
//Check to make sure SD card is functioning, if not set red LED
if (!SD.begin(20)) {
analogWrite(16, 1023);
}
Set pin 10 as output and then tell the SD card that the chip select pin is 20. Well, I don't think I'd expect that to work too well. And, apparently, it doesn't.
//Check to make sure SD card is functioning, if not set red LED
if (!SD.begin(20)) {
analogWrite(16, 1023);
}
Set pin 10 as output and then tell the SD card that the chip select pin is 20. Well, I don't think I'd expect that to work too well. And, apparently, it doesn't.
Every post I have read on the topic says that pin 10 needs to be set as output for the SD library to work even if there is nothing on pin 10. And pin 20 is the chip select pin on a Teensy++ 2.0 according to what I have read. I have seen several examples of what claim to be working code with the same hardware that use exactly the code I am using here.
My programming background is not in Arduino, so if you or anyone else have any helpful suggestions to this problem I would love to hear them.
Error code 0X1 means the SD card does not respond to the first command that SdFat sends. This is almost certainly a hardware problem.
Hope you are not connecting 5V, SCK, SS, and MOSI directly to the card. The card runs at 3.3 V and these signals are too high so you need a level shifter. You can connect MISO directly to the card.
fat16lib:
Hope you are not connecting 5V, SCK, SS, and MOSI directly to the card. The card runs at 3.3 V and these signals are too high so you need a level shifter. You can connect MISO directly to the card.
Only if there are no 5V devices on the SPI bus. Why doesn't anyone consider the problem of mixing 3.3V and 5V devices on the SPI bus?
According to the product page (PJRC Store), the SD board contains "a 3.3 volt regulator and 5 to 3.3 volt buffer chip protects the SD card, and allows interfacing to 5 volt processors." So yes, it is connected directly to the card. I figured it was a hardware issue, but when I measured the inputs on the SS, SCLK, MOSI and MISO on the Teensy through analogRead they all showed that they were receiving input. I have tested it with different MicroSDHC cards and tested the cards in other devices. I am somewhat at a loss here... any suggestions on other ways to check and correct potential hardware issues?
I have used that Micro SD card adapter with a teensy successfully so it should work with the teensy++ if you have it connected correctly.
It has the proper regulator and level shifters so that is not a problem.
Measuring the voltage levels is not much of a test and analogRead is meaningless since SS is high in most of your readings so the SD is not selected.
There is nothing you can do with software tests when you get error code 0X1 since no data is received from the card. It is acting like nothing is connected to the SPI bus.