简体   繁体   中英

stm32 doesn't receive a Rx interrupt from UART

I'm trying to implement simple echo for UART on stm32f4 discovery board (using freertos). As far as I understand it should be very easy. First I call HAL_UART_Receive_IT(&huart3, &rx_char,1) in a task. And after receiving an interrupt USART3_IRQHandler should trigger. And then in HAL_UART_RxCpltCallback I'll do HAL_UART_Transmit(&huart3, &rx_char, 1, timeout) and maybe re-enable it with HAL_UART_Receive_IT . Did I get the idea right? Should it work?

But in my case it doesn't. I'm trying to send a char from the terminal, but USART3_IRQHandler is never triggered. Nothing happens.

The code was generated using Stm32CubeMX with Freertos, USART3, NVIC and with USART3 global interrupt enabled.

Also I call __HAL_UART_ENABLE_IT(&huart3, UART_IT_RXNE) in main function. What is wrong? HAL_UART_Transmit works perfectly.

HAL isn't ideal library. You must check registers, if something went wrong. Your problem is looking like non-working NVIC. Check it, and if it wasn't turning on use something like - NVIC_EnableIRQ(USART3_IRQn); Or may be wasn't switch on RE register in CR1 in USART3. Anyway, I'm repeating - check registers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM