薇儿安蓝的笔记 https://bbs.21ic.com/?909395 [收藏] [复制] [RSS]

日志

【转】STM32中断和事件的配置应用main()

已有 928 次阅读2013-9-12 15:09 |个人分类:STM32|系统分类:嵌入式系统| generate, falling, 通道

void main(void)
{
  /* System Clocks Configuration */
  RCC_Configuration();
      
  /* NVIC configuration */
  NVIC_Configuration();
   
  /* Configure the GPIO ports */
  GPIO_Configuration();
  
  /* Connect Key Button EXTI Line to Key Button GPIO Pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource2);

  /* Configure Key Button EXTI Line to generate an interrupt on falling edge */  
  EXTI_InitStructure.EXTI_Line = EXTI_Line2;//使用2号中断通道
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断模式
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//下降沿触发
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);


  /* Generate software interrupt: simulate a falling edge applied on Key Button EXTI line */
  EXTI_GenerateSWInterrupt(EXTI_Line2);//软件模拟一次中断
        
  while (1)
  {
  }
}

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)