Bug on SDcard and stm32f415 ?
Hi, i have a problem with my project....I'm using Fat and SD with freertos to read/write files on SD using hdma channel.
First part i fixed all "SDIO_STA_STBITER" with "SDIO_STA_STBITERR" (with 2 "R" ) because a typo is present.
But i see the interrupt HAL_SD_IRQHandler starting without reason .
For example,
if( f_open( &MyFile, MyFileName, FA_READ ) == FR_OK )
{
/* Get file status */
FileOut.size = MyFileInfo.fsize;
f_close( &MyFile );
}
else
{
// tiro una bestemmia
}
while ( 1 ) osDelay ( 100 );
Here the operation on SD must be completed.... instead, if you put now a brakpoint on HAL_SD_IRQHandler , you will see in random time (can be immediatly or after also 5/6 minutes) a interrupt request generated by SDIO_IT_DTIMEOUT.
This interrupt will call a HAL_DMA_Abort_IT() and all the next operations of writing will fail because the pointer to hdmtx its void
Have you forgot some parts ?
Its normal to keep SD interrupts active also after the end of operations ?
And also inside HAL_SD_IRQHandler ....
/* Abort the SD DMA Streams */
if(hsd->hdmatx != NULL)
{
/* Set the DMA Tx abort callback */
hsd->hdmatx->XferAbortCallback = SD_DMATxAbort;
/* Abort DMA in IT mode */
if(HAL_DMA_Abort_IT(hsd->hdmatx) != HAL_OK)
{
SD_DMATxAbort(hsd->hdmatx);
}
}
else if(hsd->hdmarx != NULL)
{
/* Set the DMA Rx abort callback */
hsd->hdmarx->XferAbortCallback = SD_DMARxAbort;
/* Abort DMA in IT mode */
if(HAL_DMA_Abort_IT(hsd->hdmarx) != HAL_OK)
{
SD_DMARxAbort(hsd->hdmarx);
}
}
else
{
hsd->ErrorCode = HAL_SD_ERROR_NONE;
hsd->State = HAL_SD_STATE_READY;
HAL_SD_AbortCallback(hsd);
}
Comment say "/* Abort the SD DMA Streams */"... are you sure abort streams ? With "else" between, you will abort only one stream for each errror.... so first error abort "hdmatx", second error abort "hdmarx" and third error you will call "HAL_SD_AbortCallback"..
What did you want to do ?
I know, my english is worse than yours code ! =)
Bye bye
