Datasheet

Mmc_Fat_Init
327
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
unsigned short Mmc_Fat_Init();
Returns
- 0 - if MMC/SD card was detected and successfully initialized
-
1 - if FAT16 boot sector was not found
-
255 - if MMC/SD card was not detected
Description
Initializes MMC/SD card, reads MMC/SD FAT16 boot sector and extracts neces-
sary data needed by the library.
Note: MMC/SD card has to be formatted to FAT16 file system.
Requires
Global variables :
-
Mmc_Chip_Select: Chip Select line
- Mmc_Chip_Select_Direction: Direction of the Chip Select pin
must be defined before using this function.
The appropriate hardware SPI module must be previously initialized. See the
SPI1_Init, SPI1_Init_Advanced routines.
Example
// MMC module connections
sfr sbit Mmc_Chip_Select at PORTG.B1;
sfr sbit Mmc_Chip_Select_Direction at DDRG.B1;
// MMC module connections
// Pointer to appropriate SPI Read function
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV128, _SPI_CLK_LO_LEAD-
ING);
Spi_Rd_Ptr = SPI1_Read;
// use fat16 quick format instead of init routine if a formatting
is needed
if (!Mmc_Fat_Init()) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING);
...
}