AnsweredAssumed Answered

Change of PWM periode on runtime

Question asked by Yixin Wu on Mar 4, 2019
Latest reply on Mar 5, 2019 by Yixin Wu

Dear community,

 

I would like to ask, if it is possible to change the periode of PWM (frequency) on runtime?

I am using B0, B3, X0 and X3 outputs. If I try to change the FlexPWM_0.SUB[0].VAL5.R for example, the duty cycle of B0 output will change without problem. If I try to change FlexPWM_0.SUB[0].VAL4.R, nothing will be effected. What am I doing wrong?

 

Thank you for any help in advance.

 

Following is my configuration:

 

  FlexPWM_0.OUTEN.R           = 0x0099; // b3 b0 x3 x0
  //sub 0
  FlexPWM_0.SUB[0].CTRL1.R    = 0x0404; // full cycle reload, LDMOD
  FlexPWM_0.SUB[0].CTRL2.R    = 0x2000; // independent 
  FlexPWM_0.SUB[0].DTCNT0.R   = 0x0000; // deadtime values, not aplicable on INDEP mode
  FlexPWM_0.SUB[0].DTCNT1.R   = 0x0000;
  FlexPWM_0.SUB[0].INIT.R    = 0x0;  // PWM init value  
  FlexPWM_0.SUB[0].VAL0.R   = PWM_MODULO/2;   // PWMX rising edge, half cycle reload point   x0
  FlexPWM_0.SUB[0].VAL1.R   = PWM_MODULO; // PWM modulo, PWMX falling edge
  FlexPWM_0.SUB[0].VAL2.R   = 0;     // PWM A0 rising edge
  FlexPWM_0.SUB[0].VAL3.R   = 0;  // PWM A0 falling edge
  FlexPWM_0.SUB[0].VAL4.R   = PWM_MODULO/2;  // PWM B0 rising edge      b0
  FlexPWM_0.SUB[0].VAL5.R   = PWM_MODULO; // PWM B0 falling edge
  FlexPWM_0.SUB[0].DISMAP.R = 0x0000;  // disable fault pin condition

  //sub 3
  FlexPWM_0.SUB[3].CTRL1.R    = 0x0404; // full cycle reload, LDMOD
  FlexPWM_0.SUB[3].CTRL2.R    = 0x2000; // independent 
  FlexPWM_0.SUB[3].DTCNT0.R   = 0x0000; // deadtime values, not aplicable on INDEP mode
  FlexPWM_0.SUB[3].DTCNT1.R   = 0x0000;
  FlexPWM_0.SUB[3].INIT.R    = 0x0;  // PWM init value  
  FlexPWM_0.SUB[3].VAL0.R   = PWM_MODULO/2;   // PWMX rising edge, half cycle reload point    x3
  FlexPWM_0.SUB[3].VAL1.R   = PWM_MODULO; // PWM modulo, PWMX falling edge
  FlexPWM_0.SUB[3].VAL2.R   = 0;     // PWM A0 rising edge
  FlexPWM_0.SUB[3].VAL3.R   = 0;  // PWM A0 falling edge
  FlexPWM_0.SUB[3].VAL4.R   = PWM_MODULO/2;  // PWM B0 rising edge
  FlexPWM_0.SUB[3].VAL5.R   = PWM_MODULO; // PWM B0 falling edge                             b3
  FlexPWM_0.SUB[3].DISMAP.R = 0x0000;  // disable fault pin condition
  
  FlexPWM_0.MCTRL.R = 0x0900;

Outcomes