mikroC Language SD Card Library Functions
The mikroC language provides an extensive set of library functions to read and write data to SD cards (and also MultiMediaCards, MMC). Data can be written to or read from a given sector of the card, or the file system on the card can be used for more sophisticated applications.
The following library functions are provided:
• Mmc_Init (initialize the card)
• Mmc_Read_Sector (read one sector of data)
• Mmc_Write_Sector (write one sector of data)
• Mmc_Read_Cid (read CID register)
• Mmc_Read_Csd (read CSD register)
• Mmc_Fat_Init (initialize FAT)
• Mmc_Fat_QuickFormat (format the card to FAT16)
• Mmc_Fat_Assign (assign the file we will be working with)
• Mmc_Fat_Reset (reset the file pointer; opens the currently assigned file for reading)
• Mmc_Fat_Rewrite (reset the file pointer and clear assigned file; opens
the assigned file for writing)
• Mmc_Fat_Append (move file pointer to the end of assigned file so new data can be appended to the file)
• Mmc_Fat_Read (read the byte the file pointer points to)
• Mmc_Fat_Write (write a block of data to the assigned file)
• Mmc_Set_File_Date (write system timestamp to a file)
• Mmc_Fat_Delete (delete a file)
• Mmc_Fat_Get_File_Date (read file timestamp)
• Mmc_Fat_Get_File_Size (get file size in bytes)
• Mmc_Fat_Get_Swap_File (create a swap file)
In the remainder of this chapter we will look at some SD-card and PIC18 microcontroller-based projects.