cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_Receive_IT did not trigger IRQ

Dilbert K
Senior
Posted on April 25, 2017 at 04:48

I am using the example to create a UART receive 

STM32Cube_FW_F4_V1.15.0\Projects\STM32F411RE-Nucleo\Examples\UART\UART_Printf\SW4STM32

When I used the 'HAL_UART_Receive', then it is fine.

I have made following changes to example code, but did not get any IRQ nor the callback.

Below are the code I added

Serial_Open(void)  --> this is called in Main after SystemClock_Config()

{

   UartHandle.Instance = USART2;

   status=HAL_UART_Init(&UartHandle); 

   status=HAL_UART_Receive_IT(&UartHandle,uartRxBuf,1); 

}

void USART2_IRQHandler(void)

{

    HAL_UART_IRQHandler(&UartHandle);

}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

    uartRdLen++;

    HAL_UART_Receive_IT(&UartHandle, uartRxBuf, 1);

}

I checked startup_stm32f411xe.s, the vector function name is correct

g_pfnVectors:

.word USART2_IRQHandler  /* USART2 */

What else I am missing ??

2 REPLIES 2
Posted on April 25, 2017 at 05:06

Is it actually receiving anything? Do you see RXNE assert? Review in your main() loop, not in a debugger view

The callback will only occur if the IRQ occurs and calls HAL_UART_IRQHandler() 

Are you using C++, or a .CPP file? If so you must use the following form

extern 'C' void USART2_IRQHandler(void)

{

...

Check .MAP and actual linkage in table.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 25, 2017 at 17:23

Thanks for suggestions.

At the end, it was the basic.... Interrupt not enabled.

HAL_NVIC_EnableIRQ(USART2_IRQn)