0
votes

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.

1
My advice - when you start with new architecture / peripheral / library / hardware try first without RTOS. When you learn how to use it go further. Otherwise you will stack with the simplest tasks0___________

1 Answers

0
votes

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.