Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
395
Mmc_Fat_QuickFormat
Prototype
sub function Mmc_Fat_QuickFormat(dim byref mmc_fat_label as string[11]) as 
word
Description Formats to FAT16 and initializes MMC/SD card.
Parameters 
mmc_fat_label
: volume label (11 characters in length). If less than 11 characters are provided, the 
label will be padded with spaces. If null string is passed volume will not be labeled 
Returns
0
 - if MMC/SD card was detected, successfully formated and initialized 
1
 - if FAT16 format was unseccessful 
255
 - if MMC/SD card was not detected 
Requires
The appropriate hardware SPI module must be previously initialized.
Example
// Initialize the SPI module
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);
// Format and initialize MMC/SD card and MMC_FAT16 library globals
Mmc_Fat_QuickFormat(“mikroE”);
// Reinitialize the SPI module at higher speed (change primary prescaler).
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);
Notes
This routine can be used instead or in conjunction with Mmc_Fat_Init routine.
If MMC/SD card already contains a valid boot sector, it will remain unchanged (except volume label 
field) and only FAT and ROOT tables will be erased. Also, the new volume label will be set.