PWM with changing dutycycle S32k144

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM with changing dutycycle S32k144

804 Views
eyas077
Contributor I

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.

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

644 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

This has been already discussed here on the community.

Please take a look at this thread: 

https://community.nxp.com/message/1012624 

Thank you,

BR, Daniel 

0 Kudos