2022-11-30 07:42 AM
hello,
i work in STM32F405, create projet with cubeMx, SD 4 wires.
Pull up in the schematic D0..3 , CMD, no internal pull in cube MX
mount return FR_NOT_READY
when SD_WideBus_Enable() (in hal_sd) call:
in SD_FindSCR() after the cmd 51 , there is a polling wait
but i have SDIO_STA_STBITERR
and no data is return by the SD:
i will try to reduce clock:
clock init: 0x76: 400khz to 0xBA(400khz if the PLL output 48Mhz is 72Mhz) see in errata sheet STMF405
clock after SD_CLK: divider = 0x76 the same of init.
any idea?
thx
2022-12-01 01:16 AM
update:
MxCube.Version=6.6.1
if i migrate to the new CubeMx 6.7.0, regenerated software and doesn't works.
i passed 3 days to search and i will continue to find problem.
with the new cube mx:
void MX_SDIO_SD_Init(void)
{
/* USER CODE BEGIN SDIO_Init 0 */
/* USER CODE END SDIO_Init 0 */
/* USER CODE BEGIN SDIO_Init 1 */
/* USER CODE END SDIO_Init 1 */
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_4B;
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = 20;
/* USER CODE BEGIN SDIO_Init 2 */
/* USER CODE END SDIO_Init 2 */
}
//old
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
//new
hsd.Init.BusWide = SDIO_BUS_WIDE_4B;
/* Configure SDIO peripheral interface */
(void)SDIO_Init(hsd->Instance, hsd->Init);
//so use CubeMx parameters for the first initialisation
//the first initialisation must be in 1 Wire. bug in last CubeMx.
2022-12-09 07:23 AM
Hi @trave.1 ,
This looks like the same issue as described by @Brieuc in this question.
I let out STM32CubeMX expert @Semer CHERNI deeply review both cases. Meanwhile, you can try to with the old configuration (hsd.Init.BusWide = SDIO_BUS_WIDE_1B;) to check if it works properly.
-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.
2023-12-06 08:53 PM - edited 2023-12-06 08:55 PM
The better way to solve this for me wasn't changing the generated code but solving a bug (IMO it's a bug or bad implementation).
From SD_InitCard() remove (void)SDIO_Init(hsd->Instance, hsd->Init);
Because that initialization is made with the final speed and wide parameters instead, and it's also redundant.
Commenting that line solves the issue.
And the generated code can be kept at SDIO_BUS_WIDE_4B as specified in the project.
In BSP_SD_Init
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
SDIO_BUS_WIDE_4B should be replaced by hsd.Init.BusWide (according to setting).
It is surprising this bug hasn't been fixed after quite a few CUBE releases.