TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //TIM输出级性为高,这是用来做什么的?
我在PWM.C文件中将这句代码改为TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "pwm.h"
int main(void)
{
delay_init();
LED_Init();
TIM1_PWM_Init(9999,143);//周期为20ms
while(1)
{
TIM_SetCompare1(TIM1,250);
delay_ms(10000);
TIM_SetCompare1(TIM1,500);//45度
delay_ms(10000);
TIM_SetCompare1(TIM1,750);//90度
delay_ms(10000);
TIM_SetCompare1(TIM1,1000);//135度
delay_ms(10000);
TIM_SetCompare1(TIM1,1250);//180度
delay_ms(10000);
连上舵机10v的直流电压,连上舵机尝试了一下,舵机不动;用示波器测量书出的波形,在低电平期间有杂波,但大体能保证周期为20ms,以0.5ms(45度)为高电平的pwm波,请问问题出现在哪儿?
|