2014-07-01 05:58 AM
hi,all
I'm using two stm32f103 for dma spi both master and slave. I enable one gpio for external interrupt on the master side for slave inform of PTX. But somehow theEXTI15_10_IRQHandler keep triggered after initialized, as I can see on debug. The configuration is as followed,please anyone help me out with it. Many thanks.#include ''stm32f10x.h''
#include ''stm32f10x_gpio.h''
#include ''stm32f10x_exti.h''
#include ''stm32f10x_spi.h''
#define WIFI_SPI_MASTER
#define WIFI_SPI SPI2
#define TIP_WIFI_SPI_GRP GPIOB
#define TIP_WIFI_NSS_PIN GPIO_Pin_10
#define TIP_WIFI_IRQ_PORT_SRC GPIO_PortSourceGPIOB
#define TIP_WIFI_IRQ_EXTI_LINE EXTI_Line10
void RccInit(void)
{
ErrorStatus HSEStartUpStatus;
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08)
{
}
}
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
}
void GpioInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOA, GPIOB, GPIOC and AFIO clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC , ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO , ENABLE);
//NSS SPI_NSS_Soft
GPIO_InitStructure.GPIO_Pin = TIP_WIFI_NSS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(TIP_WIFI_SPI_GRP, &GPIO_InitStructure);
}
void NvicInit(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
/* EXTI NVIC configuration*/
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_EXTILineConfig(TIP_WIFI_IRQ_PORT_SRC, TIP_WIFI_IRQ_PORT_SRC);
EXTI_InitStructure.EXTI_Line = TIP_WIFI_IRQ_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //EXTI
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //failling edge triger
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //enable exti
EXTI_Init(&EXTI_InitStructure);
}
int main(void)
{
uint8_t count = 0;
RccInit();
GpioInit();
// DmaInit();
NvicInit();
for(;;);
}
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(TIP_WIFI_IRQ_EXTI_LINE) != RESET)
{
if(GPIO_ReadInputDataBit(TIP_WIFI_SPI_GRP,TIP_WIFI_NSS_PIN)==Bit_SET) /*it is a raising edge, begin of transition*/
{
// SPI_I2S_ITConfig(WIFI_SPI, SPI_I2S_IT_RXNE, ENABLE); /* enable the rx interupt*/
// spi_rx_flag = 1;
}
else /*it is a falling edge, end of transition*/
{
// SPI_I2S_ITConfig(WIFI_SPI, SPI_I2S_IT_RXNE, DISABLE); /* disable the rx interupt*/
// spi_rx_flag = 0;
}
EXTI_ClearITPendingBit(TIP_WIFI_IRQ_EXTI_LINE);
}
}
#exti15_10_irqhandler-stm32-isr
2014-07-01 07:00 AM
Sorry,my friends. There was a mistyping at the GPIO_EXTILineConfig.
GPIO_EXTILineConfig(TIP_WIFI_IRQ_PORT_SRC, TIP_WIFI_IRQ_PIN_SRC);Appreciate your time. Many thanks.