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

sd card interface pic help me out

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



Joined: 26 Oct 2009
Posts: 16

View user's profile Send private message

sd card interface pic help me out
PostPosted: Thu Dec 31, 2009 6:42 am     Reply with quote

I'm interfacing micro sd card with pic 16f877a... I'm using external oscillator of 20mhz...I just tried out the example in CCS EX_SPI.C...if I write A DATA in a particular address when I read I cannot read the data I wrote I'm getting value of 00...can anyone help me out.......
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Dec 31, 2009 7:19 am     Reply with quote

Without details about your hardware and software it is difficult to point the error.

A few general comments though:
- What is your compiler version number?
- A PIC16 is a poor choice because the SD card has to be written in blocks of 512 bytes. The PIC16 does not have that large RAM making things complicated. Better use a PIC18.
- A PIC16 at 20MHz requires 5V. The SD card requires 3.3V or less. Describe the hardware circuit between your PIC and the SD card to compensate for the voltage difference. A lower clocked PIC at 3.3V would be more stable.
picfreak



Joined: 26 Oct 2009
Posts: 16

View user's profile Send private message

PostPosted: Tue Jan 05, 2010 6:09 pm     Reply with quote

sorry for the late reply...
1) I am using ccs version 4.084.
2) ya I have connected 3.3V VDD to SD CARD. Connected a voltage divider to CLK PIN and SDA PIN of SD CARD.
just_learn
Guest







I want to know about the interface sd card with pic
PostPosted: Wed Jan 06, 2010 2:21 am     Reply with quote

I want to make my project and I don't know actually how to connect SD card with PIC.

Anybody can help me how to solve this ? Maybe give me WEB or something that can help me figure it out.
Ttelmah
Guest







PostPosted: Wed Jan 06, 2010 4:52 am     Reply with quote

picfreak wrote:
sorry for the late reply...
1) I am using ccs version 4.084.
2) ya I have connected 3.3V VDD to SD CARD. Connected a voltage divider to CLK PIN and SDA PIN of SD CARD.


Are you using the hardware SPI?.
You probably need a hardware buffer, on the data line coming from the SPI chip.
You have two lines 'from' the PIC, SCL, and SDO, which can use resistive dividers, but the line coming back from the SD card, 'to' the PIC, feeding SDI, needs to have it's voltage _increased_. The PIC input on this line, requires a 'high', of 4v (0.8*Vdd). A 3.3v chip is not going to give this, so you need a buffer chip...
The alternative, is to use software SPI, and then you can use a PIC input that has a TTL input buffer, rather than a Schmitt one. Even then, it is worth adding a pull-up resistor, to ensure that the signal goes high enough. Really much better to use proper buffers in both directions....

Best Wishes
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: I want to know about the interface sd card with pic
PostPosted: Wed Jan 06, 2010 11:00 pm     Reply with quote

just_learn wrote:
I want to make my project and I don't know actually how to connect SD card with PIC.

Anybody can help me how to solve this ? Maybe give me WEB or something that can help me figure it out.


Checkout my site. At the bottom of the software page you will find some general guidelines. On the projects page you will see a number of proven reference designs
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
picfreak



Joined: 26 Oct 2009
Posts: 16

View user's profile Send private message

PostPosted: Thu Jan 07, 2010 6:52 pm     Reply with quote

i am using software spi...
ya i connected of DO of sd card to SDI of pic directly.. scl pin and SDO pin of pic to sd card clk and DI pin i connected an divider circuit...for cs i gave 3.3v
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Jan 07, 2010 8:06 pm     Reply with quote

picfreak wrote:
i am using software spi...
ya i connected of DO of sd card to SDI of pic directly.. scl pin and SDO pin of pic to sd card clk and DI pin i connected an divider circuit...for cs i gave 3.3v


Software SPI for SD interfacing is downright ugly especially if you are planning to implement the FAT file system because of the hugh volume of data that must traverse the bus.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah
Guest







PostPosted: Fri Jan 08, 2010 5:25 am     Reply with quote

CS, needs to be operated by the PIC, if you are to have any hope of synchronising the transactions. Without this being operated, any noise on the lines during switch on, and clock edges generated as the code sets the lines to the idle states, will be 'seen' by the card, and it'll be out of sync with the PIC. Transactions then won't work.

Seriously, to get this working properly, I'd say switch to a 3.3v compatible PIC, which will massively simplify the connections, or use a proper 5v to 3.3v level translator. As it stands, I'd say the chance that your connections 'work', is less than 15%. Then add the CS line.
Then whether this is going to be 'useable' for anything, depends on what you want to do.
The sector size on SD, is 512 bytes, and I'd say that doing anything much with an SD card, without at least this much RAM, is very unlikely to work....

Best Wishes
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

Re: sd card interface pic help me out
PostPosted: Sat Jan 09, 2010 7:31 am     Reply with quote

picfreak wrote:
I'm interfacing micro sd card with pic 16f877a...
My understanding is that only regular SD and MiniSD cards are required to support an SPI interface. MicroSD cards are not. It's possible your MicroSD card doesn't support SPI.
_________________
Andrew
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: sd card interface pic help me out
PostPosted: Sat Jan 09, 2010 7:55 am     Reply with quote

andrewg wrote:
picfreak wrote:
I'm interfacing micro sd card with pic 16f877a...
My understanding is that only regular SD and MiniSD cards are required to support an SPI interface. MicroSD cards are not. It's possible your MicroSD card doesn't support SPI.


SPI support has been dropped from the SD spec covering all variants. I have tested lots of SD, miniSD and microSD cards both standard and HD have have yet to find any that do not work with the SPI bus.

Doing any SD related work with a 16F processor is a waste of time.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
picfreak



Joined: 26 Oct 2009
Posts: 16

View user's profile Send private message

PostPosted: Tue Jan 12, 2010 12:24 am     Reply with quote

Ok friends I'll do what you said. If anyone can provide me any application notes. From Microchip site I downloaded two application notes going through that. If any have a better application notes post here.

regards
pic freak
picfreak



Joined: 26 Oct 2009
Posts: 16

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 5:35 am     Reply with quote

I am interfacing sd card with pic in Proteus.
Defaultly in my Proteus 5v is obtain.
How to change 5v to 3.3v in Proteus ? Can anyone help me out.
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