cancel
Showing results for 
Search instead for 
Did you mean: 

SPI3 in stm32f10x problem

parisa
Senior
Posted on March 02, 2017 at 08:53

Hi,

Sorry I take the forum user's time for my simple questions.

Here is my code for spi3 in stm32f10x for PB3 and PB4 output/input.

    SPI_InitTypeDef SPI_INS;

      GPIO_InitTypeDef GPIOS

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3,ENABLE);

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);

    GPIO_PinRemapConfig(GPIO_Remap_SPI3,DISABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4| GPIO_Pin_5|GPIO_Pin_3;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

 SPI_INS.SPI_Direction =SPI_Direction_2Lines_FullDuplex;

 SPI_INS.SPI_Mode = SPI_Mode_Master;

 SPI_INS.SPI_DataSize = SPI_DataSize_8b;

 SPI_INS.SPI_CPOL = SPI_CPOL_High;

 SPI_INS.SPI_CPHA = SPI_CPHA_1Edge;

 SPI_INS.SPI_NSS = SPI_NSS_Soft;

 SPI_INS.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;

 SPI_INS.SPI_FirstBit = SPI_FirstBit_MSB;

 SPI_INS.SPI_CRCPolynomial = 7;

  SPI_Init(SPI3, &SPI_InitStructure);

  SPI_Cmd(SPI3, ENABLE);

 SPI_SSOutputCmd(SPI3,DISABLE);

  SPI_I2S_ITConfig(SPI3,SPI_I2S_IT_RXNE,ENABLE);

However I can't see any clock signal in PB3 pin when I start sending ff value with SPI_I2S_SendData(SPI3, 0xff); function.

in STM32cubemx something is more strange:

According to datasheet we understand that for SPI3 without any remap PORT B can play SPI role.

0690X00000606SeQAI.png

However in STM32cubemx when I enable SPI3 and see it's configuration it just enables port c SPI section and it doesn't config anything such as remap.In addition when I change SPI3 for Port B it only change clock source.

STM32CubeMX output:

(REMAP)(PORTC) GPIO configuration

static void MX_GPIO_Init(void)

{

  /* GPIO Ports Clock Enable */

  __HAL_RCC_GPIOC_CLK_ENABLE();

}

and (without REMAP)(PORTB) GPIO configuration

static void MX_GPIO_Init(void)

{

  /* GPIO Ports Clock Enable */

  __HAL_RCC_GPIOB_CLK_ENABLE();

}

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on March 07, 2017 at 21:30

Perhaps the Remap code is elsewhere, like where it actually configures the pins, or the SPI peripheral.

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

View solution in original post

1 REPLY 1
Posted on March 07, 2017 at 21:30

Perhaps the Remap code is elsewhere, like where it actually configures the pins, or the SPI peripheral.

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