Home > other >  STM32 into external interrupt
STM32 into external interrupt

Time:10-08

Void device_init ()
{
GPIO_InitTypeDef GPIO_InitStructure;


RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_15;
GPIO_InitStructure. GPIO_Mode=GPIO_Mode_IPU;
GPIO_InitStructure. GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init (GPIOB, & amp; GPIO_InitStructure);
//GPIO_SetBits (GPIOB, GPIO_Pin_15);

}

Void EXTIX_Init (void)
{

EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

Device_init ();//initialize the IO

RCC_APB2PeriphClockCmd (RCC_APB2Periph_AFIO, ENABLE);//make can reuse function clock



//GPIOB. 15 bolt and a decline in interrupt initialization configuration along the trigger
GPIO_EXTILineConfig (GPIO_PortSourceGPIOB, GPIO_PinSource15);
EXTI_InitStructure. EXTI_Line=EXTI_Line15;
EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStructure. EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Init (& amp; EXTI_InitStructure);//set according to the specified parameters in the EXTI_InitStruct initial non-greeks EXTI register




NVIC_InitStructure. NVIC_IRQChannel=EXTI15_10_IRQn;//the interrupt
NVIC_InitStructure. NVIC_IRQChannelPreemptionPriority=0 x02;//take priority 2,
NVIC_InitStructure. NVIC_IRQChannelSubPriority=0 x03;//child priority 3
NVIC_InitStructure. NVIC_IRQChannelCmd=ENABLE;//can make external interrupt channel
NVIC_Init (& amp; NVIC_InitStructure);




}

Void EXTI15_10_IRQHandler ()
{
If (EXTI_GetITStatus (EXTI_Line15)!=RESET)
{
Delay_ms (10);//shaking,
If (DEVIN==0)//
{
Printf (" SUS ");
}
EXTI_ClearITPendingBit (EXTI_Line15);//clear the interrupt flag bit on the LINE15
}
}
One afternoon didn't find the reason, external interrupt into not to go, is that you need to set up there, STM32F103C8 28 pins,

CodePudding user response:

Find out why the less 1 EXTI_InitStructure. EXTI_LineCmd=ENABLE;

CodePudding user response:

comparing STM32Cube configuration generated easy

CodePudding user response:

Syntax checking should be found out, uninitialized structure members
  • Related