cancel
Showing results for 
Search instead for 
Did you mean: 

Use SPI NSS as a generic GPIO

pieretti
Associate II
Posted on April 09, 2014 at 11:11

Hello,

I'm trying to configure SPI1 with NSS software management in my STM32F100, because I want to manage NSS pin as a generic IO pin. Is this possible?

For example, I've configured my NSS pin as a generic open-drain

 and I connected it to 3v3 by a pull-up resistor, but the signal at the pin is always low.

This's my configuration:

  // Enable GPIO clock

  RCC_APB2PeriphClockCmd( SPI_SCK_GPIO_CLK |

                          SPI_MISO_GPIO_CLK |

                          SPI_MOSI_GPIO_CLK |

                          SPI_NSS_GPIO_CLK |

                          RCC_APB2Periph_AFIO,

                         ENABLE);

  // Enable SPI clock  

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI,  ENABLE);

  GPIO_InitStructure.GPIO_Pin = SPI_SCK_PIN | SPI_MOSI_PIN;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(SPI_SCK_GPIO_PORT, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = SPI_MISO_PIN;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(SPI_MISO_GPIO_PORT, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = SPI_NSS_PIN;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(NSS_GPIO_PORT, &GPIO_InitStructure);

Thanks in advance

#stm32 #spi
0 REPLIES 0