User manual
mikroC PRO for dsPIC
MikroElektronika
431
U1MODEbits.ALTIO = 1; // Switch Rx and Tx pins on their alternate locations.
// This is used to free the pins for other module, namely the SPI.
//--- init the FAT library
if (!Mmc_Fat_Init()) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_
PRI_4,
_SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH,
_SPI_ACTIVE_2_IDLE);
//--- 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.");
}
else {
UART1_Write_Line(err_txt); // Note: Mmc_Fat_Init tries to initialize a card more
than once.
// If card is not present, initialization may last
longer (depending on clock speed)
}
}
HW Connection
Pin diagram of MMC memory card