Page 1 of 1

SPI2 with FatFS stuck waiting

Posted: Thu Sep 04, 2014 4:35 pm
by jackjr
Hi,

I designed a board with a STM32F051 mcu.
The SPI2 of the mcu is connected to a MicroSD socket.

When trying to connect to the SD card with mmcConnect(), it remains stuck in an infinite loop waiting the idle state.
(wait() in send_hdr()).

However, when trying the same code with the SPI1 (configuring the pins accordingly), everything works fine…

Any idea please?

Here's the SPI config I'm using:

Code: Select all

static SPIConfig hs_spicfg = {NULL, GPIOB, 12, 
                              SPI_CR1_BR_1,
                              SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 };

static SPIConfig ls_spicfg = {NULL, GPIOB, 12,
                              SPI_CR1_BR_2 | SPI_CR1_BR_1,
                              SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 };

/* MMC/SD over SPI driver configuration.*/
static MMCConfig mmccfg = {&SPID2, &ls_spicfg, &hs_spicfg};

Re: SPI2 with FatFS stuck waiting

Posted: Thu Sep 04, 2014 7:36 pm
by Giovanni
Hi,

Your problem apparently is the same described in this ticket: https://sourceforge.net/p/chibios/bugs/530/ isn't it?

The solution will be a timeout making mmConnect() fail but not stuck, expected in release 2.6.6.

Giovanni

Re: SPI2 with FatFS stuck waiting

Posted: Thu Sep 04, 2014 8:02 pm
by jackjr
Yes, this is it.
But for an obscure reason it was happening even when the sd card was present.

Now I just tried again with SPI2 and it worked…
I assume it was a bad solder joint or something… although I haven't changed anything since then.

Thanks for your support.

Re: SPI2 with FatFS stuck waiting

Posted: Thu Sep 04, 2014 8:17 pm
by Giovanni
Please consider lenght of connections, terminations, capacitors. I think it can be triggered by HW aspects.

Giovanni

Re: SPI2 with FatFS stuck waiting

Posted: Fri Sep 05, 2014 9:13 pm
by colin
Could there be a DMA channel conflict with the SPI2 TX, RX DMA channels?