0

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.

Logen Sand
  • 111
  • 3
  • 10
  • 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 tasks – 0___________ Jul 10 '17 at 13:25

1 Answers1

0

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.

luden
  • 113
  • 1
  • 1
  • 4
  • Actually no. This is not the case. I just tried to do it as PeterJ recommended. Without Freertos (and obvoiusly it didn't work). After that I just downloaded full Cube project for some Tutorial. Uploaded it without any changes to the board - same thing. Rx just doesn't work. I've tried different cables also. It just doesn't receive anything. It looks like I'm missing something very obvious (pins are connected properly :)). What could it be? – Logen Sand Jul 10 '17 at 16:02
  • What do you mean by wasn't switch on RE register in CR1? – Logen Sand Jul 10 '17 at 16:27
  • Oh, I got it. No, RE in CR1 is 1. It looks like that data I don't send any data. But I do. – Logen Sand Jul 10 '17 at 17:02
  • Huh, if you have oscilloscope, you can see what happen on RX. If not, you can try get data in main-cycle, without interrupts. It'll let us understand where problem, interrupt or usart. – luden Jul 11 '17 at 07:33