I'm using HAL drivers with code generated by CubeMX. In main routine I called HAL_UART_Receive_IT()
. After transmitting data over UART (which is connected in a loopback fashion) I can see the module is receiving byte and setting RXNE bit in registers. However interrupt is not generated? I can't explain why... In HAL_UART_Receive_IT()
function there is code enabling interrupts, so what's wrong?
2
votes
It is somewhat tricky to guess without the specific code, my suggestion would be to peek at the I/O register settings in the debugger to spot oddities in the initialization and if that fails extract a minimal repro case with direct register writes to post here. Anyway, can you elaborate on how you know that the interrupt is not being issued? Have you verified that interrupt vector is properly routed and that interrupts have not been masked globally?
– doynax
1 Answers
5
votes
You are not giving enough info and code in your question. Anyway, in your stm32xx_hal_msp.c file you initialize your peripheral from hardware point of view: be sure to enable interrupts too
HAL_NVIC_SetPriority(USART1_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(USART1_IRQn);
Then add
void USART1_IRQHandler(void)
{
HAL_UART_IRQHandler(&huart1);
}
to your stm32xx_it.c file