智能车制作
标题:
coldfire求帮忙看下我的PWM初始化
[打印本页]
作者:
9__2__9
时间:
2014-5-9 19:50
标题:
coldfire求帮忙看下我的PWM初始化
我的pwm初始话对应输出50hz的pwm波,不是固定的,是在不停的跳变,
void PWM_init(void)
{
MCF_GPIO_PTCPAR=MCF_GPIO_PTCPAR_DTIN0_PWM0
|MCF_GPIO_PTCPAR_DTIN1_PWM2
|MCF_GPIO_PTCPAR_DTIN2_PWM4
|MCF_GPIO_PTCPAR_DTIN3_PWM6;
MCF_GPIO_PTAPAR=MCF_GPIO_PTAPAR_ICOC0_PWM1
|MCF_GPIO_PTAPAR_ICOC1_PWM3
|MCF_GPIO_PTAPAR_ICOC2_PWM5
|MCF_GPIO_PTAPAR_ICOC3_PWM7;
MCF_PWM_PWMPOL=0xff;
MCF_PWM_PWMCLK=0xff;
MCF_PWM_PWMPRCLK=MCF_PWM_PWMPRCLK_PCKA(3)
|MCF_PWM_PWMPRCLK_PCKB(3); //分频系数4总线分频为10Mhz
MCF_PWM_PWMCAE=0;//左对齐
MCF_PWM_PWMCTL|=MCF_PWM_PWMCTL_CON01; //级联01
MCF_PWM_PWMSCLA=5;
MCF_PWM_PWMSCLB=5; //SA,SB为1Mhz
//MCF_PWM_PWMPER(0)=20000/256;
//MCF_PWM_PWMPER(1)=20000%256;
MCF_PWM_PWMPER2=100;
MCF_PWM_PWMPER3=100;
MCF_PWM_PWMPER4=100;
MCF_PWM_PWMPER5=100;
MCF_PWM_PWMPER6=100;
MCF_PWM_PWMPER7=100; //10Khz
MY_PWMPER01=20000; //50hz
MY_PWMDTY01=10000;
//MCF_PWM_PWMDTY(0)=1470/256;
//MCF_PWM_PWMDTY(1)=1470%256;
MCF_PWM_PWMDTY2=0;
MCF_PWM_PWMDTY3=0;
MCF_PWM_PWMDTY4=0;
MCF_PWM_PWMDTY5=0;
MCF_PWM_PWMDTY6=0;
MCF_PWM_PWMDTY7=0;
MCF_PWM_PWME=0xf3;
}
头文件中加
#define MY_PWMPER01 (*(vuint16 *)(0x401B0014))
#define MY_PWMPER23 (*(vuint16 *)(0x401B0016))
#define MY_PWMPER45 (*(vuint16 *)(0x401B0018))
#define MY_PWMPER67 (*(vuint16 *)(0x401B001A))
#define MY_PWMDTY01 (*(vuint16 *)(0x401B001C))
#define MY_PWMDTY23 (*(vuint16 *)(0x401B001E))
#define MY_PWMDTY45 (*(vuint16 *)(0x401B0020))
#define MY_PWMDTY67 (*(vuint16 *)(0x401B0022))
输出到舵机会使舵机不停的抖,示波器上看到的是一个抖动的方波,求大神帮忙看下
作者:
chengxinshuaish
时间:
2014-5-13 09:34
你用的是哪一款芯片呢?
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2