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.
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.
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?
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".
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.
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.