|
|
View previous topic :: View next topic |
Author |
Message |
SSURESHREDDY
Joined: 10 Aug 2013 Posts: 13 Location: bangalore
|
Need guidelines for SD card Interface |
Posted: Thu Jul 31, 2014 4:56 am |
|
|
Hi all,
I need to interface Micro SD card to store the data, measured by the PIC18F2525. Anybody explain me how can I communicate easily?
Suresh |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Jul 31, 2014 8:59 am |
|
|
use the drivers that CCS supplies or one of the ones in the code library here
IMPORTANT be sure to PROPERLY interface the PIC to the SD card.
Your PIC is 5 V and all SD cards are 3 volts !!!
You have at least 3 choices to configure your project
1) Use a 3Volt PIC, An 'L' version. This is easy, simple and works.
2) Use 'logic level' transceiver interface chips. Added cost and wiring
3)Choose I/O pins that are 3V compatible.
Also be aware that the SD driver is for 2GB or less cards,however there is code in the 'code library' for bigger cards I think.
FIRST though... get your PIC to do the 1Hz LED program to confirm your
PIC,board work and you can compile code !!!
hth
jay |
|
|
SSURESHREDDY
Joined: 10 Aug 2013 Posts: 13 Location: bangalore
|
|
Posted: Fri Aug 01, 2014 1:08 am |
|
|
Thanks Jay,
I used a driver to send the measured data to LAPTOP with a "USB to UART Converter", but I never used for SD card, can you suggest me some interface chips.
And I got the MMCSD driver from CCS libraries. Can you explain me how can I use those libraries, I don't know those drivers are designed for <2GB or >2GB
Suresh |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri Aug 01, 2014 2:07 am |
|
|
and get the initialisation resistors right.
The pullup resistors on DAT1, DAT2, DATA_OUT, and CS should be present to ensure that the card wakes up correctly. 10KR each is OK.
These have different functions in different circumstances and on the different lines.
1) The drives on the SD card wake up in open collector mode. The resistors make sure the undriven lines are pulled up, till the card is programmed to SPI mode.
2) The card may be unplugged. The resistors ensure the lines go high when this is done.
3) The PIC pins, wake up set as inputs. So the CS line, can float at this point. The resistor ensures it is pulled high at this time.
4) They have a slight effect in speeding the rising edges of the signals.
The 'simplest' circuit for 5v PIC to 3.3v SD, is resistive dividers (1K8/3K3) on the DATA_IN, and SCLK lines, 'open collector' driving of the CS line (either using a diode, or using the 'output_float' ability when the line needs to go high), and a single buffer on the incoming data line (a buffer like a 74ACT125). Then the four pullup resistors.
This works.
Remember you need to work out how you are going to allow the user to unplug the card. If the card is unplugged while data is being written, there _will_ at some point be corruption. I use a little access 'cover' hatch, and when this is opened, finish writing to the card, and turn on a green LED to say 'OK to remove'. Close the hatch, and the code starts talking to the card again. and the LED goes out. Generally the shut-off is so fast that by the time you have opened the door, and reached inside to push the card to release, it has already finished. Having a 'just pull it out' type access, is generally OK, if the card is only ever read (this is how they are used for music players etc.). But if you are writing as well, a bit of thought is needed. |
|
|
SSURESHREDDY
Joined: 10 Aug 2013 Posts: 13 Location: bangalore
|
|
Posted: Fri Aug 01, 2014 11:13 pm |
|
|
thanks all,
I configure my hardware (SPI pins) with a resistor divider(2.2k and 3.3k gives 3 Volts).
and I included mmcsd.c for my existing project,
I just only want to write the data with in a file, I don't have read application with micro controller.
is anybody have an experience how to write data using mmcsd.c please give me an examples,
Suresh |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Aug 02, 2014 5:33 am |
|
|
Sorry but your use of hardware SPI pins will NOT work. While resistors will allow the 5 V PIC to send data to the 3 V SD card, the PIC requires 4 volts FROM the SD card on the hardware SPI peripheral.
The hardware SPI uses ST input and they require .8 * VDD( .8 * 5 - 4.0 volts) as a logic one.
This is shown in the datasheet under the electrical specs ( D041 I think).
As I said earlier there some options on how to configure your project but resistors will NOT be one.
hth
jay |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Sat Aug 02, 2014 6:35 am |
|
|
SSURESHREDDY wrote: |
I just only want to write the data with in a file, I don't have read application with micro controller.
Suresh |
Even if you only want to write, the driver must read the media (boot sector, directory structure and both File Allocation Tables in order to perform a write. Reading is simpler than writing. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|
|
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
|