2841 views|2 replies

16

Posts

0

Resources
The OP
 

[Serial] [Starlight Lightning STM32F407 Development Board] Chapter 10 Serial Communication Experiment [Copy link]

Chapter 11 Serial Port Communication Experiment 11.1 Purpose Through this experiment, you will master the use of STM32 serial port and realize sending and receiving data through the serial port. For the data sheet, please refer to Chapter 26. 11.2 Experimental Introduction Serial communication is a very common serial communication method between devices. The serial port sends and receives bytes by bit. Although it is slower than parallel communication by byte, the serial port can send data on one line while receiving data on another line. Most electronic devices support this communication device. As the main interface for data exchange between computers and single-chip microcomputers, it is widely used in various instruments, industrial detection and automatic control fields. The communication protocol is an agreement reached by the two parties who need to communicate. It makes unified regulations on issues including data format, synchronization mode, transmission speed, transmission steps, error detection and correction methods, and control character definitions, and both parties must comply with them. Serial communication is generally divided into physical layer and protocol layer. The physical layer specifies the characteristics of the mechanical and electronic functional parts in the communication system to ensure the transmission of the original data in the physical media. The protocol layer mainly specifies the communication logic and unifies the data packaging and unpacking standards of the sender and receiver. Physical layer: It is the lowest level signal transmission. The well-known RS232 and RS485 chips are the level conversion of the physical layer, which converts the TTL level of the microcontroller into the corresponding interface level. The F407 development board has a USB to serial port chip on board, which converts the TTL signal into the differential signal of the USB interface. This is also a physical layer chip. RS232 and RS485 will be introduced in the following experiments. Serial communication is divided into simplex, half-duplex and full-duplex, depending on the transceiver chip of the physical layer:  Simplex: can only be transmitted from one party A to the other party B.  Half-duplex: can be transmitted in both directions, but not at the same time.  Full-duplex: can be transmitted in both directions at the same time. Protocol layer: The format of a character transmitted by the serial port is divided into start bit, data bit, parity bit, stop bit and idle bit.  Start bit: sends a logic "0" signal to indicate the start of character transmission.  Data bit: Immediately after the start bit, the number of data bits can be 5, 6, 7, or 8. Generally, 8 bits are used, and the lowest bit is transmitted first.  Parity bit: Parity is a simple error correction method in serial communication. After the data bit is added with this bit, the number of bits of 1 is even (even parity) or odd (odd parity).  Stop bit: It is a sign that a character data transmission has ended. It can be a high level of 1 bit, 1.5 bits, or 2 bits.  Idle bit: In the logic "1" state, it means that there is no data on the current transmission line.
11.3 Circuit Design
The Starlight Lightning F407 development board has a built-in USB serial port. The chip uses CH340G and the interface uses a MINI USB interface. It is connected to PA9 and PA10 of USART1 of STM32. The circuit is shown in Figure 11.3..1:
Figure 11.3.1
11.4 Software Design
Open 3, Program Source Code->1, Basic Experiment->Experiments8 Serial communication experiment project, open the Usart.c file under the BSP in the left directory tree. This is the driver file of the serial port. The project directory is shown in the figure below: 387302 Figure 11.4.1 Open the Usart.c file, the code is as follows: 387303 387304 387305 387306 11.5 Download verification
UseMINI USB cable to connect the computer and development board through CN3's USB port, flip the power switch to power on the development board, the D3 power indicator lights up, connect the JLINK/ST-LINK download debugger,open the "Experiment 8 Serial Communication Experiment" project code, compile and download, open the serial port debugging assistant, the serial port baud rate115200, press KEY1 once to send a message, and when a message is received, the received content will be sent back.
This content is originally created by EEWORLD forum user hejecu. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source


图片3.png (13.49 KB, downloads: 0)

图片3.png

图片4.png (147.63 KB, downloads: 0)

图片4.png

图片5.png (57.14 KB, downloads: 0)

图片5.png

图片6.png (47.59 KB, downloads: 0)

图片6.png

图片7.png (14.65 KB, downloads: 0)

图片7.png

实验8 串口通信实验.zip

652.63 KB, downloads: 17

This post is from stm32/stm8

Latest reply

Using DMA with idle interrupts will reduce bus resource usage  Details Published on 2018-11-15 10:02
 

1368

Posts

6

Resources
2
 
Using DMA with idle interrupts will reduce bus resource usage
This post is from stm32/stm8
 
Personal signature专注智能产品的研究与开发,专注于电子电路的生产与制造……QQ:2912615383,电子爱好者群: void
 

16

Posts

0

Resources
3
 
Lazy Cat Loves Flying Published on 2018-11-15 10:02 Using DMA, combined with idle interrupts, will use less bus resources
Yes, the serial port communication of the development board uses interrupt mode, not DMA
This post is from stm32/stm8
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list