I'm trying to set up access to a SD card on my STM32F4 Discovery Board, and have a simple program which just calls the initialisation function and sets and LED based on the returned value. It works, but the LEDs are indicating that the function isn't picking up my SD card at all. Anyone got any troubleshooting tips that might help with finding where the issue is? Here's my code:
Code: Select all
unsigned int success;
sbit Mmc_Chip_Select at GPIOD_ODR.B12;
sbit MMC_Card_Detect at GPIOB_IDR.B15;
void main() {
// Reset module
SDIO_Reset();
Delay_ms(100);
// SDIO_CK frequency must be less than 400 kHz in identification mode
SDIO_Init(_SDIO_CFG_POWER_SAVE_DISABLE | _SDIO_CFG_4_WIDE_BUS_MODE | _SDIO_CFG_CLOCK_BYPASS_DISABLE
| _SDIO_CFG_CLOCK_RISING_EDGE | _SDIO_CFG_HW_FLOW_ENABLE, 120, &_GPIO_MODULE_SDIO_D0_D3);
// Set pull-ups on SDIO lines (if there is no external pull-ups)
//GPIOD_PUPDR |= 0x10;
//GPIOC_PUPDR |= 0x550000;
// Set SDIO interface
Mmc_Set_Interface(_MMC_INTERFACE_SDIO);
Mmc_Init();
// Init MMC
while(1){
success = Mmc_Fat_Init();
//SDIO_ClockCmd(_SDIO_ENABLE);
// Once the MMC/SD card is initialized, SDIO speed (SDIO_CK) can be increased
//SDIO_CLKCR &= ~(unsigned long)0xff;
//SDIO_CLKCR |= (unsigned long)0x2;
GPIO_Digital_Output(&GPIOD_ODR, _GPIO_PINMASK_13 | _GPIO_PINMASK_14 | _GPIO_PINMASK_15); // Set PORTF as digital output
GPIOD_ODR.B13 = 0;
GPIOD_ODR.B14 = 0;
GPIOD_ODR.B15 = 0;
GPIOD_ODR.B13 = 1;
if(success == 0){
GPIOD_ODR.B14 = 1;}
if(success == 255){
GPIOD_ODR.B15 = 1;}
}
}