OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4332|回复: 1

SD初始化正确,但是在读取多块数据的时候总是卡在SD_ReadMultiBlocks这个函数里面

[复制链接]

15

主题

41

帖子

0

精华

初级会员

Rank: 2

积分
129
金钱
129
注册时间
2015-2-17
在线时间
3 小时
发表于 2015-6-27 08:30:54 | 显示全部楼层 |阅读模式
5金钱
[mw_shl_code=c,true]/** * @brief Allows to read blocks from a specified address in a card. The Data * transfer can be managed by DMA mode or Polling mode. //·????????? * @note This operation should be followed by two functions to check if the * DMA Controller and SD Card status. //dma?????±???÷?????????????? * - SD_ReadWaitOperation(): this function insure that the DMA * controller has finished all data transfer. * - SD_GetStatus(): to check that the SD Card has finished the * data transfer and it is ready for data. * @param readbuff: pointer to the buffer that will contain the received data. * @param ReadAddr: Address from where data are to be read. * @param BlockSize: the SD card Data block size. The Block size should be 512. * @param NumberOfBlocks: number of blocks to be read. * @retval SD_Error: SD Card Error code. */ SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) { SD_Error errorstatus = SD_OK; TransferError = SD_OK; TransferEnd = 0; StopCondition = 1; SDIO->DCTRL = 0x0; //?????????????????÷ if (CardType == SDIO_HIGH_CAPACITY_SD_CARD)//sdhc?¨?????·???é???????????é512×??? { BlockSize = 512; ReadAddr /= 512; } /*!< Set Block Size for Card??cmd16,????sdsc?¨???????????è???é?ó????????sdhc?¨???é?ó????512×?????????cmd16?°?ì */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) BlockSize; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; //r1 SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN); if (SD_OK != errorstatus) { return(errorstatus); } SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; //???????±???? SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize; //?????é???????????????¤???????÷????????±??????????é?¤??(??SDIO_DCTRL)??±??? SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4; //?±?????????à????????SDIO_DataBlockSize_512b SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO;//????·??ò SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; //???????? SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; //????????×????ú SDIO_DataConfig(&SDIO_DataInitStructure); /*!< Send CMD18 READ_MULT_BLOCK with argument data address */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)ReadAddr; //???????· SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_READ_MULT_BLOCK; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; //r1 SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_READ_MULT_BLOCK); if (errorstatus != SD_OK) { return(errorstatus); } SDIO_ITConfig(SDIO_IT_DATAEND, ENABLE); //?????????????á?????? ??Data end (data counter, SDIDCOUNT, is zero) interrupt SDIO_DMACmd(ENABLE); //????dma·??? SD_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize));//????DMA???? return(errorstatus); }[/mw_shl_code]

SD初始化正确,但是在读取多块数据的时候总是卡在SD_ReadMultiBlocks这个函数里面
求大家告知一下这是什么问题?要怎么解决啊?

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

230

主题

1950

帖子

10

精华

论坛元老

Rank: 8Rank: 8

积分
4562
金钱
4562
注册时间
2010-12-14
在线时间
32 小时
发表于 2015-6-27 11:07:01 | 显示全部楼层
用的什么板子?我们都配有SDIO历程。
我是开源电子网?网站管理员,对网站有任何问题,请与我联系!QQ:389063473Email:389063473@qq.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-20 22:54

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表