FTM进阶特性介绍 —【组合与互补模式】
上上周与大伙分享了FTM的双边沿捕获特性,大伙是不是真真切切的感受到FTM在PWM周期与占空比测量方面很给力呢,这次咱们再接再励探讨一下FTM在PWM输出方面有什么给力的地方?
FTM进阶特性介绍【组合与互补模式】.pdf
(255.78 KB, 下载次数: 22)
2014-6-9 11:16 上传
点击文件名下载附件
FTM组合模式例程代码如下,至于互补模式,大家可以根据参考手册介绍,在组合模式例程代码的基础上修改:
FTM进阶特性介绍 —【组合与互补模式】.rar
(778 Bytes, 下载次数: 10)
2014-6-9 11:17 上传
点击文件名下载附件
PS:本帖可从飞思卡尔版块置顶帖:飞思卡尔Kinetis资料大本营的飞思卡尔论坛支持小组【经验分享】帖汇总链接进入。
我在做无刷直流电机控制 按照你说的初始化 FTM0_combine_PWM_init();
然后 io中断获取了霍尔信号的换相字,然后进入换相程序 如下
switch (value)
{
case 5: /* -->BA */
FTM0_OUTMASK = 0x30; /* mask pwm4, pwm5 */
FTM0_SWOCTRL = 0x0203; /* pwm0 output 0, pwm1 output 1 */
Q2_TOP_B_PWM (0); /* pwm2 and pwm3 complement output */
Q5_BOTTOM_B_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 1: /* -->CA */
FTM0_OUTMASK = 0x0C; /* mask pwm2, pwm3 */
FTM0_SWOCTRL = 0x0203; /* pwm0 output 0, pwm1 output 1 */
Q3_TOP_C_PWM (0); /* pwm4 and pwm5 complement output */
Q6_BOTTOM_C_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 3: /* -->CB */
FTM0_OUTMASK = 0x03; /* mask pwm0, pwm1 */
FTM0_SWOCTRL = 0x080C; /* pwm2 output 0, pwm3 output 1 */
Q3_TOP_C_PWM (0); /* pwm4 and pwm5 complement output */
Q6_BOTTOM_C_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 2: /* -->AB */
FTM0_OUTMASK = 0x30; /* mask pwm4, pwm5 */
FTM0_SWOCTRL = 0x080C; /* pwm2 output 0, pwm3 output 1 */
Q1_TOP_A_PWM (0); /* pwm0 and pwm1 complement output */
Q4_BOTTOM_A_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 6: /* -->AC */
FTM0_OUTMASK = 0x0C; /* mask pwm2, pwm3 */
FTM0_SWOCTRL = 0x2030; /* pwm4 output 0, pwm5 output 1 */
Q1_TOP_A_PWM (0); /* pwm0 and pwm1 complement output */
Q4_BOTTOM_A_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 4: /* -->BC */
FTM0_OUTMASK = 0x03; /* mask pwm0, pwm1 */
FTM0_SWOCTRL = 0x2030; /* pwm4 output 0, pwm5 output 1 */
Q2_TOP_B_PWM (0); /* pwm0 and pwm1 complement output */
Q5_BOTTOM_B_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
default:
break;
}
// SIM_SOPT |= SIM_SOPT_DELAY(pwm_value>>2);
FTM0_PWMLOAD = 0x23F;
}
这是之前定义的
#define Q1_TOP_A PTC1
#define Q4_BOTTOM_A PTA4
#define Q2_TOP_B PTA5
#define Q5_BOTTOM_B PTC4
#define Q3_TOP_C PTD4
#define Q6_BOTTOM_C PTD5
#define Q1_TOP_A_PWM(pwm_value) FTM0_C0V = pwm_value
#define Q4_BOTTOM_A_PWM(pwm_value) FTM0_C1V = pwm_value
#define Q2_TOP_B_PWM(pwm_value) FTM0_C2V = pwm_value
#define Q5_BOTTOM_B_PWM(pwm_value) FTM0_C3V = pwm_value
#define Q3_TOP_C_PWM(pwm_value) FTM0_C4V = pwm_value
#define Q6_BOTTOM_C_PWM(pwm_value) FTM0_C5V = pwm_value
但是我并没有输出PWM呢 为什么呢 还有你用什么方法能看见pwm 我用示波器看的 编译用的iar 不知道能不能直观看见互补的pwm呢 求方法
一周热门 更多>