Hi,
I am facing the following problem in trying to interface a PIC micro with an SD card via SPI :
1- I take a card I usually use with my camera and format it with Windows in FAT32.
2- I try to read the first 512 bytes block on the card with the PIC (BOOT sector) by reading directly the bytes on the card.
=> the card positively answers to the reading request, but I read mostly zeros, except some bytes, but they correspond to nothing really on the card.
3- I then erase this first 512 block with the PIC by writing for example 0x1F everywhere.
=> If I then read the content of this first block again with the PIC, I properly get what I just wrote.
4- Moreover, if I format the card again in Windows, I can now read with the PIC this same first block (which now holds the BOOT sector data written by Windows when formatting), which was not working at step 2-.
In summary, everything happens as if the card was initially locked, and I had to write at least once this first block with the PIC or it can never be read with the PIC.
5- Now, if I reformat the card with my camera, I'm back to step 1- and can't read the card anymore with the PIC.
Does anybody have any idea on what's happening ?
Note :
- I have tested this with several cards. All do the same.
- I have fully tested my PIC program with apparently properly initializes the card and reads / writes data in it. I say this because once I have "unlocked" the card once as described above, all my program perfectly works.
Thank's in advance,
GB
I am facing the following problem in trying to interface a PIC micro with an SD card via SPI :
1- I take a card I usually use with my camera and format it with Windows in FAT32.
2- I try to read the first 512 bytes block on the card with the PIC (BOOT sector) by reading directly the bytes on the card.
=> the card positively answers to the reading request, but I read mostly zeros, except some bytes, but they correspond to nothing really on the card.
3- I then erase this first 512 block with the PIC by writing for example 0x1F everywhere.
=> If I then read the content of this first block again with the PIC, I properly get what I just wrote.
4- Moreover, if I format the card again in Windows, I can now read with the PIC this same first block (which now holds the BOOT sector data written by Windows when formatting), which was not working at step 2-.
In summary, everything happens as if the card was initially locked, and I had to write at least once this first block with the PIC or it can never be read with the PIC.
5- Now, if I reformat the card with my camera, I'm back to step 1- and can't read the card anymore with the PIC.
Does anybody have any idea on what's happening ?
Note :
- I have tested this with several cards. All do the same.
- I have fully tested my PIC program with apparently properly initializes the card and reads / writes data in it. I say this because once I have "unlocked" the card once as described above, all my program perfectly works.
Thank's in advance,
GB