mmcConnect fails

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jackjr
Posts: 4
Joined: Fri Jun 27, 2014 10:55 pm

mmcConnect fails

Post by jackjr »

Hello,

I've a problem accessing a SD card using the MMC SPI driver.

I'm using a STM Nucleo board, with the STM32F030R8.
I mostly copied the code from the STM32F103-FATFS demo. The SD card is connected on the SPI2 bus.

In the mmcConnect function, the initialization part using the slow speed seems to succeed.
However, after switching to high speed, the SET_BLOCKLEN command fails.

Here's a sample of a GDB session:

Code: Select all

516     spiStart(mmcp->config->spip, mmcp->config->hscfg);
519     if (send_command_R1(mmcp, MMCSD_CMD_SET_BLOCKLEN,
send_command_R1 (mmcp=0x20000d80 <MMCD1>, cmd=16 '\020', arg=512) at ../ChibiOS_2.6.4/os/hal/src/mmc_spi.c:265
265     spiSelect(mmcp->config->spip);
266     send_hdr(mmcp, cmd, arg);
267     r1 = recvr1(mmcp);
(gdb) p r1
$5 = 32 ' '
(gdb) n
268     spiUnselect(mmcp->config->spip);
269     return r1;
(gdb) p r1
$6 = 255 '\377'

I'm not sure how to interpret these values...
Why r1 = 32 and then 255?

Any help would be greatly appreciated :)
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: mmcConnect fails

Post by Giovanni »

Not sure, are pins configured for SPI? are connection short enough? bypass caps? resistor terminations? there can be a lot of things that could cause that.

Giovanni
jackjr
Posts: 4
Joined: Fri Jun 27, 2014 10:55 pm

Re: mmcConnect fails

Post by jackjr »

You were right. The wires were too long.

Reducing the speed did solve the problem.

Thanks for your help!
Post Reply