cancel
Showing results for 
Search instead for 
Did you mean: 

LL drivers USART - interrupt not working

simo zz
Senior

Hi all,

I am trying to use the USART1 with RX interrupt but I cannot make it working with code generated using STM32Cube IDE running on Linux.

The MCU is an STM32F407VG.

The ISR function (the only part of the code I modified according to the MCU TRM) is the following:

/**
  * @brief This function handles USART1 global interrupt.
  */
void USART1_IRQHandler(void)
{
  /* USER CODE BEGIN USART1_IRQn 0 */
  if(LL_USART_IsActiveFlag_RXNE(USART1) && LL_USART_IsEnabledIT_RXNE(USART1))
  {
	char x = LL_USART_ReceiveData8(USART1);
	LL_USART_TransmitData8(USART1, x);
  }
  /* USER CODE END USART1_IRQn 0 */
  /* USER CODE BEGIN USART1_IRQn 1 */
 
  /* USER CODE END USART1_IRQn 1 */
}

Could someone please suggest what could be wrong that makes the peripheral not working properly using its interrupt ?

Thanks.

s

5 REPLIES 5
  • UART not working at all for whatever reason - read out and check content of USART registers
  • interrupt not enabled in USART itself - read out and check content of USART_CR1
  • interrupt not enabled in NVIC - check NVIC_ISERx
  • ISR address not properly inserted into the vector table - check in disassembly
  • if VTOR is remapped, incorrect vector table is used
  • ISR *is* in fact firing, but there's some problem with the code within - put a breakpoint into ISR in debugger, put a simple and tested pin toggle there and observe with an oscilloscope/LA

JW

simo zz
Senior

@Community member​ ,

Shouldn't this setup be automatically be done by STM32Cube ???

s.

Do you want to get it working, or do you want to argue who's responsible?

JW

Pavel A.
Evangelist III

@simo zz​ So what is not working? does the interrupt arrive at all? You get spurious interrupts and cannot get out? Something else?

When using LL routines for USART, Cube should generate initialization code and the interrupt handler function, and enable the interrupt in NVIC.

But it won't create any code in the interrupt handler and won't enable any individual interrupts such as RXNE.

The latter is likely the missing part if you don't get interrupts at all.

- pa

simo zz
Senior

Actually, when I press debug, I cannot reproduce the correct behaviour of the interrupt.

To achieve so, I have to stop the debug and manually reset my board.

I strongly miss a simple "Flash chip" or "Run" button into STM32Cube.