2023-02-07 09:13 AM
I have three UARTs on the board, all passed the loopback test (wire the tx and rx pin together on the same UART)
Then I connect UART 1 to UART2 while UART 1 is transmitter and UART2 is receiver.
UART 1 is using HAL_UART_Transmit() to send data to UART2.
On the UART2 side, after initialization, I did
__HAL_UART_ENABLE_IT(uart_interrupt_config.huart, UART_IT_RXNE); // read data register not empty interruption
IRQ_SetPriority(UART2_IRQn, 0);
IRQ_Enable(UART2_IRQn);
I put a break point inside UART2_IRQhandler but never reaches there.
What am I missing here?
Thanks in advance
2023-02-07 09:39 AM
If using HAL_UART_Transmit(), why not using HAL_UART_Receive_IT() for the other UART beforehand? Shall work, and you can optimize later by looking at the HAL source code.
hth
KnarfB
2023-02-07 09:50 AM
Thank you @KnarfB
But what do I do wrong in my original approach?
2023-02-07 10:04 AM
Hmm, the devil is in the details. UART2_IRQhandler is definitively misspelled. And your're mixing different levels like HAL, __HAL, and IRQ_, not NVIC_EnableIRQ ?, are all clocks enabled? I simply don't see enough. Try the HAL-only approach and refine after that is working.
hth
KnarfB
2023-02-07 10:06 AM
I took these functions from the HAL_driver. I think there are difference between cortex A and Cortex M HAL drivers
2023-02-07 10:09 AM
Just to clarify the variable in my original post
UART_HandleTypeDef *huart; (This variable is in a struct)
uart_interrupt_config.huart = UART2;
__HAL_UART_ENABLE_IT(uart_interrupt_config.huart, UART_IT_RXNE);