AnsweredAssumed Answered

PWM with changing dutycycle S32k144

Question asked by Eyas Awadelkarim Hamid Ali on Dec 15, 2019
Latest reply on Dec 17, 2019 by Daniel Martynek

Hi, 

I'm a beginner when dealing with the s32k144 so please be patient with me.

 

I would like to use timer FTM0 channel 0 as a PWM source and update its CnV (compare register ) according to some events.  the pwm works when initialized however it is not updated when I run the following command.

 

FTM0-> CONTROLS [0] = .CnV FTM_CnV_VAL (new_pwm_value); 

 

  • Here is my initialization of the timer.

 

PCC-> PCCn [PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK; 
PCC-> PCCn [PCC_FTM0_INDEX] = PCC_PCCn_PCS (6) | PCC_PCCn_CGC_MASK;
PORTD-> PCR [15] = PORT_PCR_MUX (2);
FTM0-> MODE = FTM_MODE_FTMEN_MASK;

FTM0-> MOD = FTM_MOD_MOD (8000-1);
FTM0-> CNTIN = FTM_CNTIN_INIT (0); 
FTM0-> CONTROLS [0] .CnSC = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK;

FTM0-> CONTROLS [0] = .CnV FTM_CnV_VAL (7000); 

FTM0-> CNT = 0;
FTM0-> SC = FTM_SC_CLKS (1) | FTM_SC_PS ( 0 ) | FTM_SC_PWMEN0_MASK ;

 

 

Please advise.

Outcomes