AnsweredAssumed Answered

STM32 UART/USART RX message terminator detection with LIN Mode

Question asked by mauro.cerisola on Sep 1, 2015
Latest reply on Jun 7, 2017 by mauro.cerisola
Hi everybody,
I am using several flavours of STM32: STM32F407, STM32F030, STM32F071, STM32F303 (soon).

Concerning UART, I want to set up a protocol using variable-length messages.
In order to minimize the CPU overhead, I want to use the TX with DMA and interrupt at the end of the transmitted message, and RX with DMA and interrupt at the end of the received message.

       
  • On the TX side I can fire an IRQ with TXE or TC status bits, that's fine.
  •    
  • On the RX side I want to fire an IRQ at the end of the received message. Since the protocol uses variable-length messages, how can the RX tell the received message has ended?
At first I thought I might exploit a scheme for few-char idle line detection:
       
  • RTOF (RX timeout)
  •    
  • CMF (Character match)
  •    
  • I don't like using IDLE because it would fire and IRQ as soon as the TX leaves the line idle for just 1 char, no mercy for the TX being a little busy sometimes...
But I discovered that the USART of the STM32F407, which is the richest MCU of the ones I am using, doesn't implement RTOF and CMF. Sounds strange...

Anyway, I thought I could use the Break character as a message terminator.
According to the Reference manuals, on the RX side the Break character is treated as a Framing error. Uhm... I don't like using this as a message terminator, as there's no way to distinguish it from a real error.

But the LIN mode seems to handle it slightly different, requiring *all* received bits as 0 (mark). The Break character used in LIN Mode sounds like a viable message terminator, although STM32F030 doesn't implement the LIN Mode.

I have no experience with LIN mode, can you give me some advice?

Q1: On the TX side, is there any difference with UART mode @ 8-bit data length?

Q2: On the RX side, apart from the Break character handling, is there any difference with UART mode @ 8-bit data length?

Q3: Any other caveats or constraints with LIN mode?

Best regards,
Mauro

Outcomes