cancel
Showing results for 
Search instead for 
Did you mean: 

USART in Synchronous Slave Mode with Interrupt not working

GS1
Senior III

Hi all,

I try to install a synchronous USART communication between 2 x STM32H743, one is the (transmitting only ) Master the other is the (receiving only) Slave. When transferring data via Polling everything seems to work well.

But when using HAL_USART_Receive_IT the USART produces an UDR Underrun error in the Slave USART. As this is a tranmission related error I disabled this error case in the HAL. But then I get an Overrun error interrupt after the first byte in the block.

Did anyone use the USART in synchronous mode as a Slave with Interrupt reception. (Or DMA - which I did not try yet)?

Init Code:

void MX_USART3_Init(void)

{

   husart3.Instance = USART3;

   husart3.Init.BaudRate = 1000000;

   husart3.Init.WordLength = USART_WORDLENGTH_8B;

   husart3.Init.StopBits = USART_STOPBITS_1;

   husart3.Init.Parity = USART_PARITY_NONE;

   husart3.Init.Mode = USART_MODE_RX;

   husart3.Init.CLKPolarity = USART_POLARITY_HIGH;

   husart3.Init.CLKPhase = USART_PHASE_2EDGE;

   husart3.Init.CLKLastBit = USART_LASTBIT_ENABLE;

   husart3.Init.Prescaler = USART_PRESCALER_DIV1;

   husart3.Init.SlaveMode = USART_SLAVEMODE_ENABLE;

   husart3.Init.FIFOMode = USART_FIFOMODE_ENABLE; // or DISABLE - doesn't change behaviour

   husart3.Init.TXFIFOThreshold = USART_TXFIFO_THRESHOLD_1_8;

   husart3.Init.RXFIFOThreshold = USART_RXFIFO_THRESHOLD_1_8;

   if (HAL_USART_Init(&husart3) != HAL_OK)

   {

      Error_Handler();

   }

}

1 REPLY 1

When you get tired of fighting the HAL spaghetti code, for use cases that probably haven't been rigorously tested/exercised, consider just writing a simple IRQ Handler to manage the UART comms.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..