View previous topic :: View next topic |
Author |
Message |
championx
Joined: 28 Feb 2006 Posts: 151
|
Weird thing with SD card |
Posted: Mon Sep 12, 2011 9:27 am |
|
|
I'm using the SD card mmcsd.c library provided by CCS. The thing is... if i turn on the circuit, everything works fine... but... if i hit the MCLR button... then the SD card can not initialize.
What could it be??? any suggestions? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 12, 2011 3:34 pm |
|
|
What's your PIC and CCS compiler version ?
Did you build the hardware yourself, or are you using a manufactured
board ? If so, what's the manufacturer and part number of the board ?
What's the Vdd voltage of the PIC ? If +5v, do you have a level
translator circuit between the SD card (at +3.3v) and the PIC ?
Describe your MCLR circuit.
What are your #fuses ?
What type of SD card are you using, and what storage capacity size ?
Describe the SD card interface circuit.
Quote: | then the SD card can not initialize.
|
Does this mean you know that the program is locking up in the mmc_init()
function ? If so, can you trouble-shoot the problem and find out what line
in the routine is causing the problem ? (By using a debugger or printf
statements to find the exact line where the lockup occurs ? Probably
where it's testing for some expected return value, that it doesn't get ?) |
|
![](templates/subSilver/images/spacer.gif) |
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Tue Sep 13, 2011 8:10 am |
|
|
I use the 4.054 version.
I build the hardware myself, i have two versions of the circuit, one operates at 3.3v the entire board. The other have level shifters. The level shifters are 4 mosfet transistors 2N7000 with pullups on each side.
the mclr circuit is a pullup with a switch. Nothing special.
fuses: #fuses H4,NOWDT,PUT,NOPROTECT,NOLVP,MCLR
I use a sandisk 2GB SD card.
the strange thing is that the 3.3v board is exactly the same but at 20mhz (xtal). The 5v board operates at 40mhz (10mhz xtal + PLL).
The firmware is the same (with the difference on the fuses and xtal config). |
|
![](templates/subSilver/images/spacer.gif) |
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Tue Sep 13, 2011 8:13 am |
|
|
on the 3.3 board i can use the maximum baudrate on the SPI bus. But in the 5v circuit, if i use higher baudrates than 75000 then the SD does not init or init but shows garbage.
I put an oscope and i could see the 300.000 khz clock on the 3.3 board. But in the 5v board i can not exceed 75.000 khz. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Sep 13, 2011 9:18 am |
|
|
I think you need to post a link to the level shifting circuit you are using.
The description sounds like it is based on the bi-directional level shifter sometimes used on I2C busses. I'd be very dubious if this will work correctly at really high speeds. Some modern SD cards are fussy about rise times on the signalling lines (particularly those designed to clock at 50MHz). Generally a resistive divider will work for the 'down' conversion (5v to 3.3v), though lower resistor values may be needed than has often been posted, when using modern cards (edge speed again), and a FET can do an up conversion, but you will get much better edges and overall performance from using a proper shifter in both directions.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Wed Sep 14, 2011 5:35 am |
|
|
yes, the level shifter circuit is this:
http://www.rocketnumbernine.com/2009/04/10/5v-33v-bidirectional-level-converter/
At first i used voltage dividers on the SCL, MOSI and CS lines. The MISO line was directly connected to the pic. Everything worked fine, but slow... if i increase the speed, then it wont initialize... so... i supposed that the voltage dividers was a poor conversion... so i then put some MOSFET level shifters. I could increase the speed... but not too much.
thanks! |
|
![](templates/subSilver/images/spacer.gif) |
|