From 33a2cc8fb47da9570b682530fe901545c30e192b Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Thu, 18 Jun 2026 15:02:19 +0200 Subject: [PATCH] Enable USART1 global interrupt --- Core/Inc/stm32f4xx_it.h | 1 + Core/Src/stm32f4xx_hal_msp.c | 6 ++++++ Core/Src/stm32f4xx_it.c | 15 +++++++++++++++ can_logger.ioc | 1 + 4 files changed, 23 insertions(+) diff --git a/Core/Inc/stm32f4xx_it.h b/Core/Inc/stm32f4xx_it.h index 08a2693..d4eaf0d 100644 --- a/Core/Inc/stm32f4xx_it.h +++ b/Core/Inc/stm32f4xx_it.h @@ -52,6 +52,7 @@ void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void DebugMon_Handler(void); +void USART1_IRQHandler(void); void SDIO_IRQHandler(void); void TIM6_DAC_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); diff --git a/Core/Src/stm32f4xx_hal_msp.c b/Core/Src/stm32f4xx_hal_msp.c index 61835fe..cfd77ff 100644 --- a/Core/Src/stm32f4xx_hal_msp.c +++ b/Core/Src/stm32f4xx_hal_msp.c @@ -392,6 +392,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) __HAL_LINKDMA(huart,hdmatx,hdma_usart1_tx); + /* USART1 interrupt Init */ + HAL_NVIC_SetPriority(USART1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspInit 1 */ /* USER CODE END USART1_MspInit 1 */ @@ -424,6 +427,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* USART1 DMA DeInit */ HAL_DMA_DeInit(huart->hdmatx); + + /* USART1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspDeInit 1 */ /* USER CODE END USART1_MspDeInit 1 */ diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c index 410f57b..d121dda 100644 --- a/Core/Src/stm32f4xx_it.c +++ b/Core/Src/stm32f4xx_it.c @@ -59,6 +59,7 @@ extern DMA_HandleTypeDef hdma_sdio_rx; extern DMA_HandleTypeDef hdma_sdio_tx; extern SD_HandleTypeDef hsd; extern DMA_HandleTypeDef hdma_usart1_tx; +extern UART_HandleTypeDef huart1; extern TIM_HandleTypeDef htim6; /* USER CODE BEGIN EV */ @@ -163,6 +164,20 @@ void DebugMon_Handler(void) /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ +/** + * @brief This function handles USART1 global interrupt. + */ +void USART1_IRQHandler(void) +{ + /* USER CODE BEGIN USART1_IRQn 0 */ + + /* USER CODE END USART1_IRQn 0 */ + HAL_UART_IRQHandler(&huart1); + /* USER CODE BEGIN USART1_IRQn 1 */ + + /* USER CODE END USART1_IRQn 1 */ +} + /** * @brief This function handles SDIO global interrupt. */ diff --git a/can_logger.ioc b/can_logger.ioc index 170b21c..2fc928d 100644 --- a/can_logger.ioc +++ b/can_logger.ioc @@ -124,6 +124,7 @@ NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false NVIC.TIM6_DAC_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true NVIC.TimeBase=TIM6_DAC_IRQn NVIC.TimeBaseIP=TIM6 +NVIC.USART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false PA10.Mode=Asynchronous PA10.Signal=USART1_RX