[英]how to use EXTI interrupt with HAL library for stm32f1?
我需要在我的 stm32f103 板的 A1 端口上配置一個 exti 中斷。 我使用 stm32cubemx 創建了一個模板,但我正在嘗試手動配置中斷,因為它是我已經編寫的代碼的新功能。 我正在閱讀很多主題,但我沒有找到任何解決方案。 在這個項目中,我使用 HAL 庫並按照以下步驟操作:
配置GPIO
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
啟用 IRQ
HAL_NVIC_SetPriority(EXTI1_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
自定義回調
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == STEP_PIN)
{
GlobalMotorData.step.longint++;
}
}
i wrote The callback function in a new.c file and i do not touch the same function inside stm32f1xx_hal_gpio.c
我沒有啟用宏 HAL_EXTI_MODULE_ENABLED 因為項目找不到 corrisponding.h header 文件但沒有宏,代碼構建沒有錯誤。
我忘記了什么?
謝謝你
您很可能缺少 EXTI1 中斷處理程序:
void EXTI1_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.