AnsweredAssumed Answered

How to configure communication with SPI Clock

Question asked by thebank.moneyin on Nov 26, 2012
Latest reply on Nov 27, 2012 by thebank.moneyin
Hi fella. I want established a communication between a board stm32f4 discovery and a sensor LIS3LV02DQ by SPI interface. But I don't understand how to configure the clock to sincronize the board and the sensor. I try to configurate SPI interface throught the following code:
"     GPIO_InitTypeDef GPIO_InitStructure;

     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); // GRUPPO C

     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
     
     GPIO_Init(GPIOC, &GPIO_InitStructure);
     
     GPIO_PinAFConfig(GPIOC, GPIO_PinSource15, GPIO_AF_SPI2);
     /*PULISCO SPI2*/
     SPI_I2S_DeInit(SPI2);
     
     SPI_InitStructure.SPI_Direction = SPI_Direction_1Lines_Rx;
     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_2; 
     SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; 
     SPI_InitStructure.SPI_CRCPolynomial = 7;     

     SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
     SPI_Init(SPI2, &SPI_InitStructure);"

Can you help me to understand how setup correctly the SPI interface? Thanks to all

Outcomes