问题背景:
在做低功耗外部中断唤醒的时候,发现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
*/
}
总结
做低功耗之前,在前期规划的时候就要将唤醒脚合理规划布置,免得后面硬件根本不支持再头疼。