Datasheet

filename[7] = 'C';
Cf_Fat_Assign(&filename, 0);
Cf_Fat_Rewrite();
for(loop = 1; loop <= 55; loop++) {
file_contents[0] = loop / 10 + 64;
file_contents[1] = loop % 10 + 64;
Cf_Fat_Write(file_contents, 38); // write data to the assigned
file
}
}
//-------------- Opens an existing file and appends data to it
// (and alters the date/time stamp)
void M_Open_File_Append() {
filename[7] = 'B';
Cf_Fat_Assign(&filename, 0);
Cf_Fat_Set_File_Date(2005,6,21,10,35,0);
Cf_Fat_Append(); // Prepare
file for append
Cf_Fat_Write(" for mikroElektronika 2005n", 27); // Write data
to assigned file
}
//-------------- Opens an existing file, reads data from it and puts
it to USART
void M_Open_File_Read() {
filename[7] = 'B';
Cf_Fat_Assign(&filename, 0);
Cf_Fat_Reset(&size); // To read file, procedure returns
size of file
for (i = 1; i <= size; i++) {
Cf_Fat_Read(&caracter);
UART1_Write(caracter); // Write data to USART
}
}
//-------------- Deletes a file. If file doesn't exist, it will first
be created
// and then deleted.
void M_Delete_File() {
filename[7] = 'F';
Cf_Fat_Assign(filename, 0);
Cf_Fat_Delete();
}
271
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6