User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
379
Mmc_Fat_Write(le_contents, LINE_LEN-1); // write data to the assigned le
}
}
// Creates many new les and writes data to them
void M_Create_Multiple_Files() {
for(loop2 = ‘B’; loop2 <= ‘Z’; loop2++) {
UART1_Write(loop2); // signal the progress
lename[7] = loop2; // set lename
Mmc_Fat_Set_File_Date(2011,1,12,11,9,0); // Set le date & time info
Mmc_Fat_Assign(&lename, 0xA0); // nd existing le or create a new one
Mmc_Fat_Rewrite(); // To clear le and start with new data
for(loop = 1; loop <= 44; loop++) {
le_contents[0] = loop / 10 + 48;
le_contents[1] = loop % 10 + 48;
Mmc_Fat_Write(le_contents, LINE_LEN-1); // write data to the assigned le
}
}
}
// Opens an existing le and rewrites it
void M_Open_File_Rewrite() {
lename[7] = ‘C’;
Mmc_Fat_Assign(&lename, 0);
Mmc_Fat_Rewrite();
for(loop = 1; loop <= 55; loop++) {
le_contents[0] = loop / 10 + 48;
le_contents[1] = loop % 10 + 48;
Mmc_Fat_Write(le_contents, LINE_LEN-1); // write data to the assigned le
}
}
// Opens an existing le and appends data to it
// (and alters the date/time stamp)
void M_Open_File_Append() {
lename[7] = ‘B’;
Mmc_Fat_Assign(&lename, 0);
Mmc_Fat_Set_File_Date(2009, 1, 23, 17, 22, 0);
Mmc_Fat_Append(); // Prepare le for append
Mmc_Fat_Write(“ for mikroElektronika 2009\n”, 27); // Write data to assigned le
}
// Opens an existing le, reads data from it and puts it to UART
void M_Open_File_Read() {
char character;
lename[7] = ‘B’;
Mmc_Fat_Assign(&lename, 0);
Mmc_Fat_Reset(&size); // To read le, procedure returns size of le
for (i = 1; i <= size; i++) {
Mmc_Fat_Read(&character);
UART1_Write(character); // Write data to UART
}
}