2013-09-03 12:50 PM
Hi everyone,
I have a problem with a stm32f207 device. I use the NSS pin of the SPI2 as a GPO. (The chip select to my SPI2 devices comes from an external I2C IO expander). NSS pin (I4) seems to be working ok as a GPO until I enable SPI2 interface. If I have the I4 (NSS) high when I enable the SPI2 I can see that it goes to approx. 2v. This means as far as I understand that the NSS pin goes low, which it should when I enable the SPI, but I have not assigned it to its alternative function. Can anyone spot what I have missed? I think this is the relevant init code� //Configure PI.4 as motor control */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_Init(GPIOI, &GPIO_InitStructure); // Connect PI.1 to SD_SPI pins: SCK GPIO_PinAFConfig(GPIOI, GPIO_PinSource1, GPIO_AF_SPI2); //Configure PI.2 as SD_SPI pins: MISO GPIO_PinAFConfig(GPIOI, GPIO_PinSource2, GPIO_AF_SPI2); //Configure PI.3 as SD_SPI pins: MOSI GPIO_PinAFConfig(GPIOI, GPIO_PinSource3, GPIO_AF_SPI2);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_UP; // Configure CLK, MISO, MOSI pins GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3; GPIO_Init(GPIOI, &GPIO_InitStructure); // SPI configuration 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_High; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI2, &SPI_InitStructure);/*!< Enable the SPI */
SPI_Cmd(SPI2, ENABLE); #stm32f107-nss-gpio-spi2