User manual

430
mikoC PRO for dsPIC
MikroElektronika
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;
ADPCFG = 0xFFFF; // initialize AN pins as digital
//--- set up USART for the le read
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_
PRI_64,
_SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_
ACTIVE_2_IDLE);
UART1_Init(19200); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize