2014-09-18 06:46 PM
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_FLASHBut 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_GPIOEBy:#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_GPIOBMy 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,Nhan2014-09-18 07:45 PM
2014-09-18 09:10 PM
Watch the APB1 vs APB2 clocks