cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card using 1 bit SDIO on Nucleo 401Re

david cambridge
Associate II
Posted on December 02, 2017 at 18:59

HI 

I've been trying to get an SD card working in 1bit mode using the SDIO peripheral. I am failing, and would appreciate some help. I'm on a Nucel401RE using STM32Cube_FW_F4V1.180.0

The pin configuration is below. I have not enabled anything else

0690X00000604BYQAY.jpg0690X00000604I8QAI.jpg

My clock configuration is below. I've not configured anything else - including any interrupts. (sorry for the small font HCLK is 84 Mhz)

0690X00000604HpQAI.jpg

SDIO_CMD, SDIO_CK, and SDIO_D0 are connected as you might imagine. The breakout board includes some pull ups.

0690X00000604IhQAI.jpg

When i generate the project I've noticed that HAL_SD_Init is missing from sd_diskio.o, so my code in main.c looks like this

MX_GPIO_Init();

MX_SDIO_SD_Init();

/* USER CODE BEGIN 2 */

if (HAL_SD_Init(&hsd) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

MX_FATFS_Init();

fResult = f_mount(&SDFatFs, (TCHAR const*)SDPath, 1);

When I run the code, fResult eventually times out and reports error code 1 - FR_DISK_ERR

It get's stuck in SD_read in file sd_diskio.c, and I never see ReadStatus go true.

I can see on my scope that something is happening. The D0 and clock, triggered on a D0 rising edge, are below. The D0 signal is coming from the SD card.

0690X00000602VZQAY.bmp

I've tried various SDIOCLK clock divide (0,50,100,255) all to no avail.

After spending a few days on this I'm completely stuck , so I'd be really grateful for some help!

Thanks

David

#401re #sd #nucleo #sdio
1 ACCEPTED SOLUTION

Accepted Solutions
david cambridge
Associate II
Posted on December 04, 2017 at 11:27

Hi 

Problem now solved, I needed to set Stm32Cube\Configuration\FATS Configuration\IPs instances\Use DMA template to 'disabled' - and then it worked!

David

View solution in original post

5 REPLIES 5
david cambridge
Associate II
Posted on December 04, 2017 at 11:27

Hi 

Problem now solved, I needed to set Stm32Cube\Configuration\FATS Configuration\IPs instances\Use DMA template to 'disabled' - and then it worked!

David

John Craven
Senior
Posted on December 04, 2017 at 21:18

Can you explain where/how you disabled this '

Use DMA template'?

Posted on December 04, 2017 at 22:39

You'll find it in STMCube, go to the configuration tab, and choose the configuration for the FATFS, and then it's in the second tab along (IP Instances)

0690X00000604JkQAI.jpg
Posted on December 04, 2017 at 22:50

Ok, that's what i thought you meant, but i don't have that on my cube!

Upgrade time.

Curious, when it was setup disabled, did you have DMA setup in the SDIO configuration?

Posted on December 04, 2017 at 23:25

I was trying to keep the project as simple as possible, so everything was at it's default values (i.e. I didn't do anything to enable DMA that didn't happen automatically)