2011-07-29 05:43 AM
I use STM32F215.
I run uSDCard example from StandartPeriphLibrary. But there is no clock available at pin 53 ( PC12 ) and SD is not work. There is bug? My init code is:RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD, ENABLE);
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);// 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_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_UP; GPIO_Init(GPIOC, &GPIO_InitStructure);// Configure PD.02 CMD line
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_Init(GPIOD, &GPIO_InitStructure);// Configure PC.12 pin: CLK pin
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOC, &GPIO_InitStructure); RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, DISABLE); RCC_APB2PeriphClockCmd( RCC_APB2Periph_SDIO, ENABLE );RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_DMA2, ENABLE );
//!< Power ON Sequence --------------------------------------------------- //!< Configure the SDIO peripheral //!< SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_INIT_CLK_DIV //!< on STM32F2xx devices, SDIOCLK is fixed to 48MH //!< SDIO_CK for initialization should not exceed 400 KHz SDIO_InitStructure2.SDIO_ClockDiv = 0x78; SDIO_InitStructure2.SDIO_ClockEdge = SDIO_ClockEdge_Rising; SDIO_InitStructure2.SDIO_ClockBypass = SDIO_ClockBypass_Disable; SDIO_InitStructure2.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; SDIO_InitStructure2.SDIO_BusWide = SDIO_BusWide_1b; SDIO_InitStructure2.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; SDIO_Init(&SDIO_InitStructure2);//!< Set Power State to ON */
SDIO_SetPowerState(SDIO_PowerState_ON);SDIO_ClockCmd(ENABLE);
while( 1);SDIO_CmdInitStructure2.SDIO_Argument = 0x0;
SDIO_CmdInitStructure2.SDIO_CmdIndex = 0; SDIO_CmdInitStructure2.SDIO_Response = SDIO_Response_No; SDIO_CmdInitStructure2.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure2.SDIO_CPSM = SDIO_CPSM_Enable;//RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDIO, ENABLE);
//while( 1 ){ SDIO_SendCommand(&SDIO_CmdInitStructure2); //while( (SDIO_GetFlagStatus(SDIO_FLAG_CMDSENT) == RESET) ); //while(1); I think when while(1) is running, clock will appear, but clock is in low state always. #sdio #stm32f215