cancel
Showing results for 
Search instead for 
Did you mean: 

SPI2 problem on STM32F013.

nhandt3
Associate II
Posted on September 19, 2014 at 03:46

Hi,

I working with STM32F103 chip and trying to test SPI2. I use the example from: STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\SPI\SPI_FLASH

But replace

#define sFLASH_SPI                                            SPI1

#define sFLASH_SPI_CLK                                  RCC_APB2Periph_SPI1

#define sFLASH_SPI_SCK_PIN                          GPIO_Pin_5                  /* PA.05 */

#define sFLASH_SPI_SCK_GPIO_PORT           GPIOA                       /* GPIOA */

#define sFLASH_SPI_SCK_GPIO_CLK             RCC_APB2Periph_GPIOA

#define sFLASH_SPI_MISO_PIN                        GPIO_Pin_6                  /* PA.06 */

#define sFLASH_SPI_MISO_GPIO_PORT         GPIOA                       /* GPIOA */

#define sFLASH_SPI_MISO_GPIO_CLK           RCC_APB2Periph_GPIOA

#define sFLASH_SPI_MOSI_PIN                        GPIO_Pin_7                 /* PA.07 */

#define sFLASH_SPI_MOSI_GPIO_PORT         GPIOA                       /* GPIOA */

#define sFLASH_SPI_MOSI_GPIO_CLK           RCC_APB2Periph_GPIOA

#define sFLASH_CS_PIN                                     GPIO_Pin_6                  /* PE.06 */

#define sFLASH_CS_GPIO_PORT                      GPIOE                       /* GPIOE */

#define sFLASH_CS_GPIO_CLK                        RCC_APB2Periph_GPIOE

By:

#define sFLASH_SPI                                                SPI2

#define sFLASH_SPI_CLK                                      RCC_APB1Periph_SPI2

#define sFLASH_SPI_SCK_PIN                              GPIO_Pin_13                  /* PA.05 */

#define sFLASH_SPI_SCK_GPIO_PORT               GPIOB                       /* GPIOA */

#define sFLASH_SPI_SCK_GPIO_CLK                 RCC_APB2Periph_GPIOB

#define sFLASH_SPI_MISO_PIN                           GPIO_Pin_14                  /* PA.06 */

#define sFLASH_SPI_MISO_GPIO_PORT            GPIOB                       /* GPIOA */

#define sFLASH_SPI_MISO_GPIO_CLK              RCC_APB2Periph_GPIOB

#define sFLASH_SPI_MOSI_PIN                          GPIO_Pin_15                 /* PA.07 */

#define sFLASH_SPI_MOSI_GPIO_PORT           GPIOB                       /* GPIOA */

#define sFLASH_SPI_MOSI_GPIO_CLK             RCC_APB2Periph_GPIOB

#define sFLASH_CS_PIN                                      GPIO_Pin_12                  /* PE.06 */

#define sFLASH_CS_GPIO_PORT                       GPIOB                       /* GPIOE */

#define sFLASH_CS_GPIO_CLK                         RCC_APB2Periph_GPIOB

My purpose  is replace SPI1 by SPI2, but the program can not pass:

while (SPI_I2S_GetFlagStatus(sFLASH_SPI, SPI_I2S_FLAG_TXE) == RESET);

when send data.

Please, tell me the reason, thanks in advance.

Regards,

Nhan

2 REPLIES 2
nhandt3
Associate II
Posted on September 19, 2014 at 04:45

I read all examples in STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\SPI\ and recognize that SPI2 is only play the SLAVE role. So, can SPI2 pin connect to extenal Flash (play the master role). I found nothing in STM32 reference manual. Thanks you.

Posted on September 19, 2014 at 06:10

Watch the APB1 vs APB2 clocks

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