STM32 LLD for UART with bus idle detection

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
michael_s
Posts: 4
Joined: Thu Dec 03, 2015 3:31 pm
Location: Dresden
Been thanked: 1 time
Contact:

STM32 LLD for UART with bus idle detection

Postby michael_s » Wed Oct 04, 2017 4:38 pm

Hello Giovanni,

I would like to upvote this feature also as we need free bus detection for our RS-485 implementation.

In addition to checking USART_SR_IDLE, it would be necessary to check the BUSY flag (bit 16) in USART_ISR register also, since USART_SR_IDLE is only set by hardware once an idle condition is present and is not cleared in case the bus becomes busy in the meantime. So, I would propose:

Code: Select all

/* Timeout interrupt source is only checked if enabled in CR1 and if BUSY flag is not set.*/
if ((sr & USART_ISR_IDLE) && (cr1 & USART_CR1_IDLEIE) && (sr & 0x10000U) {
  _uart_timeout_isr_code(uartp);
}


BUSY flag is hardcoded (0x10000U) since CMSIS header does not provide it.
What do you think?

User avatar
Korken
Posts: 270
Joined: Wed Apr 02, 2014 4:09 pm
Location: Luleå, Sweden
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: STM32 LLD for UART with bus idle detection

Postby Korken » Wed Oct 04, 2017 6:29 pm

I also would very much like this feature.

neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Location: Dresden, Germany
Has thanked: 10 times
Been thanked: 5 times

Re: STM32 LLD for UART with bus idle detection

Postby neums » Wed Oct 11, 2017 6:51 am

Hi,
is this item on track? I whould appreciate this feature. :-)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32 LLD for UART with bus idle detection

Postby Giovanni » Sun Jan 06, 2019 5:07 pm

Necro thread...

The code in the idle detection is different now, is such a change still required?

Giovanni

michael_s
Posts: 4
Joined: Thu Dec 03, 2015 3:31 pm
Location: Dresden
Been thanked: 1 time
Contact:

Re: STM32 LLD for UART with bus idle detection

Postby michael_s » Mon Jan 07, 2019 1:22 pm

Giovanni wrote:The code in the idle detection is different now, is such a change still required?
Giovanni


Yes, I think also checking the BUSY-Bit in USART_ISR register is beneficial over just checking the IDLE-Bit in case the idle timeout shall be used to detect a "bus free" condition. By checking the BUSY-Bit, we can avoid to detect a non-idle line falsly as idle if a reception has just started and the first word is currently received.

However, as I understand, not all STM32 variants have the BUSY-Bit implemented.

Quote STM32F769 Reference Manual (page 1303):
BUSY: Busy flag
This bit is set and reset by hardware. It is active when a communication is ongoing on the
RX line (successful start bit detected). It is reset at the end of the reception (successful or
not).
0: USART is idle (no reception)
1: Reception on going


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 10 guests