2017-03-15 12:16 PM
My application is running on the STM32F746 Discovery kit (STM32F746BG chip). mIf I initialize the system clock to its maximum of 216MHz early in the application, the SDIO (ST calls it SDMMC in the F7 series - why they do I just don't know!)) peripheral stalls and doesn't initialize in the PowerOn() routine.
However, if I run the system clock at a lower speed, e.g. 96MHz and then increase it to the maxmium 216MHz after the SDIO interface has initialized, it works and the rest of the application proceeds as normal.
The SD card bus speed is not effected by this change in SysClock speed since the SD card bus clock is derived from a dedicated 48MHz PLL. I've also made sure the initial SD card bus speed is at the recommended 400KHz.
I have read the datasheet, the reference manual and the errata sheet for that chip and couldn't see any reason why this is so.
Can anyone shed any light on this?
#sdmmc #stm32f7 #sdioSolved! Go to Solution.
2017-04-16 12:11 PM
I eventually found my real problem. in my (non-HAL) clock initialization code, somehow with time, I had omitted the call to PWREx_EnableOverDrive() which of course means that the chip was not configured correctly to startup at 216MHz. Including that call fixed the problem.
2017-03-15 12:26 PM
What if you drop the APB/AHB clocks?
2017-03-15 01:36 PM
Actually, to be correct, I simply changed the main PLL values so all the clocks dropped by the same amount. That problem had stumped me for several days and I was just glad to find a working solution, without fully understanding why that solution worked. I have wasted so much time with this issue that I really must get on now and make some productive progress at last. It could well be the SysClock is OK at 216MHz and maybe just the
APB/AHB clocks should have been dropped instead.
My solution works, so for now I am inclined to just stay with it.
And further reading of the reference manual (page 1188) about the SDMMC interface reveals :'
The SD memory card protocol is a superset of the MultiMediaCard protocol as defined in the MultiMediaCard system specification V2.11.
Several commands required for SD memory devices are not supported by either SD I/O-only cards or the I/O portion of combo cards.
Some of these commands have no use in SD I/O devices, such as erase commands, and thus are not supported in the SDIO protocol.
In addition, several commands are different between SD memory cards and SD I/O cards and thus are not supported in the SDIO
protocol. ' So the name SDMMC is probably a truer description of the functionality of that peripheral than the old F4 series name of SDIO is.2017-03-16 12:37 PM
I looked into this a bit further and instead of changing the main PLL settings I left SysClock at 216MHz and changed the AHB prescaler to 2 from the default of 1. That lowered the AHB and PB busses temporarily and this also allowed the SDMMC peripheral to initialize properly. I then changed the AHB prescaler back to 1 to raise the bus frequencies after the SDMMC had initialized.
But the issue I have, I think, with STM, is that this dependency of SDMMC initialization on AHB/PB bus frequency is not documented anywhere that I could see.
2017-03-21 08:02 AM
Hmmm....My 746G-Discovery(with Rev.Z chip) is no problem even 216MHz SysClock.
And I derive SDMMC(48MHz) clock from PLLSAI.
2017-03-21 10:22 AM
Hi David,
If you keep clock settings as expected before SDMMC initialization and insert a delay of 2ms before the call of
SD_PowerON, do you still have an issue?
/******* Update in HAL_SD_InitCard *******/
/* Set Power State to ON */
SDMMC_PowerState_ON(hsd->Instance);
/* Enable SDMMC Clock */
__HAL_SD_ENABLE(hsd);
/* Power up waiting time */
HAL_Delay(2);
/* Identify card operating voltage */
errorstate = SD_PowerON(hsd);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
If it is still not resolved with such workaround, could you please share the model of card you are using?
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-03-21 12:58 PM
Thanks for that. Yes, by adding a 2ms delay before the Power On function, the SD card initializes fine now. I added ita s the first line inside the PowerOn() function so I shouldn't forget it again.Thanks for the help..
BTW, I am using a class 4 Kingston 4GB micro-SD Card. I also tried it on a class 10
Kingston 16GB micro-SD Card. It had the same initialization problem.
2017-04-16 12:11 PM
I eventually found my real problem. in my (non-HAL) clock initialization code, somehow with time, I had omitted the call to PWREx_EnableOverDrive() which of course means that the chip was not configured correctly to startup at 216MHz. Including that call fixed the problem.