The MCUXpresso SDK provides a driver for the Timer PWM Module (TPM) of MCUXpresso SDK devices.
The TPM driver supports the generation of PWM signals, input capture, and output compare modes. On some SoCs, the driver supports the generation of combined PWM signals, dual-edge capture, and quadrature decoder modes. The driver also supports configuring each of the TPM fault inputs. The fault input is available only on some SoCs.
Introduction of TPM
Initialization and deinitialization
The function TPM_Init() initializes the TPM with a specified configurations. The function TPM_GetDefaultConfig() gets the default configurations. On some SoCs, the initialization function issues a software reset to reset the TPM internal logic. The initialization function configures the TPM's behavior when it receives a trigger input and its operation in doze and debug modes.
The function TPM_Deinit() disables the TPM counter and turns off the module clock.
PWM Operations
The function TPM_SetupPwm() sets up TPM channels for the PWM output. The function can set up the PWM signal properties for multiple channels. Each channel has its own tpm_chnl_pwm_signal_param_t structure that is used to specify the output signals duty cycle and level-mode. However, the same PWM period and PWM mode is applied to all channels requesting a PWM output. The signal duty cycle is provided as a percentage of the PWM period. Its value should be between 0 and 100 where 0=inactive signal (0% duty cycle) and 100=always active signal (100% duty cycle). When generating a combined PWM signal, the channel number passed refers to a channel pair number, for example 0 refers to channel 0 and 1, 1 refers to channels 2 and 3.
The function TPM_UpdatePwmDutycycle() updates the PWM signal duty cycle of a particular TPM channel.
The function TPM_UpdateChnlEdgeLevelSelect() updates the level select bits of a particular TPM channel. This can be used to disable the PWM output when making changes to the PWM signal.
Input capture operations
The function TPM_SetupInputCapture() sets up a TPM channel for input capture. The user can specify the capture edge.
The function TPM_SetupDualEdgeCapture() can be used to measure the pulse width of a signal. This is available only for certain SoCs. A channel pair is used during the capture with the input signal coming through a channel that can be configured. The user can specify the capture edge for each channel and any filter value to be used when processing the input signal.
Output compare operations
The function TPM_SetupOutputCompare() sets up a TPM channel for output comparison. The user can specify the channel output on a successful comparison and a comparison value.
Quad decode
The function TPM_SetupQuadDecode() sets up TPM channels 0 and 1 for quad decode, which is available only for certain SoCs. The user can specify the quad decode mode, polarity, and filter properties for each input signal.
Fault operation
The function TPM_SetupFault() sets up the properties for each fault, which is available only for certain SoCs. The user can specify the fault polarity and whether to use a filter on a fault input. The overall fault filter value and fault control mode are set up during initialization.
Status
Provides functions to get and clear the TPM status.
Interrupt
Provides functions to enable/disable TPM interrupts and get current enabled interrupts.
Typical use case
PWM output
Output the PWM signal on 2 TPM channels with different duty cycles. Periodically update the PWM signal duty cycle. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/tpm
|
#define | TPM_MAX_COUNTER_VALUE(x) ((1U != (uint8_t)FSL_FEATURE_TPM_HAS_32BIT_COUNTERn(x)) ? 0xFFFFU : 0xFFFFFFFFU) |
| Help macro to get the max counter value.
|
|
|
enum | tpm_chnl_t {
kTPM_Chnl_0 = 0U,
kTPM_Chnl_1,
kTPM_Chnl_2,
kTPM_Chnl_3,
kTPM_Chnl_4,
kTPM_Chnl_5,
kTPM_Chnl_6,
kTPM_Chnl_7
} |
| List of TPM channels. More...
|
|
enum | tpm_pwm_mode_t {
kTPM_EdgeAlignedPwm = 0U,
kTPM_CenterAlignedPwm,
kTPM_CombinedPwm
} |
| TPM PWM operation modes. More...
|
|
enum | tpm_pwm_level_select_t {
kTPM_HighTrue = 0U,
kTPM_LowTrue
} |
| TPM PWM output pulse mode: high-true, low-true or no output. More...
|
|
enum | tpm_pwm_pause_level_select_t {
kTPM_ClearOnPause = 0U,
kTPM_SetOnPause
} |
| TPM PWM output when first enabled or paused: set or clear. More...
|
|
enum | tpm_chnl_control_bit_mask_t {
kTPM_ChnlELSnAMask = TPM_CnSC_ELSA_MASK,
kTPM_ChnlELSnBMask = TPM_CnSC_ELSB_MASK,
kTPM_ChnlMSAMask = TPM_CnSC_MSA_MASK,
kTPM_ChnlMSBMask = TPM_CnSC_MSB_MASK
} |
| List of TPM channel modes and level control bit mask. More...
|
|
enum | tpm_trigger_select_t |
| Trigger sources available. More...
|
|
enum | tpm_trigger_source_t {
kTPM_TriggerSource_External = 0U,
kTPM_TriggerSource_Internal
} |
| Trigger source options available. More...
|
|
enum | tpm_ext_trigger_polarity_t {
kTPM_ExtTrigger_Active_High = 0U,
kTPM_ExtTrigger_Active_Low
} |
| External trigger source polarity. More...
|
|
enum | tpm_output_compare_mode_t {
kTPM_NoOutputSignal = (1U << TPM_CnSC_MSA_SHIFT),
kTPM_ToggleOnMatch = ((1U << TPM_CnSC_MSA_SHIFT) | (1U << TPM_CnSC_ELSA_SHIFT)),
kTPM_ClearOnMatch = ((1U << TPM_CnSC_MSA_SHIFT) | (2U << TPM_CnSC_ELSA_SHIFT)),
kTPM_SetOnMatch = ((1U << TPM_CnSC_MSA_SHIFT) | (3U << TPM_CnSC_ELSA_SHIFT)),
kTPM_HighPulseOutput = ((3U << TPM_CnSC_MSA_SHIFT) | (1U << TPM_CnSC_ELSA_SHIFT)),
kTPM_LowPulseOutput = ((3U << TPM_CnSC_MSA_SHIFT) | (2U << TPM_CnSC_ELSA_SHIFT))
} |
| TPM output compare modes. More...
|
|
enum | tpm_input_capture_edge_t {
kTPM_RisingEdge = (1U << TPM_CnSC_ELSA_SHIFT),
kTPM_FallingEdge = (2U << TPM_CnSC_ELSA_SHIFT),
kTPM_RiseAndFallEdge = (3U << TPM_CnSC_ELSA_SHIFT)
} |
| TPM input capture edge. More...
|
|
enum | tpm_quad_decode_mode_t {
kTPM_QuadPhaseEncode = 0U,
kTPM_QuadCountAndDir
} |
| TPM quadrature decode modes. More...
|
|
enum | tpm_phase_polarity_t {
kTPM_QuadPhaseNormal = 0U,
kTPM_QuadPhaseInvert
} |
| TPM quadrature phase polarities. More...
|
|
enum | tpm_clock_source_t {
kTPM_SystemClock = 1U,
kTPM_ExternalClock,
kTPM_ExternalInputTriggerClock
} |
| TPM clock source selection. More...
|
|
enum | tpm_clock_prescale_t {
kTPM_Prescale_Divide_1 = 0U,
kTPM_Prescale_Divide_2,
kTPM_Prescale_Divide_4,
kTPM_Prescale_Divide_8,
kTPM_Prescale_Divide_16,
kTPM_Prescale_Divide_32,
kTPM_Prescale_Divide_64,
kTPM_Prescale_Divide_128
} |
| TPM prescale value selection for the clock source. More...
|
|
enum | tpm_interrupt_enable_t {
kTPM_Chnl0InterruptEnable = (1U << 0),
kTPM_Chnl1InterruptEnable = (1U << 1),
kTPM_Chnl2InterruptEnable = (1U << 2),
kTPM_Chnl3InterruptEnable = (1U << 3),
kTPM_Chnl4InterruptEnable = (1U << 4),
kTPM_Chnl5InterruptEnable = (1U << 5),
kTPM_Chnl6InterruptEnable = (1U << 6),
kTPM_Chnl7InterruptEnable = (1U << 7),
kTPM_TimeOverflowInterruptEnable = (1U << 8)
} |
| List of TPM interrupts. More...
|
|
enum | tpm_status_flags_t {
kTPM_Chnl0Flag = (1U << 0),
kTPM_Chnl1Flag = (1U << 1),
kTPM_Chnl2Flag = (1U << 2),
kTPM_Chnl3Flag = (1U << 3),
kTPM_Chnl4Flag = (1U << 4),
kTPM_Chnl5Flag = (1U << 5),
kTPM_Chnl6Flag = (1U << 6),
kTPM_Chnl7Flag = (1U << 7),
kTPM_TimeOverflowFlag = (1U << 8)
} |
| List of TPM flags. More...
|
|
|
static void | TPM_Reset (TPM_Type *base) |
| Performs a software reset on the TPM module. More...
|
|
|
status_t | TPM_SetupPwm (TPM_Type *base, const tpm_chnl_pwm_signal_param_t *chnlParams, uint8_t numOfChnls, tpm_pwm_mode_t mode, uint32_t pwmFreq_Hz, uint32_t srcClock_Hz) |
| Configures the PWM signal parameters. More...
|
|
status_t | TPM_UpdatePwmDutycycle (TPM_Type *base, tpm_chnl_t chnlNumber, tpm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent) |
| Update the duty cycle of an active PWM signal. More...
|
|
void | TPM_UpdateChnlEdgeLevelSelect (TPM_Type *base, tpm_chnl_t chnlNumber, uint8_t level) |
| Update the edge level selection for a channel. More...
|
|
static uint8_t | TPM_GetChannelContorlBits (TPM_Type *base, tpm_chnl_t chnlNumber) |
| Get the channel control bits value (mode, edge and level bit fileds). More...
|
|
static void | TPM_DisableChannel (TPM_Type *base, tpm_chnl_t chnlNumber) |
| Dsiable the channel. More...
|
|
static void | TPM_EnableChannel (TPM_Type *base, tpm_chnl_t chnlNumber, uint8_t control) |
| Enable the channel according to mode and level configs. More...
|
|
void | TPM_SetupInputCapture (TPM_Type *base, tpm_chnl_t chnlNumber, tpm_input_capture_edge_t captureMode) |
| Enables capturing an input signal on the channel using the function parameters. More...
|
|
void | TPM_SetupOutputCompare (TPM_Type *base, tpm_chnl_t chnlNumber, tpm_output_compare_mode_t compareMode, uint32_t compareValue) |
| Configures the TPM to generate timed pulses. More...
|
|
void | TPM_SetupDualEdgeCapture (TPM_Type *base, tpm_chnl_t chnlPairNumber, const tpm_dual_edge_capture_param_t *edgeParam, uint32_t filterValue) |
| Configures the dual edge capture mode of the TPM. More...
|
|
void | TPM_SetupQuadDecode (TPM_Type *base, const tpm_phase_params_t *phaseAParams, const tpm_phase_params_t *phaseBParams, tpm_quad_decode_mode_t quadMode) |
| Configures the parameters and activates the quadrature decode mode. More...
|
|
static void | TPM_SetChannelPolarity (TPM_Type *base, tpm_chnl_t chnlNumber, bool enable) |
| Set the input and output polarity of each of the channels. More...
|
|
static void | TPM_EnableChannelExtTrigger (TPM_Type *base, tpm_chnl_t chnlNumber, bool enable) |
| Enable external trigger input to be used by channel. More...
|
|
struct tpm_chnl_pwm_signal_param_t |
tpm_chnl_t tpm_chnl_pwm_signal_param_t::chnlNumber |
In combined mode (available in some SoC's), this represents the channel pair number
uint8_t tpm_chnl_pwm_signal_param_t::dutyCyclePercent |
100=always active signal (100% duty cycle)
uint8_t tpm_chnl_pwm_signal_param_t::firstEdgeDelayPercent |
Specifies the delay to the first edge in a PWM period. If unsure, leave as 0. Should be specified as percentage of the PWM period, (dutyCyclePercent + firstEdgeDelayPercent) value should be not greate than 100.
bool tpm_chnl_pwm_signal_param_t::enableComplementary |
true: The combined channels output complementary signals; false: The combined channels output same signals;
Define the second channel output level when counter first enabled or paused
uint8_t tpm_chnl_pwm_signal_param_t::deadTimeValue[2] |
Deadtime insertion is disabled when this value is zero, otherwise deadtime insertion for channel n/n+1 is configured as (deadTimeValue * 4) clock cycles. deadTimeValue's available range is 0 ~ 15.
struct tpm_dual_edge_capture_param_t |
- Note
- This mode is available only on some SoC's.
struct tpm_phase_params_t |
This structure holds the configuration settings for the TPM peripheral. To initialize this structure to reasonable defaults, call the TPM_GetDefaultConfig() function and pass a pointer to your config structure instance.
The config struct can be made const so it resides in flash
- Note
- Actual number of available channels is SoC dependent
Enumerator |
---|
kTPM_Chnl_0 |
TPM channel number 0.
|
kTPM_Chnl_1 |
TPM channel number 1.
|
kTPM_Chnl_2 |
TPM channel number 2.
|
kTPM_Chnl_3 |
TPM channel number 3.
|
kTPM_Chnl_4 |
TPM channel number 4.
|
kTPM_Chnl_5 |
TPM channel number 5.
|
kTPM_Chnl_6 |
TPM channel number 6.
|
kTPM_Chnl_7 |
TPM channel number 7.
|
Enumerator |
---|
kTPM_EdgeAlignedPwm |
Edge aligned PWM.
|
kTPM_CenterAlignedPwm |
Center aligned PWM.
|
kTPM_CombinedPwm |
Combined PWM (Edge-aligned, center-aligned, or asymmetrical PWMs can be obtained in combined mode using different software configurations)
|
- Note
- When the TPM has PWM pause level select feature, the PWM output cannot be turned off by selecting the output level. In this case, the channel must be closed to close the PWM output.
Enumerator |
---|
kTPM_HighTrue |
High true pulses.
|
kTPM_LowTrue |
Low true pulses.
|
Enumerator |
---|
kTPM_ClearOnPause |
Clear Output when counter first enabled or paused.
|
kTPM_SetOnPause |
Set Output when counter first enabled or paused.
|
Enumerator |
---|
kTPM_ChnlELSnAMask |
Channel ELSA bit mask.
|
kTPM_ChnlELSnBMask |
Channel ELSB bit mask.
|
kTPM_ChnlMSAMask |
Channel MSA bit mask.
|
kTPM_ChnlMSBMask |
Channel MSB bit mask.
|
This is used for both internal & external trigger sources (external trigger sources available in certain SoC's)
- Note
- The actual trigger sources available is SoC-specific.
- Note
- This selection is available only on some SoC's. For SoC's without this selection, the only trigger source available is internal triger.
Enumerator |
---|
kTPM_TriggerSource_External |
Use external trigger input.
|
kTPM_TriggerSource_Internal |
Use internal trigger (channel pin input capture)
|
- Note
- Selects the polarity of the external trigger source.
Enumerator |
---|
kTPM_ExtTrigger_Active_High |
External trigger input is active high.
|
kTPM_ExtTrigger_Active_Low |
External trigger input is active low.
|
Enumerator |
---|
kTPM_NoOutputSignal |
No channel output when counter reaches CnV.
|
kTPM_ToggleOnMatch |
Toggle output.
|
kTPM_ClearOnMatch |
Clear output.
|
kTPM_SetOnMatch |
Set output.
|
kTPM_HighPulseOutput |
Pulse output high.
|
kTPM_LowPulseOutput |
Pulse output low.
|
Enumerator |
---|
kTPM_RisingEdge |
Capture on rising edge only.
|
kTPM_FallingEdge |
Capture on falling edge only.
|
kTPM_RiseAndFallEdge |
Capture on rising or falling edge.
|
- Note
- This mode is available only on some SoC's.
Enumerator |
---|
kTPM_QuadPhaseEncode |
Phase A and Phase B encoding mode.
|
kTPM_QuadCountAndDir |
Count and direction encoding mode.
|
Enumerator |
---|
kTPM_QuadPhaseNormal |
Phase input signal is not inverted.
|
kTPM_QuadPhaseInvert |
Phase input signal is inverted.
|
Enumerator |
---|
kTPM_SystemClock |
System clock.
|
kTPM_ExternalClock |
External TPM_EXTCLK pin clock.
|
kTPM_ExternalInputTriggerClock |
Selected external input trigger clock.
|
Enumerator |
---|
kTPM_Prescale_Divide_1 |
Divide by 1.
|
kTPM_Prescale_Divide_2 |
Divide by 2.
|
kTPM_Prescale_Divide_4 |
Divide by 4.
|
kTPM_Prescale_Divide_8 |
Divide by 8.
|
kTPM_Prescale_Divide_16 |
Divide by 16.
|
kTPM_Prescale_Divide_32 |
Divide by 32.
|
kTPM_Prescale_Divide_64 |
Divide by 64.
|
kTPM_Prescale_Divide_128 |
Divide by 128.
|
Enumerator |
---|
kTPM_Chnl0InterruptEnable |
Channel 0 interrupt.
|
kTPM_Chnl1InterruptEnable |
Channel 1 interrupt.
|
kTPM_Chnl2InterruptEnable |
Channel 2 interrupt.
|
kTPM_Chnl3InterruptEnable |
Channel 3 interrupt.
|
kTPM_Chnl4InterruptEnable |
Channel 4 interrupt.
|
kTPM_Chnl5InterruptEnable |
Channel 5 interrupt.
|
kTPM_Chnl6InterruptEnable |
Channel 6 interrupt.
|
kTPM_Chnl7InterruptEnable |
Channel 7 interrupt.
|
kTPM_TimeOverflowInterruptEnable |
Time overflow interrupt.
|
Enumerator |
---|
kTPM_Chnl0Flag |
Channel 0 flag.
|
kTPM_Chnl1Flag |
Channel 1 flag.
|
kTPM_Chnl2Flag |
Channel 2 flag.
|
kTPM_Chnl3Flag |
Channel 3 flag.
|
kTPM_Chnl4Flag |
Channel 4 flag.
|
kTPM_Chnl5Flag |
Channel 5 flag.
|
kTPM_Chnl6Flag |
Channel 6 flag.
|
kTPM_Chnl7Flag |
Channel 7 flag.
|
kTPM_TimeOverflowFlag |
Time overflow flag.
|
void TPM_Init |
( |
TPM_Type * |
base, |
|
|
const tpm_config_t * |
config |
|
) |
| |
- Note
- This API should be called at the beginning of the application using the TPM driver.
- Parameters
-
base | TPM peripheral base address |
config | Pointer to user's TPM config structure. |
void TPM_Deinit |
( |
TPM_Type * |
base | ) |
|
- Parameters
-
base | TPM peripheral base address |
The default values are:
* config->useGlobalTimeBase = false;
* config->syncGlobalTimeBase = false;
* config->dozeEnable = false;
* config->dbgMode = false;
* config->enableReloadOnTrigger = false;
* config->enableStopOnOverflow = false;
* config->enableStartOnTrigger = false;
*#if FSL_FEATURE_TPM_HAS_PAUSE_COUNTER_ON_TRIGGER
* config->enablePauseOnTrigger = false;
*#endif
* config->triggerSelect = kTPM_Trigger_Select_0;
*#if FSL_FEATURE_TPM_HAS_EXTERNAL_TRIGGER_SELECTION
*#endif
*#if defined(FSL_FEATURE_TPM_HAS_POL) && FSL_FEATURE_TPM_HAS_POL
* config->chnlPolarity = 0U;
*#endif
*
- Parameters
-
config | Pointer to user's TPM config structure. |
tpm_clock_prescale_t TPM_CalculateCounterClkDiv |
( |
TPM_Type * |
base, |
|
|
uint32_t |
counterPeriod_Hz, |
|
|
uint32_t |
srcClock_Hz |
|
) |
| |
This function calculates the values for SC[PS].
- Parameters
-
base | TPM peripheral base address |
counterPeriod_Hz | The desired frequency in Hz which corresponding to the time when the counter reaches the mod value |
srcClock_Hz | TPM counter clock in Hz |
return Calculated clock prescaler value.
User calls this function to configure the PWM signals period, mode, dutycycle and edge. Use this function to configure all the TPM channels that will be used to output a PWM signal
- Parameters
-
base | TPM peripheral base address |
chnlParams | Array of PWM channel parameters to configure the channel(s) |
numOfChnls | Number of channels to configure, this should be the size of the array passed in |
mode | PWM operation mode, options available in enumeration tpm_pwm_mode_t |
pwmFreq_Hz | PWM signal frequency in Hz |
srcClock_Hz | TPM counter clock in Hz |
- Returns
- kStatus_Success if the PWM setup was successful, kStatus_Error on failure
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number. In combined mode, this represents the channel pair number |
currentPwmMode | The current PWM mode set during PWM setup |
dutyCyclePercent | New PWM pulse width, value should be between 0 to 100 0=inactive signal(0% duty cycle)... 100=active signal (100% duty cycle) |
- Returns
- kStatus_Success if the PWM setup was successful, kStatus_Error on failure
void TPM_UpdateChnlEdgeLevelSelect |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber, |
|
|
uint8_t |
level |
|
) |
| |
- Note
- When the TPM has PWM pause level select feature (FSL_FEATURE_TPM_HAS_PAUSE_LEVEL_SELECT = 1), the PWM output cannot be turned off by selecting the output level. In this case, must use TPM_DisableChannel API to close the PWM output.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
level | The level to be set to the ELSnB:ELSnA field; valid values are 00, 01, 10, 11. See the appropriate SoC reference manual for details about this field. |
static uint8_t TPM_GetChannelContorlBits |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber |
|
) |
| |
|
inlinestatic |
This function disable the channel by clear all mode and level control bits.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
- Returns
- The contorl bits value. This is the logical OR of members of the enumeration tpm_chnl_control_bit_mask_t.
static void TPM_DisableChannel |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber |
|
) |
| |
|
inlinestatic |
This function disable the channel by clear all mode and level control bits.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
static void TPM_EnableChannel |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber, |
|
|
uint8_t |
control |
|
) |
| |
|
inlinestatic |
This function enable the channel output according to input mode/level config parameters.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
control | The contorl bits value. This is the logical OR of members of the enumeration tpm_chnl_control_bit_mask_t. |
When the edge specified in the captureMode argument occurs on the channel, the TPM counter is captured into the CnV register. The user has to read the CnV register separately to get this value.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
captureMode | Specifies which edge to capture |
When the TPM counter matches the value of compareVal argument (this is written into CnV reg), the channel output is changed based on what is specified in the compareMode argument.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
compareMode | Action to take on the channel output when the compare condition is met |
compareValue | Value to be programmed in the CnV register. |
This function allows to measure a pulse width of the signal on the input of channel of a channel pair. The filter function is disabled if the filterVal argument passed is zero.
- Parameters
-
base | TPM peripheral base address |
chnlPairNumber | The TPM channel pair number; options are 0, 1, 2, 3 |
edgeParam | Sets up the dual edge capture function |
filterValue | Filter value, specify 0 to disable filter. |
- Parameters
-
base | TPM peripheral base address |
phaseAParams | Phase A configuration parameters |
phaseBParams | Phase B configuration parameters |
quadMode | Selects encoding mode used in quadrature decoder mode |
static void TPM_SetChannelPolarity |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
enable | true: Set the channel polarity to active high; false: Set the channel polarity to active low; |
static void TPM_EnableChannelExtTrigger |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
In input capture mode, configures the trigger input that is used by the channel to capture the counter value. In output compare or PWM mode, configures the trigger input used to modulate the channel output. When modulating the output, the output is forced to the channel initial value whenever the trigger is not asserted.
- Note
- No matter how many external trigger sources there are, only input trigger 0 and 1 are used. The even numbered channels share the input trigger 0 and the odd numbered channels share the second input trigger 1.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
enable | true: Configures trigger input 0 or 1 to be used by channel; false: Trigger input has no effect on the channel |
void TPM_EnableInterrupts |
( |
TPM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | TPM peripheral base address |
mask | The interrupts to enable. This is a logical OR of members of the enumeration tpm_interrupt_enable_t |
void TPM_DisableInterrupts |
( |
TPM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | TPM peripheral base address |
mask | The interrupts to disable. This is a logical OR of members of the enumeration tpm_interrupt_enable_t |
uint32_t TPM_GetEnabledInterrupts |
( |
TPM_Type * |
base | ) |
|
- Parameters
-
base | TPM peripheral base address |
- Returns
- The enabled interrupts. This is the logical OR of members of the enumeration tpm_interrupt_enable_t
static uint32_t TPM_GetChannelValue |
( |
TPM_Type * |
base, |
|
|
tpm_chnl_t |
chnlNumber |
|
) |
| |
|
inlinestatic |
- Note
- The TPM channel value contain the captured TPM counter value for the input modes or the match value for the output modes.
- Parameters
-
base | TPM peripheral base address |
chnlNumber | The channel number |
- Returns
- The channle CnV regisyer value.
static uint32_t TPM_GetStatusFlags |
( |
TPM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | TPM peripheral base address |
- Returns
- The status flags. This is the logical OR of members of the enumeration tpm_status_flags_t
static void TPM_ClearStatusFlags |
( |
TPM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | TPM peripheral base address |
mask | The status flags to clear. This is a logical OR of members of the enumeration tpm_status_flags_t |
static void TPM_SetTimerPeriod |
( |
TPM_Type * |
base, |
|
|
uint32_t |
ticks |
|
) |
| |
|
inlinestatic |
Timers counts from 0 until it equals the count value set here. The count value is written to the MOD register.
- Note
- This API allows the user to use the TPM module as a timer. Do not mix usage of this API with TPM's PWM setup API's.
- Call the utility macros provided in the fsl_common.h to convert usec or msec to ticks.
- Parameters
-
base | TPM peripheral base address |
ticks | A timer period in units of ticks, which should be equal or greater than 1. |
static uint32_t TPM_GetCurrentTimerCount |
( |
TPM_Type * |
base | ) |
|
|
inlinestatic |
This function returns the real-time timer counting value in a range from 0 to a timer period.
- Note
- Call the utility macros provided in the fsl_common.h to convert ticks to usec or msec.
- Parameters
-
base | TPM peripheral base address |
- Returns
- The current counter value in ticks
- Parameters
-
base | TPM peripheral base address |
clockSource | TPM clock source; once clock source is set the counter will start running |
static void TPM_StopTimer |
( |
TPM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | TPM peripheral base address |
static void TPM_Reset |
( |
TPM_Type * |
base | ) |
|
|
inlinestatic |
Reset all internal logic and registers, except the Global Register. Remains set until cleared by software.
- Note
- TPM software reset is available on certain SoC's only
- Parameters
-
base | TPM peripheral base address |