SD CARD using SPI in STM32 || Cube-IDE || File handling || uart

preview_player
Показать описание
________________________________________________________________________________________

How to interface SD card with STM32 using SPI MODE. I am using STM32CUBE iDE and STM32F103C8 controller.

************************ UPDATE 2nd JULY 20220****************************
If you are getting FR_NO_FILESYSTEM (mainly happening with LOW storage cards) with the new library, then use the older library from

************************* UPDATE 1st JULY 2020******************************

SPI can work upto 10 Mbps

F103C8 users...... If getting FR_NOT_READY error, use some external 5V power source. Power from board seems to be not enough (it could be current required for the module)

________________________________________________________________________________________

******* SUPPORT US BY DONATING******

*******Join the Membership*******

Рекомендации по теме
Комментарии
Автор

Great video, thank you so much for your help! As other users have mentioned, if using an stm32f0 discovery board, make sure to set the spi data size to 8 bits. I also ran into a error where I could not build my project with a max sector size of 4096 (too large) so I changed it to 2048 and it worked fine.

aricrowe
Автор

Awesome tutorial. I can confirm that this works on clone chip CS32F103 Bluepill board using 32Gig Transcend SD card . Thank you Controllers Tech for your hard work.

jamestroup
Автор

I have updated the code on 1st JULY 2020. Read the Description for more info.

ControllersTech
Автор

Thank you very much for your initiative. The only sensible code that I found after a long time of searching. But in the beginning there was a problem: the program did not always work. In the end, the whole problem was in SPI1. After connecting the microsd module to SPI2, the program always worked. I'm using stm32f4discovery (stm32f407vg microcontroller).

НикитаЩербаков-жх
Автор

Thanks for the video! I had to keep the MAXX_SS at 512 for my SDHC 16GB SanDisk to work.

divanbessinger
Автор

This helped a lot, thank you for the detailed walk-through!!!

golfercab
Автор

Great Video! Some boards set SPI to 4 bits ( hspi1.Init.DataSize = SPI_DATASIZE_8=4BIT). I changed it to ( hspi1.Init.DataSize = SPI_DATASIZE_8=8BIT). Btw I am using STM32F0Discovery Kit

lauchokyip
Автор

Thank you very much the best tutorials for stm32 in Youtube

ibrahimkhadraoui
Автор

Hello @ControllersTech I'm using the same MCU and same IDE as in your video, but my code gets stuck at HardFault_Handler(void) when i try to open a file. how to solve it?

mukulsharma-nouf
Автор

Excellent! One small bug. There is a buffer overrun when reading file2.txt after being appended to. The file has more than 128 bytes in it.

petervancaeseele
Автор

Nice video - I am planning a project to take sound files (.wav) from a SD card and output to I2s on a STM32F411 and I have never used Cube to program. This looks like a great starting point - thanks for all the work.

MrEdwardhartmann
Автор

Thanks, Can you pls share any example regarding GSM communication with USART(with CTS/RTS).

theraja
Автор

Thank you so much for posting this video! I was able to get it working with an SD card formatted with a block size (allocation unit size) of 512 bytes. How do you get it to work with other block sizes (for example, I'm trying to use a block size of 4096 bytes)? Is that possible?

ShawnHymel
Автор

Thanks for this Code
please keep going and make video like this video

self-studyelectronicengine
Автор

Thanks for the video. I tried to do everything according to your video, but it doesn't work.
I'm working with the same SD-card module as you, but with an STM32L432KC. The first problem is that I don't have fsize parameter in FIL typedef.
And the second is that it always says that the card is mounted successfully, even if there is NO CARD in the reader. What is more, I get Disk_error if I try to write or read a file on the card.
Could you please help me?

davidpelyva
Автор

Hello,
Everything working well. But i need to log 10 bytes of the data after every 5 milli seconds and this should be done for 24 hours,
The SPI hangs (remains in busy and locked state)after some times and i can only write for few mins of data.
Please suggest

utsavsuha
Автор

The video is very good, i know that the problem is with me, but i can identify the error. I used your whole code download and nothing

alexandrev.
Автор

Was such a helpful video. I made it work with a MSPm0l1306, by doing some small changes to implement my communication, but it was so helpful to understand how I would glue my applikation to the FATFS library. For some reason It wouldnt work in your user_diskio so i just moved all the functions into the diskio and then it worked.

Do you have or would you make, a video on how to implement it with dynamic memory allocation?

mathiasclausen
Автор

I had made some changes, there are some variables types that are not right. I run this project at 18MBits/s with no errors. I used keil uVision.
// "sprintf" needs an "unsigned long" input. Note that despite the fact that int and long are represented by the same number of bits, they are still different types.

stefanputureanu
Автор

Good morning i have a little project that i have to do but do you think that we can transfer files between two stm32 with spi ( files like .txt) thank youu

taamallahmedtahe
welcome to shbcf.ru