cancel
Showing results for 
Search instead for 
Did you mean: 

UART Hardware Flow RTS/CTS

nguen nguyen
Associate II

when data send RTS is low level

Can i change hal library to RTS high level to send data via uart?

4 REPLIES 4
Danish1
Lead II

This would only be possible if the hardware of the USART in your particular stm32 supported this.

And it might be that the library chooses to hide such a feature in order to present a common interface independent of whether such a feature were present or not.

I'm not aware of any that do support inversion of the RTS polarity. But then I don't know the entire family so it might be that your one can do this in hardware.

On the other hand, there's nothing stopping you doing this in software. You'd need to program RTS as a GPIO input (rather than alternate-function), and enable interrupts on change to high. Then you'd could run the USART to transfers by interrupt (rather than DMA), putting enough intelligence in the USART interrupt handler to stop TX (and disable the TXEIE / TCIE interrupts) when RTS is low; re-enabling them when you get a rising-edge-interrupt on RTS.

This is all possible. But you need much greater understanding of the peripheral itself as described in the Reference Manual; things that the ST/HAL libraries hide from you (which gets you started much more quickly but might not let you do precisely what you want to).

Hope this helps,

Danish

Bob S
Principal

Making the RTS output active high would make your serial port non-standard. The RS/EIA-232 standard says that the "control" signals (RTS, CTS, DTR, DSR) have a positive voltage when "active" ON THE RS/EIA-232 CABLE (i.e. after the level shifters from your CPU). The RS/EIA-232 level shifters act like an inverter - they take 0V from your CPU and generate a positive voltage (generally 3V to 12V), and +3.3 or +5V in and generate a negative voltage (generally -3V to -12V). Therefore, the RTS signal out of your CPU must be active low. Likewise, the CTS input to your CPU must also be active low.

And it looks like at least the STM32L4xx family doesn't support changing the polarity of the RTS signal.

nguen nguyen
Associate II

Thanks so much,

My peripheral works with RTS  active high :D

Thanks,

use software I know ,but using hardware stm32 supported it will be simpler

I think I should be do this in software