FlexPWM setting for single PWM

cancel
Showing results for 
Search instead for 
Did you mean: 

FlexPWM setting for single PWM

347 Views
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

Labels (1)
Tags (3)
0 Kudos
1 Reply

140 Views
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 Kudos