cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 and UART Problem (EIA-485)

lcmuller
Associate II
Posted on March 18, 2011 at 18:50

STM32 and UART Problem (EIA-485)

3 REPLIES 3
Posted on May 17, 2011 at 14:28

From the reference manual

The USART can be configured to follow a single wire half duplex protocol. The selection

 

between half and full duplex communication is done with a control bit ‘HALF DUPLEX SEL’

 

(HDSEL in USART_CR3).

 

As soon as HDSEL is written to 1:

 

�? RX is no longer used,

 

�? TX is always released when no data is transmitted. Thus, it acts as a standard I/O in

 

idle or in reception. It means that the I/O must be configured so that TX is configured as

 

floating input (or output high open-drain) when not driven by the USART.

 

 

My reading of this is that the interface uses ONE pin (SINGLE WIRE), and it's not the RX pin (PA.03). I'd suggest you don't use Half Duplex, and instead manage your IO interactions with the USART so as not to chirp over incoming data.

From readme.txt from the HalfDuplex example

 

Hardware environment

 

====================

 

This example runs on STMicroelectronics STM3210B-EVAL and STM3210E-EVAL evaluation

 

boards and can be easily tailored to any other hardware.

 

To select the STMicroelectronics evaluation board used to run the example, uncomment

 

the corresponding line in platform_config.h file.

 

 

 + STM3210B-EVAL

 

    - Connect USART1_Tx(PA.09) to USART2_Tx(PD.05) and connect a pull-up resistor to

 

      this line (10K).

 

 

 + STM3210E-EVAL

 

    - Connect USART1_Tx(PA.09) to USART2_Tx(PA.02) and connect a pull-up resistor to

 

      this line (10K).

 

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 14:28

Glad it was that simple, the example code is very poorly commented in this regard. And probably wasted a lot of people's time, I only dug deeper because someone with a smart-card interface had a single wire bus that was similar.

The reading of the data register is presumably to clear the loop-back effect, but just glancing at the code it's not that obvious.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lcmuller
Associate II
Posted on May 17, 2011 at 14:28

That was it!

Thanks Clive I didnt think twice when I saw the half-dulpex command in the example since the MAX485 chip works in half duplex mode.

Will learn me to read the reference manual in more depth.