用的EXIT2,
__HAL_RCC_SYSCFG_CLK_ENABLE();
EXTI->IMR1 |=0x0004;
HAL_NVIC_SetPriority(EXTI2_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(EXTI2_IRQn);
void EXTI2_IRQHandler(void)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_2);
HAL_GPIO_WritePin( GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
HAL_Delay(300);
HAL_GPIO_WritePin( GPIOA, GPIO_PIN_5, GPIO_PIN_RESET );
}
我在定时器中断里软件触发EXTI2,
void TIM1_UP_TIM16_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */
/* USER CODE END TIM1_UP_TIM16_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */
EXTI->SWIER1 |=0x0004;
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */
}
测试OK. 供参考。 |