21ic问答首页 - NUC131 PWM0 CH2 CH3双通道输出,为啥只有CH2输出呢?
NUC131 PWM0 CH2 CH3双通道输出,为啥只有CH2输出呢?
sky_429590692021-11-17
本帖最后由 sky_42959069 于 2021-11-17 11:12 编辑
SYS->GPA_MFP&=~(SYS_GPA_MFP_PA14_Msk|SYS_GPA_MFP_PA15_Msk);
SYS->GPA_MFP|=(SYS_GPA_MFP_PA14_PWM0_CH2|SYS_GPA_MFP_PA15_PWM0_CH3);//PA14 PA15 用于PW0-CH2 CH3 //引脚设置
void PWM_Init(void)
{
PWM_ConfigOutputChannel(PWM0,2,20000,0);
PWM_ConfigOutputChannel(PWM0,3,20000,0);
PWM_EnableOutput(PWM0,PWM_CH_2_MASK);
PWM_EnableOutput(PWM0,PWM_CH_3_MASK);
PWM_EnablePeriodInt(PWM0,2,0);
PWM_EnablePeriodInt(PWM0,3,0);
NVIC_EnableIRQ(PWM0_IRQn);
}
//初始化
请大神们帮忙看下,初次玩新唐请多关照!
SYS->GPA_MFP&=~(SYS_GPA_MFP_PA14_Msk|SYS_GPA_MFP_PA15_Msk);
SYS->GPA_MFP|=(SYS_GPA_MFP_PA14_PWM0_CH2|SYS_GPA_MFP_PA15_PWM0_CH3);//PA14 PA15 用于PW0-CH2 CH3 //引脚设置
void PWM_Init(void)
{
PWM_ConfigOutputChannel(PWM0,2,20000,0);
PWM_ConfigOutputChannel(PWM0,3,20000,0);
PWM_EnableOutput(PWM0,PWM_CH_2_MASK);
PWM_EnableOutput(PWM0,PWM_CH_3_MASK);
PWM_EnablePeriodInt(PWM0,2,0);
PWM_EnablePeriodInt(PWM0,3,0);
NVIC_EnableIRQ(PWM0_IRQn);
}
//初始化
请大神们帮忙看下,初次玩新唐请多关照!
赞0
感谢支持,已处理好。原本以为是初始化有问题,后来发现是这两个相邻通道刚好共用中断标志,而我用中断标志判断执行各自输出条件,每次都是进入CH2的逻辑。你说的对,谢谢。
评论
2021-11-22
赞0
评论
2021-11-18
您需要登录后才可以回复 登录 | 注册