cancel
Showing results for 
Search instead for 
Did you mean: 

Problem putting sd card in spi mode

saeed abdolinezhad
Associate
Posted on October 31, 2017 at 13:57

I'm trying to connect an sd card to the stm32f091cct6 microcontroller using FatFs driver. After sending some clock while MOSI and CS are high, I send idle command (CMD0) but receive no response from sd card. I pulled up MISO pin with a 100K resistor and clk pin with a 10K resistor. sd card isn't dead because I tried to communicate with it with another processor (TI ARM cortex M3) and it was a success. I pulled up all signals interally. (I tried different configurations of internal and external pull-ups but nothing happend). This is spi initialization code:

/* SPI Config */

heval_Spi.Instance = EVAL_SPIx;

// PCLK1 = 48MHz

heval_Spi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;

heval_Spi.Init.Direction = SPI_DIRECTION_2LINES;

heval_Spi.Init.CLKPhase = SPI_PHASE_1EDGE;

heval_Spi.Init.CLKPolarity = SPI_POLARITY_HIGH;

heval_Spi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

heval_Spi.Init.CRCPolynomial = 7;

heval_Spi.Init.DataSize = SPI_DATASIZE_8BIT;

heval_Spi.Init.FirstBit = SPI_FIRSTBIT_MSB;

heval_Spi.Init.NSS = SPI_NSS_HARD_OUTPUT;

heval_Spi.Init.TIMode = SPI_TIMODE_ENABLE;

heval_Spi.Init.Mode = SPI_MODE_MASTER;

SPIx_MspInit(&heval_Spi);

HAL_SPI_Init(&heval_Spi);

I've attached spi signals 

yellow: MISO

cyan: CLK

purple: MOSI

blue: CS

#fatfs #stm32f091 #sd-card #spi
3 REPLIES 3
S.Ma
Principal
Posted on October 31, 2017 at 15:34

Are you sure the SD Card accepts SPI mode? Have you tested it with a working example?

Posted on October 31, 2017 at 16:43

Seem to recall single bit mode was a prerequisite 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 01, 2017 at 06:22

Yes. I tested it with TI F28M35 processor. I was able to write data to it and read it back. I guess the problem is related to the processor internal pull-ups. In F28m35 all pins are configured as pull-up but in stm32f091 internal pull-up for MISO isn't sufficient and I have to pull it up externally. By the way spi is in single bit mode.