你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32F10x 的EXTI 問題【悬赏问答】

[复制链接]
allenfd 提问时间:2012-8-12 15:20 /
大家好
從datasheet來看,
每組GPIO pinx 都有一個EXTIx line
可是datasheet只定義了EXTI0~EXTI4
請問我有辦法使用GPIO pin5~pin15的中斷嗎?
如果可以的話請問程式要如何設定?
謝謝
收藏 评论8 发布时间:2012-8-12 15:20

举报

8个回答
yjwpm 回答时间:2012-8-12 20:24:19

RE:STM32F10x 的EXTI 問題

当然可以设置EXIT5~EXIT15
  /* Connect EXTI9 Line to PB.09 pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
  /* Configure EXTI9 line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line9;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI9_5 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
 
/**
  * @brief  This function handles External lines 9 to 5 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI9_5_IRQHandler(void)
{
#if defined (STM32F10X_HD_VL) || defined (STM32F10X_HD) || defined (STM32F10X_XL)
  if(EXTI_GetITStatus(EXTI_Line8) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 8 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line8);
  }
#else
  if(EXTI_GetITStatus(EXTI_Line9) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 9 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line9);
  }
#endif
}
allenfd 回答时间:2012-8-12 20:50:11

回复:STM32F10x 的EXTI 問題

回复第 2 楼 于2012-08-12 20:24:19发表:
 
当然可以设置EXIT5~EXIT15
  /* Connect EXTI9 Line to PB.09 pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
  /* Configure EXTI9 line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line9;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI9_5 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
 
/**
  * @brief  This function handles External lines 9 to 5 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI9_5_IRQHandler(void)
{
#if defined (STM32F10X_HD_VL) || defined (STM32F10X_HD) || defined (STM32F10X_XL)
  if(EXTI_GetITStatus(EXTI_Line8) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 8 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line8);
  }
#else
  if(EXTI_GetITStatus(EXTI_Line9) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 9 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line9);
  }
#endif
}
 

 
大大您好
我懂您所寫的
但是庫件裡面沒有EXTI9_5_IRQHandler的定義
請問這是要自己定義嗎?
火木 回答时间:2012-8-13 19:37:44

回复:STM32F10x 的EXTI 問題【悬赏问答】

他的中端向量是分开的,0-4,是单独的,5-9 10-15用两个中端向量实现,你可以查询下中端向量表,可以清晰的看到
zykzyk-93033 回答时间:2012-8-13 21:05:11

RE:STM32F10x 的EXTI 問題【悬赏问答】

请看:
/**
  * @brief  Configure PB.09 or PG.08 in interrupt mode
  * @param  None
  * @retval None
  */
