使用ptmr产生1S定时器,在定时器内让PTC2和PTC3交叉输出PWM(20KHZ,占空比20%)和高电平,程序出现卡死
-
Diga 你好!
按照你所述,我这里做了调整,现在遇到一个新的问题:
void Etmr_Drv_Init(void)
{
eTMR_DRV_Init(eTMR0_INST,&ETMR_CM_Config0,&ETMR_CM_Config0_State);
eTMR_DRV_InitPwm(eTMR0_INST,&ETMR_PWM_Config0);
/* PWM is generated when eTMR enable, the duty cycle is configured in the initial function */
eTMR_DRV_Enable(eTMR0_INST);
OSIF_TimeDelay(10);/* The following code shows how to switch the different duty cycle */ /* channel 2 duty cycle is 20% */ eTMR_DRV_UpdatePwmChannel(eTMR0_INST, 2, 0x8000U, 0); /* channel 3 duty cycle is 20% */ eTMR_DRV_UpdatePwmChannel(eTMR0_INST, 3, 0x8000U, 0); eTMR_DRV_SetLdok(0); OSIF_TimeDelay(10);
// PRINTF("CH2 output 20KHZ duty 20, CH3 output 20KHZ duty 20\n");
}
按照当前配置,正常应该是输出高电平,但是实测全部是低电平,将两路的0x8000U更改为0x0000U,输出的也是低电平,请问怎么回事啊?谢谢~
-
Diga 参考了例程,里面有这样的说明:
/* The following code shows how to switch the different duty cycle /
/ channel 2 duty cycle is 50% /
eTMR_DRV_UpdatePwmChannel(0, 2, 0x4000U, 0);
/ channel 3 duty cycle is 50% */
eTMR_DRV_UpdatePwmChannel(0, 3, 0x4000U, 0);
eTMR_DRV_SetLdok(0);
OSIF_TimeDelay(10);**/* channel 2 100% duty cycle, here is the workaround for 100% duty cycle */ eTMR0->CH[2].VAL0 = 0; eTMR0->CH[2].VAL1 = eTMR0->MOD + 1; eTMR_DRV_SetLdok(0); OSIF_TimeDelay(10);**
按照这样的配置,通道2输出的是100%占空比,也就是高电平了。
通道3是50%占空比。
帮助没办法联网的电脑使用YCT
帮助改进和优化YT CONFIG TOOL,有机会抽取YTM32B1ME0 EVB哦...