AnsweredAssumed Answered

Adapting tpm_simple_pwm.c to run in VLPR mode

Question asked by Robert Poor on Jan 3, 2017
Latest reply on Jan 6, 2017 by Robert Poor

I'm trying to adapt the tpm_simple_pwm.c driver example for a FRDM-KL27Z board to run in VLPR mode:

file: SDK_2.1_FRDM-KL27Z/boards/frdmkl27z/driver_examples/tpm/simple_pwm/tpm_simple_pwm.c

 

In the original code, I observe the output PTB18 generating time-varying PWM signals as expected.  But after my changes to the code, PTB18 appears to be floating at ~2V and there's no PWM signal. 

 

In tpm_simple_pwm.c, I changed this:

/* Get source clock for TPM driver */

#define TPM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_McgIrc48MClk)

...

/* Board pin, clock, debug console init */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
/* Select the clock source for the TPM counter as MCGPLLCLK */
CLOCK_SetTpmClock(1U);

to this (changes in boldface):

/* Get source clock for TPM driver */

#define TPM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_CoreSysClk)

...

/* Board pin, clock, debug console init */
BOARD_InitPins();
BOARD_BootClockVLPR();
APP_InitDebugConsole_InVLPR();
/* Select the clock source for the TPM counter as MCGPLLCLK */
CLOCK_SetTpmClock(1U);

 

Some points:

  • APP_InitDebugConsole_InVLPR() is a routine I've developed and tested elsewhere.  It appears to work just fine.
  • When running in normal mode (not VLPR), I can set TPM_SOURCE_CLOCK to be GetFreq(kCLOCK_CoreSysClk) and it works.
  • I don't expect to see the same PWM frequency in the modified code (because the clock is running at 2MHz rather than at 48MHz).
  • I've tried calling CLOCK_SetTpmClock(x) with values 1, 2 and 3.  No change.

 

Since I observe Port B18 floating at 2v rather than set to 0v or 3.3v, I am guessing that there may be some other register associated with Port B that must be enabled for low power mode.  But that's just a guess.

 

Any hints would be appreciated!

Outcomes