void EXTI9_5_Config(void)
{
#if defined (STM32F10X_HD_VL) || defined (STM32F10X_HD) || defined (STM32F10X_XL)
  /* Enable GPIOG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOG, ENABLE);
  /* Configure PG.08 pin as input floating */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOG, &GPIO_InitStructure);
  /* Enable AFIO clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  /* Connect EXTI8 Line to PG.08 pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOG, GPIO_PinSource8);
  /* Configure EXTI8 line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line8;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI9_5 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
#else
  /* Enable GPIOB clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  /* Configure PB.09 pin as input floating */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  /* Enable AFIO clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  /* Connect EXTI9 Line to PB.09 pin */
  GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
  /* Configure EXTI9 line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line9;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  /* Enable and set EXTI9_5 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
#endif
}
配置:Configure PB.09 or PG.08 in interrupt mode PG 08 09 中断模式
中断函数:
void EXTI9_5_IRQHandler(void)
{
#if defined (STM32F10X_HD_VL) || defined (STM32F10X_HD) || defined (STM32F10X_XL)
  if(EXTI_GetITStatus(EXTI_Line8) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 8 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line8);
  }
#else
  if(EXTI_GetITStatus(EXTI_Line9) != RESET)
  {
    /* Toggle LED2 */
     STM_EVAL_LEDToggle(LED2);
    /* Clear the  EXTI line 9 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line9);
  }
#endif
}
青檬 回答时间:2012-8-14 09:16:40

回复:STM32F10x 的EXTI 問題【悬赏问答】

 
、PA0 ... PF0 共用一个中断标志 EXT0
      PA1 ... PF1 共用一个中断标志 EXT1
       .        .
       .        .
     PA15... PF15共用一个中断标志 EXT15
2、EXT5-9   共用一个中断源
      EXT10-15 共用一个中断源  
3、启用中断前,需ENABLE IO口的复用功能(AFIO)     
4、设置中断IO口
5、将IO口注册到中断线(将IO口映射到中断线N)
例:GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);    将GPIOD.3注册至                  
                                 中断线EXTILine3
       GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);     将GPIOD.4注册至
                                                                                                                                    中断线EXTILine4
6、配置中断
   EXTI_InitStructure.EXTI_Line        =   EXTI_Line3;
   EXTI_InitStructure.EXTI_Mode     =   EXTI_Mode_Interrupt;                   中断
                                                            =   EXTI_Mode_Event                        事件(触发其它模块)
   EXTI_InitStructure.EXTI_Trigger =   EXTI_Trigger_Rising                    上升沿触发
                                                              =    EXTI_Trigger_Falling                   下降沿触发
                                                              =   EXTI_Trigger_Rising_Falling      脉冲触发
7、配置NVIC  
8、如果使用库函数写中断,要开放stm32f10x_conf.h中的相应中断
----------------------------------------------------------------------------------------------------   
例:
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO, ENABLE);
                                                                                                                             /* PD3,4,5,6按键输入*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;   //上拉输入
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* 连接IO口到中断线 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);

/* 配置中断线3为边降沿触发*/
EXTI_InitStructure.EXTI_Line = EXTI_Line3;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

/*其他为下降沿触发*/
EXTI_InitStructure.EXTI_Line = EXTI_Line4|EXTI_Line5|EXTI_Line6;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
蓝调街口-366393 回答时间:2012-8-18 09:27:44

RE:STM32F10x 的EXTI 問題【悬赏问答】

2010-12-06 11:33 STM32 GPIO中断的使用
/*
外部中断/事件我的理解是可以将单片机的IO口全部设置为外部中断口,我们可以根据触发哪个IO口中断,去执行相应的中断处理函数。这个其实很简单,51一般有2个外部中断口,而stm32将其扩展,每个IO口都可以作为外部中断口。
外部中断配置也很简单,只需要打开相应的IO口配置,时钟,打开stm32f10x_conf.h里的 #include "stm32f10x_exti.h" ,配置EXIT和中断处理函数即可。下面是简单的实例(基于3.0库):
*/
void GPIO_Configuration(void)
{
    //配置GPIOC_5口作为外部中断口
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_5;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
    GPIO_InitStructure.GPIO_Mode   = GPIO_Mode_IN_FLOATING ;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void EXTI_Configuration(void)
{
    EXTI_InitTypeDef EXTI_InitStructure;
    EXTI_InitStructure.EXTI_Line    = EXTI_Line5;                 //外部中断线
    EXTI_InitStructure.EXTI_Mode    = EXTI_Mode_Interrupt;        //中断模式
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;       //中断触发方式
    EXTI_InitStructure.EXTI_LineCmd = ENABLE;                     //打开中断
    EXTI_Init(&EXTI_InitStructure);
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource5);   //选择 GPIO管脚用作外部中断线路
}
void NVIC_Configuration(void)
{
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);               // 抢占式优先级别
    NVIC_InitStructure.NVIC_IRQChannel            = EXTI9_5_IRQn; //指定中断源
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;            // 指定响应优先级别1
    NVIC_InitStructure.NVIC_IRQChannelCmd         = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}
//中断处理函数
void EXTI9_5_IRQHandler(void)
{
    if (EXTI_GetITStatus(EXTI_Line5) != RESET)
    {
        //添加中断处理程序

        EXTI_ClearFlag(EXTI_Line5);
        //EXTI_ClearITPendingBit(EXTI_Line5);                       //本函数与上一句功能相同
    }
}
xiaodc88 回答时间:2012-8-26 17:25:28

RE:STM32F10x 的EXTI 問題【悬赏问答】

可以的,实践证明没有问题
cjq_enjoy-15073 回答时间:2012-8-28 11:54:40

RE:STM32F10x 的EXTI 問題【悬赏问答】

学习了

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版