MKW31Z TPM1 PWM not working

cancel
Showing results for 
Search instead for 
Did you mean: 

MKW31Z TPM1 PWM not working

262 Views
microfirm
Contributor I

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, :smileyx: )
#define M4_PWM_DUTY( x )               PWM_SetChnCountVal( PWM4_TIMER_INSTANCE,  PWM4_TIMER_CHANNEL, :smileyx: )

 tmr_adapter_pwm_param_t pwm_config;
 

  PWM_Init( PWM5_TIMER_INSTANCE );
  PWM_Init( PWM4_TIMER_INSTANCE );

  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 );

Labels (1)
0 Kudos
2 Replies

83 Views
bigtwisty
Contributor I

How did you solve this?  I believe I may be having the same problem with a project based on the demo BLE software.  I need all 3 TPMs for this project.

0 Kudos

83 Views
microfirm
Contributor I

I found the problem to be the demo code that I based the project on was using TPM1 for the BlueTooth stack timers

0 Kudos