Datasheet

else {
//--- file was not found - signal it
UART1_Write(0x55);
Delay_ms(1000);
UART1_Write(0x55);
}
}
//-------------- Tries to create a swap file, 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 = Mmc_Fat_Get_Swap_File(5000, "mikroE.txt", 0x20); // see
help on this function for details
if (size) {
LongToStr((signed long)size, fat_txt);
I_Write_Str(fat_txt);
for(i=0; i<5000; i++) {
Mmc_Write_Sector(size++, Buffer);
UART1_Write('.');
}
}
}
//-------------- Main. Uncomment the function(s) to test the desired
operation(s)
void main() {
// we will use PORTC to signal test end
DDRC = 0xFF;
PORTC = 0;
Spi_Rd_Ptr = SPI1_Read;
// use fat16 quick format instead of init routine if a format-
ting is needed
if (!Mmc_Fat_Init()) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2,
_SPI_CLK_LO_LEADING);
//--- Test start
//--- Test routines. Uncomment them one-by-one to test cer-
tain features
344
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6