CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Weird thing with SD card

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

Weird thing with SD card
PostPosted: Mon Sep 12, 2011 9:27 am     Reply with quote

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?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 12, 2011 3:34 pm     Reply with quote

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 ?)
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Tue Sep 13, 2011 8:10 am     Reply with quote

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).
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Tue Sep 13, 2011 8:13 am     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Tue Sep 13, 2011 9:18 am     Reply with quote

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
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 5:35 am     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group