User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
381
else {
//--- le was not found - signal it
UART1_Write(0x55);
Delay_ms(1000);
UART1_Write(0x55);
}
}
// 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 = Mmc_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++) {
Mmc_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
PORTD = 0;
TRISD = 0;
PORTF = 0;
TRISF = 0;
CHECON = 0x32;
AD1PCFG = 0xFFFF; // initialize AN pins as digital
// Initialize UART1 module
UART1_Init(19200);
Delay_ms(10);
UART1_Write_Line(“MCU-Started”); // MCU present report
//--- set up SPI for the le read
SPI2_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 64, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_
MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);
Delay_ms(10);
//--- init the FAT library
if (!Mmc_Fat_Init()) {
// reinitialize spi at higher speed
SPI2_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 8, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_
MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE);