在例程中
/********************************************************************* * @fn SDEnWideBus * * @brief Enable bus width * * @param enx - 0-disable 1-enable * * @return SD_Error - ERR code */ SD_Error SDEnWideBus( u8 enx ) { SD_Error errorstatus = SD_OK; u32 scr[2] = {0, 0}; u8 arg = 0X00; if( enx ) { arg = 0X02; } else { arg = 0X00; } if( SDIO->RESP1 & SD_CARD_LOCKED ) { return SD_LOCK_UNLOCK_FAILED; } errorstatus = FindSCR( RCA, scr ); if( errorstatus != SD_OK ) { return errorstatus; } if( ( scr[1]&SD_WIDE_BUS_SUPPORT ) != SD_ALLZERO ) { SDIO_CmdInitStructure.SDIO_Argument = ( uint32_t ) RCA << 16; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand( &SDIO_CmdInitStructure ); errorstatus = CmdResp1Error( SD_CMD_APP_CMD ); if( errorstatus != SD_OK ) { return errorstatus; } SDIO_CmdInitStructure.SDIO_Argument = arg; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_SD_SET_BUSWIDTH; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand( &SDIO_CmdInitStructure ); errorstatus = CmdResp1Error( SD_CMD_APP_SD_SET_BUSWIDTH ); return errorstatus; } else { return SD_REQUEST_NOT_APPLICABLE; } }
在进行SD_EnableWideBusOperation 切换的时候 会卡死在函数 SD_Error FindSCR中,一直在等待
/* sdio.c 1932行 */ while( !( SDIO->STA & ( SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR ) ) ) { if( SDIO_GetFlagStatus( SDIO_FLAG_RXDAVL ) != RESET ) { *( tempscr + index ) = SDIO_ReadData(); index++; if( index >= 2 ) { break; } } }
在函数中一直获取对应的标志位, 卡死在该函数中.
若不进行数据宽度切换, 似乎后面无法挂载SD卡?
热门产品 :
CH641: PD及无线充电专用MCU