STM32 basic routines

Hardware preparation

Experimental purpose

Analyze the SBUS protocol data received by the HT-10A remote controller receiver through the ROS control board, and print the values of each channel through the serial port.

HT-10A remote control

You need to install 4 No. 5 batteries in advance to power the HT-10A remote control:

image-20241211160408141

HT-10A remote controlDefault channel: The remote control does not perform channel mapping
CH1Right joystick: slide left and right
CH2Right joystick: slide up and down
CH3Left joystick: slide up and down
CH4Left joystick: slide left and right
CH5SWA channel
CH6SWB channel
CH7SWC channel
CH8SWD channel
CH9VRA channel
CH10VRB channel

SBUS receiver

The picture shows the hardware connection between the SBUS receiver and the ROS control board:

SBUS receiverROS control board
SS
+V
-G

image-20241211174339622

STM32 project

The tutorial only demonstrates the main code and functions: For detailed project code, refer to the [Software Materials] folder.

Configuration pin

ROS control board schematic

The SBUS interface is connected to the PA3 pin (RX pin of serial port 2) of the ROS control board:

image-20241212100206198

Project pin configuration

Mode:Asynchrinous

Basic Parameters:

Baud Rate:100000

Word Length:9

Parity:Even

Stop Bits:2

Data Direction:Receive and Transmit

Enable NVIC:USART2 global interrupt

image-20241212100706599

image-20241212100828355

Implementation principle

Serial port 2 receives the data of each channel sent by the SBUS receiver and parses it, and prints the correct data through serial port 1.

Core code

Serial port function

SBUS data

Main function

Hardware connection

SBUS receiverROS control board
SS
+V
-G

image-20241211174339622

Download program

Use FlyMcu program to download the program: Different development boards have different ways to enter the download program mode. The ROS control board needs to press the BOOT button before powering on and release it after connecting to the computer

①: Serial port number and baud rate settings → The serial port number can be viewed in the system device manager, and the baud rate is 115200

②: Program file → Select the .hex file of the SBUS project: located in the Debug folder of the SBUS project

③④: Select according to the content in the picture

⑤: Confirm that all options are set correctly and click the burn option

image-20241212104248589

Experimental phenomenon

After downloading the SBUS file of the project to the ROS control board, the LED flashes every 200 milliseconds. We can connect the computer through the MicroUSB interface of the ROS control board and view the data of each channel of the HT-10A remote control through the serial port.

Note: The serial port option settings are set according to the figure below!

image-20241212114008807