MKW31Z TPM1 PWM not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MKW31Z TPM1 PWM not working

1,259 次查看
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 );

标签 (1)
0 项奖励
回复
2 回复数

1,080 次查看
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 项奖励
回复

1,080 次查看
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 项奖励
回复