STM32F103C8T6, FreeModbus slave station design and testing (3)-clock, serial port initialization

Keywords: Modbus FreeModbus STM32F103C8T6 CubeMX

1. Development environment

(1) STM32CubeMX, version: 4.27.0. At the time of writing, the latest version has reached 6, but Kong Binghuo (WeChat public account: Kong Binghuo) is really not used to the interface after version 5, so I continue to use version 4.

figure 1

(2) MDK (Keil), version: 5.17. Some friends still use version 4. It is recommended to upgrade to version 5. After installing a compatibility package under 5, you can use version 5 to open the program of version 4.

2. Clock and serial port initialization

(1) New CubeMX project

Kong Binghuo (WeChat public account: Kong Binghuo) believes that this step is relatively simple. Click New Project in the initial interface, and in the configuration window that appears later, search for STM32F103C8 according to Figure 2, select this device, and then click Start Project.

figure 2

Then you come to the configuration interface in Figure 3, and the red frame is the same as the configuration in the figure. After the red box on the left is selected, the red box on the right will automatically come out. TIM2 is used for the timing of the 3.5 character period of RTU, which will be explained in detail in the next section Kong Binghuo (WeChat public account: Kong Binghuo).

image 3

 

The design experience sharing of single chip microcomputer, ARM, fieldbus, PLC, embedded software and hardware, adhering to the concept of "every bit is wisdom", share and communicate together.


Guess you like

Origin blog.51cto.com/2773203/2548133