AnsweredAssumed Answered

KL03 TPM: CMOD gets changed to zero each time TPM_DRV_PwmStart() runs

Question asked by aes_mike on Jan 3, 2017
Latest reply on Jan 6, 2017 by aes_mike

It seems that each time the TPM_DRV_PwmStart() is run that the TPM0.SC.CMOD gets set to zero.  As a result the PWM output never changes at pin PTA6.  Attached is a screen shot.   If I set a breakpoint just after the TPM_DRV_PwmStart() and then change CMOD back to 0x1, then it works fine.    It is not clear to me why CMOD reverts to zero after TPM_DRV_PwmStart()?  Any suggestions?    I just want to be able to adjust the PWM output at any time.  I am not real familiar with the TPM, so some of this might be just misunderstanding how it works.

 

I have setup the TPM0 as a PWM output.

 

tpm_general_config_t  main_tpm_config;

tpm_pwm_param_t main_tpm_timer_channel_config = {
  .mode = kTpmEdgeAlignedPWM,
  .edgeMode = kTpmHighTrue,
  .uFrequencyHZ = 100000U,
  .uDutyCyclePercent = 50U,
};

 

Initialization portion:

  CLOCK_SYS_SetTpmSrc( TPM0_IDX, kClockTpmSrcIrc48M );
  TPM_DRV_Init( TPM0_IDX, &main_tpm_config );
  TPM_DRV_SetClock( TPM0_IDX, kTpmClockSourceModuleClk, kTpmDividedBy2 );
  main_tpm_timer_channel_config.uDutyCyclePercent = 50;
  TPM_DRV_PwmStart( TPM0_IDX, &main_tpm_timer_channel_config, 0U );

 

 

Software:  KDS 3.0.0, KSDK 1.3.0.

Attachments

Outcomes