Access to SDIO

Post your requests and ideas on the future development of mikroC PRO for ARM.
Post Reply
Author
Message
jdcowpland
Posts: 91
Joined: 10 Sep 2013 11:01

Access to SDIO

#1 Post by jdcowpland » 07 Oct 2013 15:44

Hi,

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;}
 }
}

jdcowpland
Posts: 91
Joined: 10 Sep 2013 11:01

Re: Access to SDIO

#2 Post by jdcowpland » 07 Oct 2013 15:48

Sorry, just realised I posted this in the wrong forum. Will re-open it in the right one

Post Reply

Return to “mikroC PRO for ARM Wish List”