2015-06-03 12:46 PM
2015-06-03 01:42 PM
/**
* @brief Reads Sector(s)
* @param *buff: Data buffer to store read data
* @param sector: Sector address (LBA)
* @param count: Number of sectors to read (1..128)
* @retval DRESULT: Operation result
*/
DRESULT SD_read(BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff,
(uint64_t)sector * BLOCK_SIZE,
BLOCK_SIZE,
count) != MSD_OK)
{
res = RES_ERROR;
}
return res;
}
/**
* @brief Writes Sector(s)
* @param *buff: Data to be written
* @param sector: Sector address (LBA)
* @param count: Number of sectors to write (1..128)
* @retval DRESULT: Operation result
*/
#if _USE_WRITE == 1
DRESULT SD_write(const BYTE *buff, DWORD sector, UINT count)
{
DRESULT res = RES_OK;
if(BSP_SD_WriteBlocks_DMA((uint32_t*)buff,
(uint64_t)sector * BLOCK_SIZE,
BLOCK_SIZE, count) != MSD_OK)
{
res = RES_ERROR;
}
return res;
}
#endif /* _USE_WRITE == 1 */
2015-06-03 01:43 PM
2015-06-03 02:35 PM
Hi Mark,
Thank you for the reply.I actually saw your post in another thread and attempted to do that (even though my current project does not show it). I went to STM32CubeMX and edited the DMA settings to match those you listed in your HAL_SD_MspInit() function. For some reason, the same errors were returned; I couldn't get past either the mounting or opening stages, dependent on whether or not I was linking the drivers.I can definitely believe that SD doesn't work well without DMA though; it seems as if it would be a good way of making sure data gets transferred in a timely fashion.Just to make sure, I did run it again. I get the error of FR_INVALID_DRIVE.