VIPPER
VIPPER

Reputation: 352

STM32 HAL UART RXNE interrupt not generated

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?

Upvotes: 2

Views: 3999

Answers (2)

ohzso
ohzso

Reputation: 1

I just met a similar problem,and finally find the reason: I put a jlink debugger breakpoint at wrong place,The debugger has already read out uart data,which will automatically reset rxne register,and then the code in irq handler will ignore uart data. so,I reset debugger and mcu,kill all breakpoints,put the only one breakpoint behind in the irq handler,this time,it successfully catched the uart data.

Upvotes: 0

LoriB
LoriB

Reputation: 391

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

Upvotes: 6

Related Questions