Associate III
May 27, 2015
Question
SPI clock looks to be floating when not driven
- May 27, 2015
- 2 replies
- 874 views
Posted on May 27, 2015 at 09:56
Hi,
I'm using spi to read and write from an spi flash part, which is working the vast majority of the time. Occasionally I get an incorrect value. Looking at the signals on a logic analyzer the spi clock signal is not right as it seems to be floating. Diagram is attached and configuration is as follows. Anybody shed any light on what might be causing this. There is nothing else connected to this signal. Many Thanks Bob/* Enable SPI clock, SPI2 */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
/* SPI SCK, MOSI, MISO pin configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_15 | GPIO_Pin_14;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1; // 10 MHz
GPIO_Init(GPIOB, &GPIO_InitStructure);
// Configure CS pin as output floating
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_0); // SPI2 SCK
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_0); // SPI2 MOSI
GPIO_PinAFConfig(GPIOB, GPIO_PinSource14, GPIO_AF_0); // SPI2 MISO
/* SPI configuration -------------------------------------------------------*/
SPI_I2S_DeInit(SPIx);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_Init(SPIx, &SPI_InitStructure);
SPI_SSOutputCmd(SPIx, ENABLE);
SPI_Cmd(SPIx, ENABLE);