Stepper motor is controlled by microcontroller and runs according to the timing sequence in the figure. How to implement it?

Use the state machine mode to do it. First build an array to save the timing time. First assign initial values ??to the three GPIO ports, start the timer, and determine the next state based on the current state. Next The timing value of each state is taken from the timing array with the state subscript.

Stepper motor is an open-loop control element stepper motor device that converts electrical pulse signals into angular displacement or linear displacement. Under non-overload conditions, the motor's speed and stopping position only depend on the frequency and number of pulses of the pulse signal, and are not affected by load changes. When the stepper driver receives a pulse signal, it drives the stepper motor according to the The set direction rotates at a fixed angle, called "step angle", and its rotation runs step by step at a fixed angle. The angular displacement can be controlled by controlling the number of pulses to achieve accurate positioning; at the same time, the speed and acceleration of the motor rotation can be controlled by controlling the pulse frequency to achieve speed regulation.