Problem putting sd card in spi mode ''#2

Thread Starter

zogzog

Joined Jul 22, 2009
2
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;View attachment 138412 View attachment 138413



// 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
 

Thread Starter

zogzog

Joined Jul 22, 2009
2
I struggled like hell to connect sdcard to a fpga machine... only one brand of sdcard worked gigastone
all my sandisk sdcard failed not replying to CMD0
I discovered that the scard were very sensitive to the delay between mosi is set up and the clock is toggled
I modifed my vhdl code to add a delay between mosi and sck now all sdcards are responding v1, v2 from 16Mb to 128Gb

it's probably why some people are saying that they have a better success with bitbanged spi

Mod: link to old thread
https://forum.allaboutcircuits.com/threads/problem-putting-sd-card-in-spi-mode.141675/post-1195638
 
Last edited by a moderator:
Top