cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO Clock at 48mHz, D3:0 at F, CMD line works. Thank you.

slagment
Associate II
Posted on February 27, 2012 at 22:14

My SDIO clock won't divide(stuck at 48mHz) and the data lines are stuck high. I've fiddle with every setting and checked the PLL several times. Can anyone spot my mistake. Thank you.

Using STM32F407

uint32_t regSDIO_CLKCR;

GPIO_InitTypeDef GPIO_InitStructure;

SDIO_InitTypeDef SDIO_InitStructure;

/* GPIOC and GPIOD Periph clock enable */

RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD, ENABLE );

/* Enable the SDIO APB2 Clock */

RCC_APB2PeriphClockCmd( RCC_APB2Periph_SDIO, ENABLE );

/* Configure PC.12 pin: CLK pin */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIOC->BSRRL = GPIO_Pin_12;

GPIOC->BSRRH = GPIO_Pin_12;

GPIOC->BSRRL = GPIO_Pin_12;

GPIOC->BSRRH = GPIO_Pin_12;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_Init(GPIOC, &GPIO_InitStructure);

/* Configure PD.02 CMD line */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_Init(GPIOD, &GPIO_InitStructure);

/* Configure PC.08, PC.09, PC.10, PC.11 pins: D0, D1, D2, D3 pins */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_SDIO);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_SDIO);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SDIO);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SDIO);

GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SDIO);

GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_SDIO);

SDIO_InitStructure.SDIO_ClockDiv = 32;//SDIO_INIT_CLK_DIV;

SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;

SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Enable;

SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;

SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_4b;

SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;

SDIO_Init(&SDIO_InitStructure);

/*!< Set Power State to ON */

SDIO_SetPowerState(SDIO_PowerState_ON);

regSDIO_CLKCR = SDIO->CLKCR;

LCD_SetCursor ( 0, 0 );

sprintf( tmp, ''CLOCK %h'', regSDIO_CLKCR);

LCD_write_str((unsigned char *)tmp);

/*!< Enable SDIO Clock */

SDIO_ClockCmd(ENABLE);

regSDIO_CLKCR = SDIO->CLKCR;

LCD_SetCursor ( 0, 1 );

sprintf( tmp, ''CLOCK %h'', regSDIO_CLKCR);

LCD_write_str((unsigned char *)tmp);

while( 1 )

{

//CMD0 Go idle.

SDIO_CmdInitTypeDef SDIO_CmdInitStructure; //Structure.

SDIO_CmdInitStructure.SDIO_Argument = 0x0;

SDIO_CmdInitStructure.SDIO_CmdIndex = 0;

SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_No;

SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;

SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;

SDIO_SendCommand(&SDIO_CmdInitStructure);

}

stm32-sdio-sdio_clk-clock-48mhz

2 REPLIES 2
aqueisser
Senior
Posted on February 28, 2012 at 02:15

Try it without the SDIO clock bypass enabled, I think that defeats the divisor.

I've got this in my init and the clock divisor works:

SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;

slagment
Associate II
Posted on February 29, 2012 at 21:43

That did it, thanks.