5 volt SD card not working with level shifter
Boblow45
Posts: 7
Hi Guys/Girls
I am currently working with a old SD card module that works on 5 volts. I am using two ''cd40109be'' chips for level shifting. I have sent PWM signals through each of the level shifting chips to see if they work correctly, the PWM worked as expected. I am stepping the ''SS,SCK and MOSI'' signals up to 5 V and the MISO down to 3.3 V so i can interface with the module. The SD card module is part of my introduction kit I got with my Arduino. The ''sd_mount'' function is not returning 0 as expected, but is returning 6. My code is as follows:-
I am currently working with a old SD card module that works on 5 volts. I am using two ''cd40109be'' chips for level shifting. I have sent PWM signals through each of the level shifting chips to see if they work correctly, the PWM worked as expected. I am stepping the ''SS,SCK and MOSI'' signals up to 5 V and the MISO down to 3.3 V so i can interface with the module. The SD card module is part of my introduction kit I got with my Arduino. The ''sd_mount'' function is not returning 0 as expected, but is returning 6. My code is as follows:-
/* SD Minimal.side Create test.txt, write characters in, read back out, display. */ #include "simpletools.h" // Include simpletools header int MOSI = 22; int SCLK = 23; int MISO = 24; int SS = 25; // SD card pins on Propeller BOE // DO = MISO // DI = MOSI // CLK = SCLK // CS = SS // grey wire is MISO: pin 24 // brown wire is SCLK: pin 23 // black wire is SS: pin 25 // yellow wire is MOSI: pin 22 int pinRed = 22; int main(void) // main function { //sd_mount (int doPin, int clkPin, int diPin, int csPin) int mout = sd_mount(MOSI, SCLK, MISO, SS); // Mount SD card print("%d \n", mout); FILE* fp = fopen("test.txt", "w"); // Open a file for writing fwrite("Testing 123...\n", 1, 15, fp); // Add contents to the file fclose(fp); // Close the file char s[15]; // Buffer for characters fp = fopen("test.txt", "r"); // Reopen file for reading fread(s, 1, 15, fp); // Read 15 characters fclose(fp); // Close the file print("First 15 chars in test.txt:\n"); // Display heading print("%s", s); // Display characters print("\n"); while (1) { } return 0; /* while (1) { pwm_start(1000); pwm_set(pinRed,1,500) ; //pwm_set(pinGreen,1,500) ; pause(500); pwm_set(pinRed,1,000) ; //pwm_set(pinGreen,1,000) ; pause(500); pwm_set(pinRed,1,000) ; //pwm_set(pinGreen,1,000) ; pause(500); pwm_stop(); } */ }
Comments
The SD module was designed for an arduino, which obviously has its I/O pins operating at 5V. We tried originally wiring it without level shifters and got no response. as it required a 5V rail, we assumed the PCB circuitry dropped it to 3.3V, and that it required 5V I/O signals. This obviously didn't work
Having scoped the pins this morning, it seems that the pins connected to the module aren't firing - the CLK line, for instance, flashes high briefly and then stays low. There is no communication with the module. About the only thing we haven't tried is a logic analyser
I'm pretty sure the simpletools SD card library is faster than 900kHz. There's a generic C SPI driver that can only do 900kHz, but there are SD card specific SPI drivers written in PASM that can do around 20Mb/s (50ns/bit) IIRC, and I can't imagine that simpletools doesn't use them.
I've scoped the Parallax SD utilities. They run at 4 MHz. Interestingly enough - I think it even *starts* at 4 MHz instead of the required < 400 kHz - but I could be wrong on that.
PropWare's SD classes are no where near complete, but they are good enough to at least test your level shifter and the clock speed is configurable from 0 to 900 kHz. You could set the speed to 200 Hz if you really wanted. That might provide you a way to test it out.
Yeah, we tried that (its only a breadboard atm) - didnt work. Theres a new level shifter on the way.
Random though: is the prop sd library expected and SDHC card instead of SD?
I think you will find you have commented in the wrong thread/forum.... at least, I'm assuming you have, or i know a lot less than I though about SD cards