FlexPWM setting for single PWM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FlexPWM setting for single PWM

969 次查看
waqasbutt121
Contributor I

I am using the flexPWM module of MKV561M0VLL24. I am configuring my controller with the following setting but it is not working

Note: The code is for generating a single PWM on PWM0_A2. 

PWM0->OUTEN = PWM_OUTEN_PWMA_EN((1 << 2));
PWM0->SM[2].CTRL = PWM_CTRL_LDFQ(0) | 
                                                PWM_CTRL_HALF(0) | 
                                                PWM_CTRL_FULL(1) | 
                                                PWM_CTRL_PRSC(5) | 
                                                PWM_CTRL_LDMOD(1); 
PWM0->SM[2].CTRL2 = PWM_CTRL2_INDEP_MASK |
                                       PWM_CTRL2_PWM23_INIT(0) |
                                       PWM_CTRL2_INIT_SEL(0) |
                                       PWM_CTRL2_FRCEN(0) |
                                       PWM_CTRL2_FORCE(0) |
                                       PWM_CTRL2_FORCE_SEL(0) |
                                       PWM_CTRL2_CLK_SEL(0);
PWM0->SM[2].INIT = 0;
PWM0->SM[2].VAL1 = 1999;
PWM0->SM[2].VAL0 = 999;
PWM0->SM[2].VAL2 = 0;
PWM0->SM[2].VAL3 = 599;

PWM0->MCTRL = PWM_MCTRL_LDOK((1 << 2));

PWM0->MCTRL |= PWM_MCTRL_RUN((1 << 2));

The CNT register of this channel appears to be going beyond the VAL1 limit (which shouldn't happen if values are correctly loaded) and no PWM is generated. Kindly help

标签 (1)
标记 (3)
0 项奖励
回复
1 回复

762 次查看
waqasbutt121
Contributor I

Problem Solved:

Fault Status was not clear. Clearing the fault status resolved the problem

PWM0->FSTS = PWM_FSTS_FFLAG(0xF);

Moreover there is a strange behaviour, If i write the LDOK field in MCTRL without reading the MCCTRL register, it doesn't update

0 项奖励
回复