SPI2 with FatFS stuck waiting

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

SPI2 with FatFS stuck waiting

Post 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};
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI2 with FatFS stuck waiting

Post 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
jackjr
Posts: 4
Joined: Fri Jun 27, 2014 10:55 pm

Re: SPI2 with FatFS stuck waiting

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI2 with FatFS stuck waiting

Post by Giovanni »

Please consider lenght of connections, terminations, capacitors. I think it can be triggered by HW aspects.

Giovanni
colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: SPI2 with FatFS stuck waiting

Post by colin »

Could there be a DMA channel conflict with the SPI2 TX, RX DMA channels?
Post Reply