2021-05-15 07:48 PM
Hi,
I am using STM32L07xxx
I want to use USART4 and USART 5
So i generated code using STM32CUBEMX
Below is generated code for interrupt
void USART4_5_IRQHandler(void)
{
/* USER CODE BEGIN USART4_5_IRQn 0 */
/* USER CODE END USART4_5_IRQn 0 */
HAL_UART_IRQHandler(&huart4);
HAL_UART_IRQHandler(&huart5);
/* USER CODE BEGIN USART4_5_IRQn 1 */
/* USER CODE END USART4_5_IRQn 1 */
}
When interrupt happens , how i find which uart has generated an interrrupt between uart 4 and uart 5 ?
2021-05-16 02:21 AM
Normally, you would read out both UART status registers and act upon bits in them.
Cube is supposed to do this for you in HAL_UART_IRQHandler() (look at that function what does it do - Cube is open source) and then calls your callbacks passing a particular handler, if there is some event for the UART associated with that handler.
JW
2021-05-16 05:09 AM
Thanks,
handler is calling a callback
HAL_UARTEx_WakeupCallback(huart);
is there any flag for telling which uart ?
2021-05-16 05:15 AM
You can determine the uart using the instance handle, and the address of the uart peripheral therein.