cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f429 SPI3 no clock on CLK pin

FaintSmile
Associate II
Posted on February 04, 2016 at 14:02

I have just made  my own SPI3 initilization code as its shown below.

void Spi_Init(void)

{

  SPI_InitTypeDef  SPI_InitStructure;

  GPIO_InitTypeDef GPIO_InitStructure;

SPI_StructInit(&SPI_InitStructure);

/*!< Enable the SPI clock */

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);

/*!< Enable GPIO clocks */

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

  /*!< Connect SPI pins to AF5 */ 

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SPI3);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3);

/*!< SPI pins configuration *************************************************/

  GPIO_InitStructure.GPIO_Pin =  GPIO_PinSource10|GPIO_PinSource11|GPIO_PinSource12;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

  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_32;

  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

 /*!< Disable SPI  */

  SPI_Cmd(SPI3, DISABLE);

SPI_Init(SPI3, &SPI_InitStructure);

  /*!< Enable SPI  */

  SPI_Cmd(SPI3, ENABLE);

}

at main c i have this code running

while(1)

{

SPI3->DR = 0x15;

}

But I can not see clk signal on my ossiloscope is my init code is wrong or smtn else
1 REPLY 1
Posted on February 04, 2016 at 20:38

PinSource is an index

GPIO_InitStructure.GPIO_Pin =  GPIO_PinSource10|GPIO_PinSource11|GPIO_PinSource12;

Pin is a bit mask

GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12; // Use this form

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..