2011-03-18 10:50 AM
STM32 and UART Problem (EIA-485)
2011-05-17 05:28 AM
From the reference manual
The USART can be configured to follow a single wire half duplex protocol. The selectionbetween 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).
2011-05-17 05:28 AM
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.2011-05-17 05:28 AM