2024-06-18 10:25 PM
Hi,
I am try to read memory card hex file data to use STM cube IDE FATES library.
but FATES library take nearly 20 KB of memory. so if any other way is there means recommend to me.
controller : STM32F103
IDE : STM32 Cube IDE.
thank you.
2024-06-18 11:50 PM
on a STM32F103, you can use FATFS and it is not taking some much of memory (RAM),
I recommend to update chan fates to 0.15 to be able to manage long filename (instead of 0.11).
As well if your application is time critical you should use your own SPI function to avoid Hal overhead.
I hope it helps
2024-06-19 12:11 AM
thanks for your response,
Kindly giver a sample code for use Memory card SPI read method.
2024-06-19 12:19 AM
Please Have a look at this one this is working
https://01001000.xyz/2020-08-09-Tutorial-STM32CubeIDE-SD-card/
Regarding Baremetal SPI for SDCard on time critical I use this
__attribute__((optimize("-Ofast"))) static bool SD_RxDataBlockFast(BYTE *buff, UINT len){
uint8_t token;
Timer1 = 200;
SPI_HandleTypeDef *hspi=&hspi2;
uint32_t txallowed = 1U;
if ((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE)
{
/* Enable SPI peripheral */
__HAL_SPI_ENABLE(hspi);
}
do{
if ((__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) && (txallowed == 1U)){
*(__IO uint8_t *)&hspi->Instance->DR = 0xFF;
txallowed = 0U;
}
if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)){
token= hspi->Instance->DR;
txallowed = 1U;
}
}while((token == 0xFF) && Timer1);
if(token != 0xFE) return FALSE;
do{
if ((__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) && (txallowed == 1U)){
*(__IO uint8_t *)&hspi->Instance->DR = 0xFF;
txallowed = 0U;
}
if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)){
*buff= hspi->Instance->DR;
buff++;
len--;
txallowed = 1U;
}
}while(len);
/* Clear overrun flag in 2 Lines communication mode because received is not read */
if (hspi->Init.Direction == SPI_DIRECTION_2LINES)
{
__HAL_SPI_CLEAR_OVRFLAG(hspi);
}
hspi->State = HAL_SPI_STATE_READY;
/* discard CRC */
SPI_RxByte();
SPI_RxByte();
return TRUE;
}