Hardware Serial-USART-synchronous mode or asynchronous mode

Post here first, or if you can't find a relevant section!
Post Reply
mustaq_ahm
Posts: 17
Joined: Tue Sep 14, 2021 11:08 am
Answers: 2

Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mustaq_ahm »

Hi everyone!

This is just general topic. I also want to implement in my work. I have a STM32F103C8T6 with Stm32duino offical core running in it.

My question is can we program the microcontroller with USART in synchronous mode? For communication between two STM32F103C8T6 custom made boards. I want to use USART_1 in synchronous mode to transmit or recive data. How can I do that?

I have alredy did some programming. But I think that runs in asynchronous mode that is in half duplex mode.

I have configured my Hardware Serial USART_1 in PA9 as Tx and PA10 as Rx and PC14 as USART_ENABLE to the maxRS485. Whenever I need to send data from microcontroller_1 to microcontroller_2, then I have to make my eable pin HIGH for microcontroller_1 and LOW for microcontroller_2. Then when I need to send data from microcontroller_2 to microcontroller_1 then I have to change the enable pin as HIGH for microcontroller_2 and LOW for microcontroller_1.

I am littel bit confused. Whether I am using synchronous or asynchronous mode in USART_1 in microcontrollers. I know that USART synchronous mode transfer data much faster then asynchronous mode. But after refering official stm32f103 reference mannual and from lots results from internet makes me to think that I might be using asynchronous mode in USART_1. But, I am not sure.

And I also do not see any examples in online for USART in synchronous mode for STM32F103C8T6 board in Arduino IDE. All the examples available are for USART asynchronous mode, I think.

Please let me know your suggestions, oppinions, and corrections for me. Also, please let me know if I am doing something wrong or am I lacking some knowledge in something.

Greetings,
Mustaq
by mustaq_ahm » Mon Sep 27, 2021 10:08 am
Thanks all for your time and replies. I would look into this in detail.
Go to full post
Last edited by mustaq_ahm on Mon Sep 27, 2021 6:42 am, edited 1 time in total.
mrburnette
Posts: 557
Joined: Thu Dec 19, 2019 1:23 am
Answers: 4

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mrburnette »

Hardware Serial USART
USART == Universal Synchronous Asynchronous Receiver Transmitter
STM32F103 SPI (Serial Peripheral Interface) is a synchronous serial communication protocol. In this interface, in addition to transmit and receive lines, there is a third line that is used for clock line. Each slave device also has a chip select (enable) pin, that is used for activating the device.
https://www.handsonembedded.com/stm32f1 ... %20device.
mustaq_ahm
Posts: 17
Joined: Tue Sep 14, 2021 11:08 am
Answers: 2

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mustaq_ahm »

But, I would like to work on USART synchronous mode protocol which is given in this https://www.st.com/resource/en/referenc ... ronics.pdf manual at chapter 27.3.9 (Pg: 805). Also, SPI is not recomonded widely to communicate between two different boards, I think.

Also, I know that in asynchronous mode of USART the data transfer is little bit slower compared to synchronous mode of USART.

I might be wrong please correct me, if I am wrong.
mrburnette
Posts: 557
Joined: Thu Dec 19, 2019 1:23 am
Answers: 4

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mrburnette »

27.3.9 USART synchronous mode
The synchronous mode is selected by writing the CLKEN bit in the USART_CR2 register to
1. In synchronous mode, the following bits must be kept cleared:
 LINEN bit in the USART_CR2 register,
 SCEN, HDSEL and IREN bits in the USART_CR3 register.

The USART allows the user to control a bidirectional synchronous serial communications in
master mode. The CK pin is the output of the USART transmitter clock. No clock pulses are
sent to the CK pin during start bit and stop bit. Depending on the state of the LBCL bit in the
USART_CR2 register clock pulses will or will not be generated during the last valid data bit
(address mark). The CPOL bit in the USART_CR2 register allows the user to select the
clock polarity, and the CPHA bit in the USART_CR2 register allows the user to select the
phase of the external clock (see Figure 289, Figure 290 and Figure 291).

During idle, preamble and send break, the external CK clock is not activated.
In synchronous mode the USART transmitter works exactly like in asynchronous mode. But
as CK is synchronized with TX (according to CPOL and CPHA), the data on TX is
synchronous.

In this mode the USART receiver works in a different manner compared to the
asynchronous mode. If RE=1, the data is sampled on CK (rising or falling edge, depending
on CPOL and CPHA), without any oversampling. A setup and a hold time must be
respected (which depends on the baud rate: 1/16 bit time).

Note: The CK pin works in conjunction with the TX pin. Thus, the clock is provided only if the
transmitter is enabled (TE=1) and a data is being transmitted (the data register
I am a Student working on a company project.
Yes, I understand you are working on your Masters, but ... IMO, you are somewhat on your own as this is obviously possible, but I have no example code and I have never used this outliner mode of usage. Maybe Frederic has some words of wisdom or a known example that has defied my Google'tize. I know we live in a crowd-source world, but I thought original research was still valued: If Frederic w/ STM provides your answer, does he get a footnote in your Thesis?

Ref: https://forum.arduino.cc/t/spi-communic ... rds/689577
ag123
Posts: 1000
Joined: Thu Dec 19, 2019 5:30 am
Answers: 7

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by ag123 »

For 'synchronous' comms, try something with SPI, such as an SPI LCD. Once you figured that out, U 'synchronous' RT
https://en.wikipedia.org/wiki/Universal ... ransmitter
becomes easier to understand
mrburnette
Posts: 557
Joined: Thu Dec 19, 2019 1:23 am
Answers: 4

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mrburnette »

ag123 wrote:
Fri Sep 24, 2021 7:31 pm
For 'synchronous' comms, try something with SPI, such as an SPI LCD. Once you figured that out, U 'synchronous' RT
https://en.wikipedia.org/wiki/Universal ... ransmitter
becomes easier to understand
ag123:
Op "desires" to use USART for "syncronous serial" ... I suspect s/he has sufficient expertise to use SPI, just not what is desired.
mustaq_ahm wrote:
Fri Sep 24, 2021 4:24 pm
But, I would like to work on USART synchronous mode protocol ...
Until Op made reference to the statement in the Reference Man, I was unaware of such usage and while I have read the document many times, the described mode has never come up in my many years around the STM32F103xxxx ... which is almost saying I do not have a clue on how to approach the solution other than to dig-in, prototype code, test, repeat until it works on the test bench.

Ray
mustaq_ahm
Posts: 17
Joined: Tue Sep 14, 2021 11:08 am
Answers: 2

Re: Hardware Serial-USART-synchronous mode or asynchronous mode

Post by mustaq_ahm »

Thanks all for your time and replies. I would look into this in detail.
Post Reply

Return to “General discussion”