AnsweredAssumed Answered

MKW31Z TPM1 PWM not working

Question asked by Frank Strazzabosco on Apr 26, 2017
Latest reply on Sep 28, 2017 by Jeremy Swanson

Here's the code snippet to show that I can get TPM0 channel to output a PWM signal but I can not get the TPM1 to do the same. Inspecting the TPM registers in the debugger shows that TPM1 does not get initialized correctly. What am I doing wrong??


#define PWM5_TIMER_INSTANCE             1
#define PWM5_TIMER_CHANNEL              0


#define PWM4_TIMER_INSTANCE             0
#define PWM4_TIMER_CHANNEL              3


#define PWM_INIT_VAL                    0x00
#define PWM_FREQ                        25000u


#define M5_PWM_DUTY( x )               PWM_SetChnCountVal( PWM5_TIMER_INSTANCE,  PWM5_TIMER_CHANNEL, )
#define M4_PWM_DUTY( x )               PWM_SetChnCountVal( PWM4_TIMER_INSTANCE,  PWM4_TIMER_CHANNEL, )


 tmr_adapter_pwm_param_t pwm_config;



  GpioSetPinMux( gpioPort_B_c, 2u,  pinMux_Alt5_c );  // PWM5_TPM1_CH0
  GpioSetPinMux( gpioPort_C_c, 16u, pinMux_Alt5_c );  // PWM4_TPM0_CH3


  /*Configure PWM Module */
  pwm_config.initValue = PWM_INIT_VAL;
  pwm_config.frequency = PWM_FREQ;

  PWM_StartEdgeAlignedLowTrue( PWM5_TIMER_INSTANCE, &pwm_config, PWM5_TIMER_CHANNEL );
  PWM_StartEdgeAlignedLowTrue( PWM4_TIMER_INSTANCE, &pwm_config, PWM4_TIMER_CHANNEL );


  M5_PWM_DUTY( 0x80 );
  M4_PWM_DUTY( 0x80 );