Это видео недоступно.
Сожалеем об этом.
SD card using SDIO in STM32 || Uart RIng buffer || 4-Bit Mode || CubeMx
HTML-код
- Опубликовано: 17 авг 2024
- Purchase the Products shown in this video from :: controllerstec...
________________________________________________________________________________________
If you get FR_DISK_ERR, increase the SDIOCLK divide factor to 4 in the SDIO setup, or change between 0-4.
The code has been updated to work with CUBEIDE also. Latest changes made on 14-May-2020
The latest Ring buffer code can be found at github.com/con...
To download the code as shown in this video, click
controllerstec...
To download the simple and more reliable code, without the weird uart stuff goto controllerstec...
Check out more VIDEOS on SD CARD with STM32 • STM32 SD CARD
________________________________________________________________________________________
****** SUPPORT US BY DONATING*****
paypal.me/cont...
******Join the Membership******
/ @controllerstech
Join the Discord Server / discord
Join the Telegram Group t.me/controlle...
Follow me on Instagram / controllerstech
For more info, visit www.controller...
Masterpiece! It will help me a lot. Many thanks to you for all of your tutorials. I will remember you when I acquire my future job.
i learn a lot of things from you.
you deserve more subs and likes..
Glad to hear that 👍
This was really helpful.
I have an STM32F407VET6 and have struggled a lot with it in many aspects
What aspects are u talking about? I have it but mostly I don't use it, cause i get requests mostly regarding 103. But I did used it in the past and it played out pretty well.
@@ControllersTech Thankyou very much for the reply.
I was having troubles with using the sd card which you've covered here and and getting a 10.1" TFT touchscreen to work via the header on the board
Yeah I am thinking of buying that TFT. Will do that in near future and cover it in some video..
@@ControllersTech Thankyou very much, it's probably straight forward but it's lost me altogether.
I work with the same MCU but I facing trouble with SDIO. Any proposition. Black pill borad.
I Programme it on Stm32 mxID 1.15.1 but the card couldn't mounted
Thank You. You are good at this job. Keep it up man! :D
Hello, great video! I'm curious if you've experimented with utilizing DMA for reading and writing data on an SD card.
your tutorials are great! Thank you. One suggestion I have is, please have a list of potential issues and resolution or work around in the articles as a section. That will help in a big way.
Yeah will try on that
@@ControllersTech Thanks. Could you help me with 2 things
1. when I leave my card inserted but idle, it stops responding after 3-4 minute of idle, if I keep sending some command every minute, it works fine. Clock continues to come, I have checked on Oscilloscope.
2. How can I implement safe card removal and insertion again?
I tried unmount, remove card, insert card and mount, but it doesn't work..
I am using STM32F407VE, 4bit mode.
Thanks in advance for any suggestions or guidance!
Hello @ControllersTech , i think last updated of ur code has some problem,
1. cube mx setting show 4bit wide bus, in sdio.c file it shows 1bit wide bus
2. no hal_sd_init() function call in MX_SDIO_INIT() function, there suppose to be a function call to initialize the settings.
3. if i dont implement hal_sd_int function nothing happens at all
4. if i use i crashes on fs_mount function from ff.c
please update source code. im also using same board stm32f4vet6 black board still it fails.
Nice. The video title declared 4bits mode, the same is shown in CubeMX, but in the attached sofrware arrchive is 1Bit mode: main.c, line #263 "hsd.Init.BusWide = SDIO_BUS_WIDE_1B;". Also, no init code in the MX_SDIO_SD_Init() function. This pointed me to change the initialization section of my code generated by cubeMX: hsd.Init.BusWide = SDIO_BUS_WIDE_1B; not SDIO_BUS_WIDE_4B, then call the HAL_SD_Init(&hsd) and HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B); It seems the 4bits mode now in action. Yet, the hsd.Init.ClockDiv = 3; Very interesting!
i have same question like, first .ioc setting and SDIO.c data dont matched, bus wide is 1B rather 4bBthat show in website and tuts and also no hal_sd_init function call inside mx_sdio_init function. is it generator problem, now a 1.12.1 cube ide version with f4 1.27.1 does the same job, no init function call. that code wont work for me. if u can do any please share with me. i have been trying for three days.
@@shamssalehin2376 Hi! My SD_init() function runs smoothly with this:
hsd.Instance = SDIO;
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 0;
if (HAL_SD_Init(&hsd) != HAL_OK)
{
Error_Handler();
}
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
{
Error_Handler();
}
hi. thanks a lot.
I used your video and files. When running with 1-bit mode, I didn't have any trouble and everything was okay. However, when using the 4-bit structure, my SD card cannot mount and I receive the error code fresult=FR_NOT_READY.
Hi,
I got an error as you mentioned, but your advice alone was not enough to solve my problem.
"If you get FR_DISK_ERR, increase the SDIOCLK divide factor to 4 in the SDIO setup, or change between 0-4."
We select 4-bit bus and My CubeIDE version generates SDIO_Init code and it inits bus as 4B. It seems correct, but is not!!!
I found in internet some other working codes and compare it with mine. I relalized we must do 2 things additionally:
1- Clock divider must be >= 4. I tested it with 3, it works not. I have 168MHz main clock.
2- SDIO_Init BusWide must be changed as 1B configuration.
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
(My Version: STM32Cube FW_F4 V.1.27.1 )
Thank you for your sharing.
I'm working with Stm32f407VET6 Black Board and it's not working for me
fresult = f_mount(&fs, "/", 1); in mount_sd () gives me FR_NOT_READY . i hope you can help me
a little mention: anyone use oder version than R0.12a (July 10, 2016) . The FA_OPEN_APPEND flag will be not available.
Please modify Update_File:
f_lseek(&fil,f_size(&fil));
fresult = f_write(&fil, data, strlen (data), &bw);
Hello everyone
I have some issues about SDIO and STM32 IDE : 1.15.1 I USE stm32f407vet6. Since I on the Board it doesn't work.
1. I follow the video normally
2 I change the clock factor
3 i plog different SD capacity
4 I have set pull-up resistors get error
5 I solder external resistor still go error.
It doesn't work. I receive on terminal error sd card no mounted.
I change the clock divider and the board send the same errors
Any help or proposition.
Hello, i am having some troubles, i can only read the SD card, but I can't write. I get an error
error no (1) in closing file *d.txt*
"A hard error occurred in the low level disk I/O layer */"
This video helps me a lot, thank for that. However, I have a problem with f_mount functions it always returns "FR_NOT_READY" error. How can I fix this error? Thanks...
Great video , i have tried the same for the STM32F446RE controller, but problem is mount_sd(); controller is not coming out from these part. can u please help me out
Works so far in 4bit Mode if I set SDIOCLK divide factor to at least 5! Using STM32F407VET "black-board" with an 16GB FAT32 linux fdisk partition type "W95"
HI! thanks for great videos. I used simple form code of "File_Handling" for saving my data on SD-card that received with USART port., but when i use this library I lost some of data.and I have no idea How File_Handling effected my received data. could you give me some advice to solve these problem?
Great video, but I have a question. In my case the scan_files function for some reason does not list all the files in the root of my sd card. There are 17 .txt files, but it does not list all of them, the number of listed files varies with each "ls" command. Sometimes it shows 8, sometimes 14.. but never the correct amount. Also is there an option to list the files sorted by name ?
Did u use SDHC or SDXC cards in this project ?
Is it neccesary to pull up the SCK line with that R33 - 10k resistor like you show at 1:57? Almost every appnote suggests directly connecting it to the MCU SDIO host interface. I'm having issues with mounting and I suspect this can be the problem. Can't even see a 400kHz initial clock. The clock line is pulled high at all times and the SDIO clock and peripheral enabled status bits stay zero. Even changing the init divider value has no effect (stays zero too). I will try removing or raising the resistance of this pull-up resistor on Monday.
Actually that's the schematic of my board. It have the module mounted on it.
You should try increasing the sdio clock divide factor. The sdio clock needs to be less than 25 MHz.
@@ControllersTech I've tried increasing it, but maybe by not enough or too much. I feed a 45-48MHz clock from the PLL to the "48MHz clocks" and 36-72 to the APB1-APB2 buses. On my F429ZI if I set up the max HCLK clock, the "48MHz clocks" is only 45, so I use 72. Is the clock divide factor dividing the "48MHz clocks" directly? I guess I'll have to dust off the reference manual for the SDIO clock setup or maybe the Definitive Guide book again by Joseph Yiu. :)
In f4, sdio clock is connected to APB2 and finally it works like sdio clock = apb2 clock/(divider+2)
@@ControllersTech Success! Of course the problem is more electrical in it's nature. The clock signals started to appear when I was starting to use 10cm jumper wires instead of 20cm and leaving most of the breadboard out of the signal path. (Noise was like 50-100mV PP in my case.) The SDIO interface doesn't really like noise so it doesn't really comes out of reset I think. The card's limit is still at 3MHz, but it's a good starting point, before making a PCB. Everybody having this on self-made prototyping boards for the first time should start raising it up from 1MHz (48MHz SDIO peripheral CLK/48 as divider). I have seen EMI filters specifically designed for SD interfaces on the market too. Thank you for your help!
Hey, I am trying the same setup on stm32l452re but unfortunately the board is not working... any suggestions
Some time ago there was a problem with the operation of the SD card in "4 bits wide bus" mode, but it works fine in 1 bit mode. I am working on fixing this issue.
@@badzonor5797 plz have a look at this link and suggest me what I m doing wrong community.st.com/s/question/0D53W00000RQ1W9SAL/i-am-working-on-stm32l452-nucleo-boardim-able-to-read-but-write-operations-are-not-working
how to do it directly without UART?
Hi Controllers Tech, I have a problem about the "huart1"
the message said that :Symbol huart1 multiply defined (by UartRingbuffer.o and main .o)
so I take a review these two code, main.c >>line 49 and the UartRingbuffer.c>>line 13 have the same define
"UART_HandleTypeDef huart1" ,could you give me some advice to solve these problem?
Thank you~
When u r defining uart_handletypedef in uartringbuffer.c, use the keyword extern in front of it.
@@ControllersTech WOW, that work it, a lot of thanks~
wow...thank you.!!
Bro which is the suitable stlink debugger for stm32f407vet6 Dev board
J link is best, but if your budget is limited, buy st link
Hi, i love your tutorial about stm32 stuff. I have stm32l4 series board, i want to access my MMC module with it, i follow your tutorial, and in uartringbuffer.h i already changed it with l4 series. but i got an error message went i want to create the file, "error no 1 in creating file *file.txt*" and then i searching what the meaning of that number, in ff.h file said "A hard error occurred in the low level disk I/O layer" do you know what that message means?
btw i didn't use uartringbuffer, i just call "create_file("file.txt");" function
in the SDIO setup, increase the SDIOCLK divide factor and test
@@ControllersTech thank you very much for your help
Is there a possibility to use SPI SD card adapter for this example? Thank you in advance
There is already a video for sd card and spi.
If you are talking about this particular example, than yes you can use. Just use this file handling library with that video
@@ControllersTech I got a SD card adapter for breadboard so Im trying to get this working as you did in the video. Im using Nucleo-F466RE board, but I have a question. When selecting HSE should I use "Bypass"? I mean, my nucleo board doesnt have crystal soldered, and Ive read that I should use StLink crystal choosing bypass option when selecting clock source. Is it right?
Yeah you can choose bypass or the crystal itself like i did.
@@ControllersTech I cant get this working. I get "Error in mounting SD card" everytime. Im a little confused about wiring bc Im using SD adapter for uSD card, so I dont know if there is something missing
Great jobs 👍
Hi i have problem with code example it always show
"SD CARD mounted successfully..."
event no SD Card
when i send cmd ls but nothing return
Is the rest of the code working ?
@@ControllersTech hi now i can use some command of this
but it stuck when I use "ls " command .
output like this "
SD CARD mounted successfully...
*dir1* has been created successfully
*dir1/test.tx* created successfully
Dir: SPOTLI~1
Dir: STORE-V2
Dir:
I don't understand. What's the output of ls command
@@ControllersTech
I format SD card already but it still showed like this. but it's not a problem because I can use other commands as well
one more this can we detect SD plug and unplug? and reinit SD card without Hardware reset?
thank for your reply
There might be some directories, created automatically after formatting. It's reading those ones.
I know about the mounting and unmounting issue. I tried using other way but the card wasn't mounting than. So i let it be..
You can check some other tutorials and try follow the mounting command. It should be same for all the codes using fatfs
Hello! i like your videos so much (especially music :)), but i cant make 4 bit SDIO work on my STM32F746ZG nucleo board....
But i have it working in 1 bit mode, don't know what am i doing wrong...
DMA template is disabled, SDIO clock source is PLL48CLK and SDIO divider is 2, pull ups all SDIO pins except CLK.
f_mount returns FS_OK, f_open - FS_OK, but f_close stucks for long time and than no file is created.
I am using STM32CubeIDE 1.0.2
Help me please...
Can u try to read error in the debugger. If the error is disk_error or something ?
If u do, goto sdio settings in cubemx and at the end, you will find SDIOCLK clock dividing factor.
Increase it and than test.
@@ControllersTech Increasing clock dividing factor helped resolve my Disk_error! Thank you
I am using STM32F446RE what changes should I do in this code ?
Not much. You should watch the video and follow the steps properly
Did you make it works with STM32F446RE?
How to do with bluetooth without hercules?
Connect to bluetooth and send those commands using some serial app 🤷
hi, I'm using CubeMX to make sd card application just like you, but when I mount sd card. It appears FR_DISK_ERR, although I have check the wires, It's fine. I found that many others have faced this issue which relate to CubeMX version. Do you encounter this problem and if yes, could you share how to fix ?
I hear it work fine on CubeMX 4.21, but the later versions have started appearing issues
in the SDIO setup, increase the SDIOCLK divide factor and test
@@ControllersTech thank you for your reply, I set the divide factor to 6 but it the result is same.
@@ControllersTech I'm using stm32f4discovery board
I'll recheck the code and confirm if there is some issue
@@ControllersTech thank you very much. I'm very appreciate your help
How can I write file to sd card with STM32L073 series board
what card module do you have ?
@@ControllersTech Nucleo L073RZ
I am asking module... Do u have any sd card module ?
@@ControllersTech Micro Sd card adapter
Sdio or spi ?
does not work at all
Hmm i guess fake video and fake comments 🤔
@@ControllersTech what do u mean
It's sarcasm... The video shows it's working.. there are people commented it's working...
Anyway, You need to be more specific on what's not working. Debug your code, find the errors.. This is not some readymade product you are getting that it will either work or not.
What MCU are u using ? what card ? what's the size? what's the SDIO prescalar ?
Try to use this code for the STM32H7 but struggle with the UartRingbuffer as it is written for the F4...
Don't use the ring buffer than. That is used to control the card from uart. You can simply use the rest of the code.