• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing SD Card with PIC

Status
Not open for further replies.

ramygammal

New Member
Hi, I want to know how tho interface an SD Card with 16f877A PIC Microcontroller.I need to write to it,erase it and read from it.also I don't know how to connect it the PIC.
thanks
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
This is very difficult on a PIC16F877A as the buffer required to read/write is 256 bytes. You really require two of these buffers, but you only have 384 bytes available. My advice would be to upgrade to the PIC18F4520 and use all the free tools from MICROCHIP. They have extensive libraries for this application. The PIC18F4520 is a drop in replacement.

Cheers Ian
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Actually I may have jumped in with two left feet!! I assumed that you would be using dos, the FAT buffers can only read and write complete sectors (256 bytes) minimum.. You may only want to use the SD as personal storage. Do you need to access files from a PC?

Cheers Ian
 

Exo

Active Member
The SD card requires reading and writing to be done in blocks, called sectors - wich have a native size of 512 bytes. This means that you must have 512bytes of ram to store a sector in before writing it out to the SD or to store a incoming sector. The 16F877A does not have enough memory for this.
 

Mr RB

Well-Known Member
If you don't need file (FAT16) access you can read and write sectors from a small PIC like a 16F. However depending on how much RAM is available you might not be able to use full sectors, just part of each sector.

But either way it's not going to be easy for a beginner who "doesn't know how to connect it to a PIC".
 

kian2003

New Member
if you are beginner you can use the(c or basic) compiler that have a SD card reader library.like mikroC or mikroBASIC.
 

kian2003

New Member
yes,as described befor using the 16f877a is so difficalt.I mean that you have to know about micro and digital(for SD card) professionally.
but if you change your micro to 18f(no difference what your compiler is.)using SD card maybe more easier
and using mikroC or mikroBASIC because of its library make the project more easy.
 

Mr RB

Well-Known Member
Yes that is correct mikroC has ALL the fully functional libraries FAT 16 as well.

Cheers Ian
MikroC is a great compiler and has FAT16 read file and write file operations, but you need to have a filename.

At this point it does not have functions to read a directory and find all the filenames, although there are some good working user-examples of how to do that on the MikroC forum. I believe MikroE are going to add directory read functions to future revisions of the MikroC compiler.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top