Find out more information:
https://bit.ly/32F746GDISCOVERY
https://bit.ly/STM32CubeIDE-yt
https://bit.ly/FatFSinfo
In this video we will explain you how to create a file system on a SD card using STM32 and ST Toolsets. This is useful for data logging type of application where you need to write data files on an external media like a SD card.
Introduction: 0:00
Board used: 2:32
Beginning of exercise: 2:54
Live Demo: 11:40
Code available here: http://www.st.com/content/dam/AME/202...
/* USER CODE BEGIN 1 */
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
uint8_t rtext[_MAX_SS];/* File read buffer */
/* USER CODE END 1 */
...
/* USER CODE BEGIN 2 */
if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) != FR_OK)
{
Error_Handler();
}
else
{
if(f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext)) != FR_OK)
{
Error_Handler();
}
else
{
//Open file for writing (Create)
if(f_open(&SDFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
Error_Handler();
}
else
{
//Write to the text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
Error_Handler();
}
else
{
f_close(&SDFile);
}
}
}
}
f_mount(&SDFatFS, (TCHAR const*)NULL, 0);
/* USER CODE END 2 */
Смотрите видео STM32 – Creating a File System on a SD card онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь STMicroelectronics 11 Декабрь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 48,609 раз и оно понравилось 487 людям.