简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM