Advanced PIC18 Projects—SD Card Projects:Read/Write to SD Card Sectors

PROJECT 7.2—Read/Write to SD Card Sectors

The hardware of this project is the same as for Project 7.1 (i.e., as shown in Figure 7.8). In this project, sector 10 of the SD card is filled with “C” characters, and then this sector is read and the card data is sent to the UART.

The program listing of this project is given in Figure 7.11 (program SD2.C). Two character arrays called data1 and data2, of 512 bytes each, are declared at the beginning of the program. Array data1 is loaded with character “C,” and

the contents of this array are written to sector 10 of the SD card. Then the contents of sector 10 are read into character array data2 and sent to the UART, displaying 512 “C” characters on the PC screen. Normally, only one array is used to read and write to the SD card. Two arrays are used here to make it clear that what is sent to the UART is the card data, not the contents of array data1.

Leave a comment

Your email address will not be published. Required fields are marked *