First should choose two way PWM timer channel, connected to the L298N in feet, microcontroller pins reuse push-pull output, microcontroller built-in timer channels have default interface, and the mapping interface two kinds, it is not need to map with the default interface, and some heavy mapping and completely mapping is interface to reuse the function of single or not,
Complete timer channel selection, start the clock and GPIO can make, GPIO port multiplexing, initialize the GPIO, initialize the clock, set the comparison, the channel can make, preloaded can make, can make the timer modules, such as operation, after my repeated debug and mistakes, it is concluded that the operating encapsulation structure and function, and is the best way, don't be stupid to write one, don't be stupid to copying routines of all blocks, first write down the steps to the title, understand yourself doing is one of the most important,
Finally is the main function of writing, the drive motor can use advanced timer complementary PWM output, you can also use two way of PWM function and L298N IN pin, is to use an if else statements, the pin IN the PWM duty cycle of the state of the control, to achieve the pin switch
CodePudding user response:
Several orders of magnitude more difficult than 51 stm32?CodePudding user response:
I am in C8T6 with 8 road PWM output, control of the four motor eight electrodes, in order to achieve speed and positive &negative,