Associate
October 31, 2017
Question
Problem putting sd card in spi mode
- October 31, 2017
- 3 replies
- 1512 views
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