【STM32】外部中断不可以同PIN

问题背景:

在做低功耗外部中断唤醒的时候,发现PD2配置成外部中断唤醒之后,之前配置的PB2不可以正常唤醒了,注释掉PD2的外部中断GPIO配置之后,又可以正常唤醒。

问题原因:

查阅资料发现STM32的外部中断即使是不同PORT,但是只要是同PIN也是不可以同时配置为外部中断使用的。我们看STM32CubeMX发现配置的时候也是配置不了的,是互斥的。

STM32外部中断不可以共用PIN

这也验证了HAL库中外部中断回调函数只有一个形参PIN的判断,不区分PORT。

/**
  * @brief  EXTI line detection callback.
  * @param  GPIO_Pin Specifies the port pin connected to corresponding EXTI line.
  * @retval None
  */
__weak void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(GPIO_Pin);

  /* NOTE: This function should not be modified, when the callback is needed,
           the HAL_GPIO_EXTI_Rising_Callback could be implemented in the user file
   */
}

/**
  * @brief  EXTI line detection callback.
  * @param  GPIO_Pin Specifies the port pin connected to corresponding EXTI line.
  * @retval None
  */
__weak void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(GPIO_Pin);

  /* NOTE: This function should not be modified, when the callback is needed,
           the HAL_GPIO_EXTI_Falling_Callback could be implemented in the user file
   */
}
总结

做低功耗之前,在前期规划的时候就要将唤醒脚合理规划布置,免得后面硬件根本不支持再头疼。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值