cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO STM32F215 need help

v239955
Associate II
Posted on August 12, 2011 at 15:05

I have no clock on PC12. But when PC12 is OUT mode it is work. 

If I run mySDInit() I will see two jump on pc12 ( out mode test ). No clock. Where is the bug?

void mySDInit( void ){

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

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

 

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, ENABLE);

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, DISABLE);

 

  SDIO_InitStructure.SDIO_ClockDiv = 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_1b;

  SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;

  SDIO_Init(&SDIO_InitStructure);

  /*!< Set Power State to ON */

  SDIO_SetPowerState(SDIO_PowerState_ON);

  /*!< Enable SDIO Clock */

  SDIO_ClockCmd(ENABLE);

 

  regSDIO_CLKCR = SDIO->CLKCR;

 

  while( 1 );

}
4 REPLIES 4
v239955
Associate II
Posted on August 12, 2011 at 15:51

after SDIO_Init(&SDIO_InitStructure);

SDIO->CLKCR = 1142

it is ok;

but after

SDIO_ClockCmd(ENABLE);

SDIO->CLKCR is not change;

Clock enable bit is not assign. why?

When I change register after SDIO_Init manually  it is not change.

When I set this register in SDIO_Init :

  tmpreg |= (1<<8);

  SDIO->CLKCR = tmpreg;

then SDIO->CLKCR = 1398 (ok, clock enable bit is 1). But clock is not switch on.
aqueisser
Senior
Posted on August 12, 2011 at 18:03

Have you tried sending out a command? I use basically the same init sequence and send out a GO_IDLE command right afterwards. I can't remember if the clock shows up before any command goes out.

Andrew

v239955
Associate II
Posted on August 15, 2011 at 13:44

I have tried sending out a command. After call:

SDIO_SendCommand(&SDIO_CmdInitStructure);

All pin states do not change.
v239955
Associate II
Posted on August 15, 2011 at 17:13

Answer was found.

system_stm32f2xx.c set clock source from external crystall