Continue to Site

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.

  • 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
 
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
 
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
 
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.
 
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".
 
if you are beginner you can use the(c or basic) compiler that have a SD card reader library.like mikroC or mikroBASIC.
 
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.
 
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

New Articles From Microcontroller Tips

Back
Top