飞思卡尔控制电机的pwm波频率大概是多少
1个回答
展开全部
void PWM_Init(void) { //初始化
PWMPRCLK_PCKA = 0x2; /*16383000Hz/2=8192000Hz */
PWMPRCLK_PCKB = 0x2; /*8192000Hz/4 =2048000Hz */
PWMCTL_CON01 = 0X1; /* 0 & 1 成 16位精度PWM工作 */
PWMPOL_PPOL1 = 0x1; /* 极性为先高后低 与占空比相同 */
PWMCAE = 0x00; /* operate in left aligned output mode. */
}
void setPWM01(word per,byte start) {
per = (word)(2048000/per);
PWMPER01 = (word)per; /* 设置脉冲周期 */
PWMDTY01 = (word)(per/2); /* 设置脉冲占空比为50% */
if(start==1)PWME_PWME1 = 1; /* 脉冲发送开始 */
else PWME_PWME1 = 0; /* 脉冲停止发送 */
}
发脉冲时调用 setPWM01(频率,1)
PWMPRCLK_PCKA = 0x2; /*16383000Hz/2=8192000Hz */
PWMPRCLK_PCKB = 0x2; /*8192000Hz/4 =2048000Hz */
PWMCTL_CON01 = 0X1; /* 0 & 1 成 16位精度PWM工作 */
PWMPOL_PPOL1 = 0x1; /* 极性为先高后低 与占空比相同 */
PWMCAE = 0x00; /* operate in left aligned output mode. */
}
void setPWM01(word per,byte start) {
per = (word)(2048000/per);
PWMPER01 = (word)per; /* 设置脉冲周期 */
PWMDTY01 = (word)(per/2); /* 设置脉冲占空比为50% */
if(start==1)PWME_PWME1 = 1; /* 脉冲发送开始 */
else PWME_PWME1 = 0; /* 脉冲停止发送 */
}
发脉冲时调用 setPWM01(频率,1)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询