使用官方的 示例代码中的 SDIO_SD工程。
自己做的评估板,想同时使用 10M ETH PHY, 和 SD卡。 看到datasheet中可以将PB14,PB15作为 SDIO_D1和 SDIO_DO 使用。
SD_Error SD_Init( void ) { NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; u8 clkdiv = 0; SD_Error errorstatus = SD_OK; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC |RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD, ENABLE ); RCC_AHBPeriphClockCmd( RCC_AHBPeriph_SDIO | RCC_AHBPeriph_DMA2, ENABLE ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init( GPIOC, &GPIO_InitStructure ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init( GPIOB, &GPIO_InitStructure ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init( GPIOD, &GPIO_InitStructure ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init( GPIOD, &GPIO_InitStructure ); GPIO_ResetBits(GPIOD, GPIO_Pin_4); SDIO_DeInit(); NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init( &NVIC_InitStructure ); errorstatus = SD_PowerON(); if( errorstatus == SD_OK ) { errorstatus = SD_InitializeCards(); } if( errorstatus == SD_OK ) { errorstatus = SD_GetCardInfo( &SDCardInfo ); } if( errorstatus == SD_OK ) { errorstatus = SD_SelectDeselect( ( u32 )( SDCardInfo.RCA << 16 ) ); } if( errorstatus == SD_OK ) { errorstatus = SD_EnableWideBusOperation( 1 ); } if( ( errorstatus == SD_OK ) || ( SDIO_MULTIMEDIA_CARD == CardType ) ) { if( SDCardInfo.CardType == SDIO_STD_CAPACITY_SD_CARD_V1_1 || SDCardInfo.CardType == SDIO_STD_CAPACITY_SD_CARD_V2_0 ) { clkdiv = SDIO_TRANSFER_CLK_DIV + 6; } else { clkdiv = SDIO_TRANSFER_CLK_DIV + 1; } SDIO_Clock_Set( clkdiv ); errorstatus = SD_SetDeviceMode( SD_POLLING_MODE ); } return errorstatus; }
------------------------
不知道为什么 会卡在 FindSCR 函数中
另外 一块 同样的电路板,直接CmdResp1Error,现象还不一样
----------------------------------
能给点提示吗? 同时使用 10M Eth 和sd卡 ,可以吗?使用PB14,PB15作为 SDIO_D1,SDIO_D0, 有什么特殊要求吗?