AN1800
APPLICATION NOTE
STR71x BSPI
USED AS A UART
INTRODUCTION
This document presents a standard communication interface between a STR71x microcontroller and a PC. This communication is done through the STR71x BSPI peripheral and a serial
port of the PC using the RS232 protocol.
Rev. 3
AN1800/0405 1/7
1
STR71x BSPI USED AS A UART
1 BSPI COMMUNICATION
The main features of the BSPI communication peripheral are summarized below. Refer to the
STR71x reference manual for more details.
1.1 MAIN FEATURES
The Buffered Serial Peripheral Interface (BSPI) offers a flexible means of full-duplex data exchange with external equipment requiring an industry standard synchronous serial data
format.
The BSPI allows a very wide range of baud rates with different baud rates for transmission and
reception.
For BSPI, only four signals are needed, the first for transmission (MOSI), the second for reception (MISO), the third is the clock (SCLK) and the other is slave select (SS
1.2 BAUD RATES
Transmission and reception can be driven by their own baud rate generator. However be
aware that to communicate correctly, the receiver must have a reception baud rate strictly
equal to the transmission baud rate of the transmitter. As long as this condition is met, a wide
range of baud rates is possible.
).
1.3 FRAMES
The length of a data word can be 8 or 16 bits, these bits are transmitted Most Significant Bit
first.
2/7
2
STR71x BSPI USED AS A UART
2 RS232 COMMUNICATION WITH A PC
2.1 MAIN FEATURES
The electrical and protocol characteristics of RS232 are different from those of the STR71X
BSPI peripheral. In RS232 communication, high level is typically +7V and low level is typically
-7V, while the BSPI peripheral works with (0, +3.3V).
Furthermore, the polarities are different. A ’1’ bit coming from the BSPI corresponds to a ’0’ bit
in RS232, and a ’0’ bit to a ’1’ bit. So it is necessary to implement a conversion between the PC
and the BSPI peripheral. In this application ST3232 is used for this purpose.
Also the BSPI transmits Most Significant Bit first but the PC receives the Least Significant Bit
first. That’s why we must invert the order before transmitting the data.
2.2 PC CONFIGURATION
The PC will be used as a terminal. The description below refers to the Windows environment.
This terminal application is called HyperTerminal.
Under Windows, open the “HyperTerminal” application. To configure it, go to the communication parameters menu. The options of this window must be the same as the ones defined with
your STR71x.
After selecting the right serial communication port, select the same baud rate as the one configured in the microcontroller. As the PC accepts only one baud rate, transmission and reception baud rates will have the same value. Data word length will be 7 bits, and choose to use 1
stop bit. “Flow control” can be either Xon/Xoff or none. The PC is then correctly configured.
3/7