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  = .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  = 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  .CnSC = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK;
FTM0-> CONTROLS  = .CnV FTM_CnV_VAL (7000);
FTM0-> CNT = 0;
FTM0-> SC = FTM_SC_CLKS (1) | FTM_SC_PS ( 0 ) | FTM_SC_PWMEN0_MASK ;