Datasheet

The next program tests MMC FAT routines. First, we create 5 different files in the
root of MMC card, and fill with some information. Then, we read the files and send
them via UART for a check.
#include <built_in.h>
sbit Mmc_Chip_Select at PORTG.B1;
sbit Mmc_Chip_Select_Direction at DDRG.B1;
char
fat_txt[20] = "FAT16 not found",
file_contents[50] = "XX MMC/SD FAT16 library by Anton Rieckertn";
char
filename[14] = "MIKRO00xTXT"; // File names
unsigned short
tmp, caracter, loop, loop2;
unsigned long
i, size;
char Buffer[512];
//I-I-I--------- Writes string to USART
void I_Write_Str(char *ostr) {
unsigned short i;
i = 0;
while (ostr[i]) {
UART1_Write(ostr[i++]);
}
UART1_Write(0x0A);
}
//M-M-M--------- Creates new file and writes some data to it
void M_Create_New_File() {
filename[7] = 'A';
Mmc_Fat_Assign(&filename, 0xA0); // Will not find file and
then create file
Mmc_Fat_Rewrite(); // To clear file and start
with new data
for(loop = 1; loop <= 99; loop++) { // We want 5 files on the
MMC card
UART1_Write('.');
file_contents[0] = loop / 10 + 48;
file_contents[1] = loop % 10 + 48;
Mmc_Fat_Write(file_contents, 42); // write data to the assigned
file
}
}
341
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6