PWM调速控制直流电机
网上找的历程,实现可以,但是无法随我自己的意愿改变速度,还是有问题。
代码如下:
#include “delay.h”
#include “sys.h”
#include “timer.h”
void GPIO_Config(void) //配置 PA2, PA3
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOA clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
RCC_APB2Periph_GPIOC,ENABLE); //
/*GPIOA Configuration: TIM3 channel 1 and 2 as alternate function
push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //
复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; //LED0–>PC.13
端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO 口速度为 50MHz
GPIO_Init(G