cancel
Showing results for 
Search instead for 
Did you mean: 

UART2 Rx Interrupt Firing straight away

PBens.3
Associate

I have a problem using the NUCLEO-G431KB. After set-up of UART2_RX_INT, the interrupt seems to trigger and goes straight into the interrupt before any data has been put onto the receive pin of the UART. I have used Cube MX to generate the initalise. What could be causing this?

These two lines of code are used as part of the UART2 set-up.

__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE );

HAL_UART_Receive_IT(&huart2, Rx2Buff, Uart2BuffLen);

Thanks

4 REPLIES 4

> What could be causing this?

Read out and check flags in the UART status register.

JW

PS. Note, that normally you should not run your program while debugger is reading the registers.

gbm
Lead III

Enable the pull-up on the RX pin in GPIO configuration tab.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Thanks for the suggestion, but still does the same thing.

Bob S
Principal

Probably not the issue, but are you explicitly calling __HAL_UART_ENABLE_IT()? That is typically done in HAL_UART_Receive_IT() or some function that it calls.

Perhaps post your code? And what is connected to the RX pin?