User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
305
}
}
// Tries to create a swap le, whose size will be at least 100
// sectors (see Help for details)
void M_Create_Swap_File() {
unsigned int i;
for(i=0; i<512; i++)
Buffer[i] = i;
size = Cf_Fat_Get_Swap_File(5000, “mikroE.txt”, 0x20); // see help on this function
for details
if (size) {
LongToStr((signed long)size, err_txt);
UART1_Write_Line(err_txt);
for(i=0; i<5000; i++) {
Cf_Write_Sector(size++, Buffer);
UART1_Write(‘.’);
}
}
}
// Main. Uncomment the function(s) to test the desired operation(s)
void main() {
#dene COMPLETE_EXAMPLE // comment this line to make simpler/smaller example
CHECON = 0x32;
AD1PCFG = 0xFFFF; // disable A/D inputs
// Initialize UART1 module
UART1_Init(56000);
Delay_ms(10);
UART1_Write_Line(“MCU-Started”); // MCU present report
// use fat16 quick format instead of init routine if a formatting is needed
if (Cf_Fat_Init() == 0) {
Delay_ms(2000); // wait for a while until the card is stabilized
// period depends on used CF card
//--- Test start
UART1_Write_Line(“Test Start.”);
//--- Test routines. Uncomment them one-by-one to test certain features
M_Create_New_File();
#ifdef COMPLETE_EXAMPLE
M_Create_Multiple_Files();
M_Open_File_Rewrite();
M_Open_File_Append();
M_Open_File_Read();
M_Delete_File();
M_Test_File_Exist();
M_Create_Swap_File();
#endif
UART1_Write_Line(“Test End.”);