2017-10-31 05:57 AM
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 #spi2017-10-31 07:34 AM
Are you sure the SD Card accepts SPI mode? Have you tested it with a working example?
2017-10-31 09:43 AM
Seem to recall single bit mode was a prerequisite
2017-10-31 11:22 PM
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.