2019-06-26 01:55 AM
I have managed to get reading and writing of SD card to work, however I still don't really get how does reading the SDIO's FIFO work.
From tracing the code, I reading the FIFO is done by the SDIO_ReadFIFO() function in stm32f4xx_ll_sdmmc.c.
/**
* @brief Read data (word) from Rx FIFO in blocking mode (polling)
* @param SDIOx Pointer to SDMMC register base
* @retval HAL status
*/
uint32_t SDIO_ReadFIFO(SDIO_TypeDef *SDIOx)
{
/* Read data from Rx FIFO */
return (SDIOx->FIFO);
}
The function simply returns the value at the FIFO address and every time this function is called, the value changes simply from reading it.
I can't figure out how does this work? How does the SD card's FIFO know that I have already read and knows to shift the FIFO? There are no setting of flags of such in the code under HAL_SD_ReadBlocks().
if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXFIFOHF))
{
/* Read data from SDIO Rx FIFO */
for(count = 0U; count < 8U; count++)
{
*(tempbuff + count) = SDIO_ReadFIFO(hsd->Instance);
}
tempbuff += 8U;
}
Are there any kind knowledgeable souls around to explain this? I poured over the datasheet, reference manual, code documentation and I couldn't figure it out. Sorry if it is an obvious question.
2019-06-26 02:01 AM
Peripheral space doesn't act like a memory cell, there is logic behind it interfacing with more complex structures and state machines.
The act of reading increments a counter indexing into another memory array.
2019-06-26 02:04 AM
Got it. Any idea where is this documented?