The KSDK provides a driver for the FlexTimer Module (FTM) of Kinetis devices.
Function groups
The FTM driver supports the generation of PWM signals, input capture, dual edge capture, output compare, and quadrature decoder modes. The driver also supports configuring each of the FTM fault inputs.
Initialization and deinitialization
The function FTM_Init() initializes the FTM with specified configurations. The function FTM_GetDefaultConfig() gets the default configurations. The initialization function configures the FTM for the requested register update mode for registers with buffers. It also sets up the FTM's fault operation mode and FTM behavior in BDM mode.
PWM Operations
The function FTM_SetupPwm() sets up FTM channels for PWM output. The function can set up the PWM signal properties for multiple channels. Each channel has its own duty cycle and level-mode specified. However, the same PWM period and PWM mode is applied to all channels requesting the PWM output. The signal duty cycle is provided as a percentage of the PWM period. Its value should be between 0 and 100 0=inactive signal(0% duty cycle) and 100=always active signal (100% duty cycle).
The function FTM_UpdatePwmDutycycle() updates the PWM signal duty cycle of a particular FTM channel.
The function FTM_UpdateChnlEdgeLevelSelect() updates the level select bits of a particular FTM channel. This can be used to disable the PWM output when making changes to the PWM signal.
Input capture operations
The function FTM_SetupInputCapture() sets up an FTM channel for input capture. The user can specify the capture edge and a filter value to be used when processing the input signal.
The function FTM_SetupDualEdgeCapture() can be used to measure the pulse width of a signal. A channel pair is used during capture with the input signal coming through a channel n. The user can specify whether to use one-shot or continuous capture, the capture edge for each channel, and any filter value to be used when processing the input signal.
Output compare operations
The function FTM_SetupOutputCompare() sets up an FTM channel for output compare. The user can specify the channel output on a successful comparison and a comparison value.
Quad decode
The function FTM_SetupQuadDecode() sets up FTM channels 0 and 1 for quad decoding. The user can specify the quad decoding mode, polarity, and filter properties for each input signal.
Fault operation
The function FTM_SetupFault() sets up the properties for each fault. 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.
Register Update
Some of the FTM registers have buffers. The driver support various methods to update these registers with the content of the register buffer. The registers can be updated using the PWM synchronized loading or an intermediate point loading. The update mechanism for register with buffers can be specified through the following fields available in the configuration structure.
uint32_t pwmSyncMode;
uint32_t reloadPoints;
Multiple PWM synchronization update modes can be used by providing an OR'ed list of options available in the enumeration ftm_pwm_sync_method_t to the pwmSyncMode field.
When using an intermediate reload points, the PWM synchnronization is not required. Multiple reload points can be used by providing an OR'ed list of options available in the enumeration ftm_reload_point_t to the reloadPoints field.
The driver initialization function sets up the appropriate bits in the FTM module based on the register update options selected.
If software PWM synchronization is used, the below function can be used to initiate a software trigger
Typical use case
PWM output
Output a PWM signal on 2 FTM channels with different duty cycles. Periodically update the PWM signal duty cycle.
int main(void)
{
bool brightnessUp = true;
|
enum | ftm_chnl_t {
kFTM_Chnl_0 = 0U,
kFTM_Chnl_1,
kFTM_Chnl_2,
kFTM_Chnl_3,
kFTM_Chnl_4,
kFTM_Chnl_5,
kFTM_Chnl_6,
kFTM_Chnl_7
} |
| List of FTM channels. More...
|
|
enum | ftm_fault_input_t {
kFTM_Fault_0 = 0U,
kFTM_Fault_1,
kFTM_Fault_2,
kFTM_Fault_3
} |
| List of FTM faults. More...
|
|
enum | ftm_pwm_mode_t {
kFTM_EdgeAlignedPwm = 0U,
kFTM_CenterAlignedPwm,
kFTM_CombinedPwm
} |
| FTM PWM operation modes. More...
|
|
enum | ftm_pwm_level_select_t {
kFTM_NoPwmSignal = 0U,
kFTM_LowTrue,
kFTM_HighTrue
} |
| FTM PWM output pulse mode: high-true, low-true or no output. More...
|
|
enum | ftm_output_compare_mode_t {
kFTM_NoOutputSignal = (1U << FTM_CnSC_MSA_SHIFT),
kFTM_ToggleOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (1U << FTM_CnSC_ELSA_SHIFT)),
kFTM_ClearOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (2U << FTM_CnSC_ELSA_SHIFT)),
kFTM_SetOnMatch = ((1U << FTM_CnSC_MSA_SHIFT) | (3U << FTM_CnSC_ELSA_SHIFT))
} |
| FlexTimer output compare mode. More...
|
|
enum | ftm_input_capture_edge_t {
kFTM_RisingEdge = (1U << FTM_CnSC_ELSA_SHIFT),
kFTM_FallingEdge = (2U << FTM_CnSC_ELSA_SHIFT),
kFTM_RiseAndFallEdge = (3U << FTM_CnSC_ELSA_SHIFT)
} |
| FlexTimer input capture edge. More...
|
|
enum | ftm_dual_edge_capture_mode_t {
kFTM_OneShot = 0U,
kFTM_Continuous = (1U << FTM_CnSC_MSA_SHIFT)
} |
| FlexTimer dual edge capture modes. More...
|
|
enum | ftm_quad_decode_mode_t {
kFTM_QuadPhaseEncode = 0U,
kFTM_QuadCountAndDir
} |
| FlexTimer quadrature decode modes. More...
|
|
enum | ftm_phase_polarity_t {
kFTM_QuadPhaseNormal = 0U,
kFTM_QuadPhaseInvert
} |
| FlexTimer quadrature phase polarities. More...
|
|
enum | ftm_deadtime_prescale_t {
kFTM_Deadtime_Prescale_1 = 1U,
kFTM_Deadtime_Prescale_4,
kFTM_Deadtime_Prescale_16
} |
| FlexTimer pre-scaler factor for the dead time insertion. More...
|
|
enum | ftm_clock_source_t {
kFTM_SystemClock = 1U,
kFTM_FixedClock,
kFTM_ExternalClock
} |
| FlexTimer clock source selection. More...
|
|
enum | ftm_clock_prescale_t {
kFTM_Prescale_Divide_1 = 0U,
kFTM_Prescale_Divide_2,
kFTM_Prescale_Divide_4,
kFTM_Prescale_Divide_8,
kFTM_Prescale_Divide_16,
kFTM_Prescale_Divide_32,
kFTM_Prescale_Divide_64,
kFTM_Prescale_Divide_128
} |
| FlexTimer pre-scaler factor selection for the clock source. More...
|
|
enum | ftm_bdm_mode_t {
kFTM_BdmMode_0 = 0U,
kFTM_BdmMode_1,
kFTM_BdmMode_2,
kFTM_BdmMode_3
} |
| Options for the FlexTimer behaviour in BDM Mode. More...
|
|
enum | ftm_fault_mode_t {
kFTM_Fault_Disable = 0U,
kFTM_Fault_EvenChnls,
kFTM_Fault_AllChnlsMan,
kFTM_Fault_AllChnlsAuto
} |
| Options for the FTM fault control mode. More...
|
|
enum | ftm_external_trigger_t {
kFTM_Chnl0Trigger = (1U << 4),
kFTM_Chnl1Trigger = (1U << 5),
kFTM_Chnl2Trigger = (1U << 0),
kFTM_Chnl3Trigger = (1U << 1),
kFTM_Chnl4Trigger = (1U << 2),
kFTM_Chnl5Trigger = (1U << 3),
kFTM_Chnl6Trigger,
kFTM_Chnl7Trigger,
kFTM_InitTrigger = (1U << 6),
kFTM_ReloadInitTrigger = (1U << 7)
} |
| FTM external trigger options. More...
|
|
enum | ftm_pwm_sync_method_t {
kFTM_SoftwareTrigger = FTM_SYNC_SWSYNC_MASK,
kFTM_HardwareTrigger_0 = FTM_SYNC_TRIG0_MASK,
kFTM_HardwareTrigger_1 = FTM_SYNC_TRIG1_MASK,
kFTM_HardwareTrigger_2 = FTM_SYNC_TRIG2_MASK
} |
| FlexTimer PWM sync options to update registers with buffer. More...
|
|
enum | ftm_reload_point_t {
kFTM_Chnl0Match = (1U << 0),
kFTM_Chnl1Match = (1U << 1),
kFTM_Chnl2Match = (1U << 2),
kFTM_Chnl3Match = (1U << 3),
kFTM_Chnl4Match = (1U << 4),
kFTM_Chnl5Match = (1U << 5),
kFTM_Chnl6Match = (1U << 6),
kFTM_Chnl7Match = (1U << 7),
kFTM_CntMax = (1U << 8),
kFTM_CntMin = (1U << 9),
kFTM_HalfCycMatch = (1U << 10)
} |
| FTM options available as loading point for register reload. More...
|
|
enum | ftm_interrupt_enable_t {
kFTM_Chnl0InterruptEnable = (1U << 0),
kFTM_Chnl1InterruptEnable = (1U << 1),
kFTM_Chnl2InterruptEnable = (1U << 2),
kFTM_Chnl3InterruptEnable = (1U << 3),
kFTM_Chnl4InterruptEnable = (1U << 4),
kFTM_Chnl5InterruptEnable = (1U << 5),
kFTM_Chnl6InterruptEnable = (1U << 6),
kFTM_Chnl7InterruptEnable = (1U << 7),
kFTM_FaultInterruptEnable = (1U << 8),
kFTM_TimeOverflowInterruptEnable = (1U << 9),
kFTM_ReloadInterruptEnable = (1U << 10)
} |
| List of FTM interrupts. More...
|
|
enum | ftm_status_flags_t {
kFTM_Chnl0Flag = (1U << 0),
kFTM_Chnl1Flag = (1U << 1),
kFTM_Chnl2Flag = (1U << 2),
kFTM_Chnl3Flag = (1U << 3),
kFTM_Chnl4Flag = (1U << 4),
kFTM_Chnl5Flag = (1U << 5),
kFTM_Chnl6Flag = (1U << 6),
kFTM_Chnl7Flag = (1U << 7),
kFTM_FaultFlag = (1U << 8),
kFTM_TimeOverflowFlag = (1U << 9),
kFTM_ChnlTriggerFlag = (1U << 10),
kFTM_ReloadFlag = (1U << 11)
} |
| List of FTM flags. More...
|
|
|
void | FTM_SetupQuadDecode (FTM_Type *base, const ftm_phase_params_t *phaseAParams, const ftm_phase_params_t *phaseBParams, ftm_quad_decode_mode_t quadMode) |
| Configures the parameters and activates the quadrature decoder mode. More...
|
|
void | FTM_SetupFault (FTM_Type *base, ftm_fault_input_t faultNumber, const ftm_fault_param_t *faultParams) |
| Sets up the working of the FTM fault protection. More...
|
|
static void | FTM_SetGlobalTimeBaseOutputEnable (FTM_Type *base, bool enable) |
| Enables or disables the FTM global time base signal generation to other FTMs. More...
|
|
static void | FTM_SetOutputMask (FTM_Type *base, ftm_chnl_t chnlNumber, bool mask) |
| Sets the FTM peripheral timer channel output mask. More...
|
|
static void | FTM_SetSoftwareTrigger (FTM_Type *base, bool enable) |
| Enables or disables the FTM software trigger for PWM synchronization. More...
|
|
static void | FTM_SetWriteProtection (FTM_Type *base, bool enable) |
| Enables or disables the FTM write protection. More...
|
|
|
status_t | FTM_SetupPwm (FTM_Type *base, const ftm_chnl_pwm_signal_param_t *chnlParams, uint8_t numOfChnls, ftm_pwm_mode_t mode, uint32_t pwmFreq_Hz, uint32_t srcClock_Hz) |
| Configures the PWM signal parameters. More...
|
|
void | FTM_UpdatePwmDutycycle (FTM_Type *base, ftm_chnl_t chnlNumber, ftm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent) |
| Updates the duty cycle of an active PWM signal. More...
|
|
void | FTM_UpdateChnlEdgeLevelSelect (FTM_Type *base, ftm_chnl_t chnlNumber, uint8_t level) |
| Updates the edge level selection for a channel. More...
|
|
void | FTM_SetupInputCapture (FTM_Type *base, ftm_chnl_t chnlNumber, ftm_input_capture_edge_t captureMode, uint32_t filterValue) |
| Enables capturing an input signal on the channel using the function parameters. More...
|
|
void | FTM_SetupOutputCompare (FTM_Type *base, ftm_chnl_t chnlNumber, ftm_output_compare_mode_t compareMode, uint32_t compareValue) |
| Configures the FTM to generate timed pulses. More...
|
|
void | FTM_SetupDualEdgeCapture (FTM_Type *base, ftm_chnl_t chnlPairNumber, const ftm_dual_edge_capture_param_t *edgeParam, uint32_t filterValue) |
| Configures the dual edge capture mode of the FTM. More...
|
|
struct ftm_chnl_pwm_signal_param_t |
ftm_chnl_t ftm_chnl_pwm_signal_param_t::chnlNumber |
In combined mode, this represents the channel pair number.
uint8_t ftm_chnl_pwm_signal_param_t::dutyCyclePercent |
100 = always active signal (100% duty cycle).
uint8_t ftm_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 a percentage of the PWM period
struct ftm_dual_edge_capture_param_t |
struct ftm_phase_params_t |
Data Fields |
bool | enableFaultInput |
| True: Fault input is enabled; false: Fault input is disabled.
|
|
bool | faultLevel |
| True: Fault polarity is active low i.e '0' indicates a fault; False: Fault polarity is active high.
|
|
bool | useFaultFilter |
| True: Use the filtered fault signal; False: Use the direct path from fault input.
|
|
This structure holds the configuration settings for the FTM peripheral. To initialize this structure to reasonable defaults, call the FTM_GetDefaultConfig() function and pass a pointer to the configuration structure instance.
The configuration structure can be made constant so as to reside in flash.
uint32_t ftm_config_t::pwmSyncMode |
uint32_t ftm_config_t::reloadPoints |
Multiple reload points can be used by providing an OR'ed list of options available in enumeration ftm_reload_point_t.
uint32_t ftm_config_t::extTriggers |
Multiple trigger sources can be enabled by providing an OR'ed list of options available in enumeration ftm_external_trigger_t.
- Note
- Actual number of available channels is SoC dependent
Enumerator |
---|
kFTM_Chnl_0 |
FTM channel number 0.
|
kFTM_Chnl_1 |
FTM channel number 1.
|
kFTM_Chnl_2 |
FTM channel number 2.
|
kFTM_Chnl_3 |
FTM channel number 3.
|
kFTM_Chnl_4 |
FTM channel number 4.
|
kFTM_Chnl_5 |
FTM channel number 5.
|
kFTM_Chnl_6 |
FTM channel number 6.
|
kFTM_Chnl_7 |
FTM channel number 7.
|
Enumerator |
---|
kFTM_Fault_0 |
FTM fault 0 input pin.
|
kFTM_Fault_1 |
FTM fault 1 input pin.
|
kFTM_Fault_2 |
FTM fault 2 input pin.
|
kFTM_Fault_3 |
FTM fault 3 input pin.
|
Enumerator |
---|
kFTM_EdgeAlignedPwm |
Edge-aligned PWM.
|
kFTM_CenterAlignedPwm |
Center-aligned PWM.
|
kFTM_CombinedPwm |
Combined PWM.
|
Enumerator |
---|
kFTM_NoPwmSignal |
No PWM output on pin.
|
kFTM_LowTrue |
Low true pulses.
|
kFTM_HighTrue |
High true pulses.
|
Enumerator |
---|
kFTM_NoOutputSignal |
No channel output when counter reaches CnV.
|
kFTM_ToggleOnMatch |
Toggle output.
|
kFTM_ClearOnMatch |
Clear output.
|
kFTM_SetOnMatch |
Set output.
|
Enumerator |
---|
kFTM_RisingEdge |
Capture on rising edge only.
|
kFTM_FallingEdge |
Capture on falling edge only.
|
kFTM_RiseAndFallEdge |
Capture on rising or falling edge.
|
Enumerator |
---|
kFTM_OneShot |
One-shot capture mode.
|
kFTM_Continuous |
Continuous capture mode.
|
Enumerator |
---|
kFTM_QuadPhaseEncode |
Phase A and Phase B encoding mode.
|
kFTM_QuadCountAndDir |
Count and direction encoding mode.
|
Enumerator |
---|
kFTM_QuadPhaseNormal |
Phase input signal is not inverted.
|
kFTM_QuadPhaseInvert |
Phase input signal is inverted.
|
Enumerator |
---|
kFTM_Deadtime_Prescale_1 |
Divide by 1.
|
kFTM_Deadtime_Prescale_4 |
Divide by 4.
|
kFTM_Deadtime_Prescale_16 |
Divide by 16.
|
Enumerator |
---|
kFTM_SystemClock |
System clock selected.
|
kFTM_FixedClock |
Fixed frequency clock.
|
kFTM_ExternalClock |
External clock.
|
Enumerator |
---|
kFTM_Prescale_Divide_1 |
Divide by 1.
|
kFTM_Prescale_Divide_2 |
Divide by 2.
|
kFTM_Prescale_Divide_4 |
Divide by 4.
|
kFTM_Prescale_Divide_8 |
Divide by 8.
|
kFTM_Prescale_Divide_16 |
Divide by 16.
|
kFTM_Prescale_Divide_32 |
Divide by 32.
|
kFTM_Prescale_Divide_64 |
Divide by 64.
|
kFTM_Prescale_Divide_128 |
Divide by 128.
|
Enumerator |
---|
kFTM_BdmMode_0 |
FTM counter stopped, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers bypass the register buffers.
|
kFTM_BdmMode_1 |
FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are forced to their safe value , writes to MOD,CNTIN and C(n)V registers bypass the register buffers.
|
kFTM_BdmMode_2 |
FTM counter stopped, CH(n)F bit is not set, FTM channels outputs are frozen when chip enters in BDM mode, writes to MOD,CNTIN and C(n)V registers bypass the register buffers.
|
kFTM_BdmMode_3 |
FTM counter in functional mode, CH(n)F bit can be set, FTM channels in functional mode, writes to MOD,CNTIN and C(n)V registers is in fully functional mode.
|
Enumerator |
---|
kFTM_Fault_Disable |
Fault control is disabled for all channels.
|
kFTM_Fault_EvenChnls |
Enabled for even channels only(0,2,4,6) with manual fault clearing.
|
kFTM_Fault_AllChnlsMan |
Enabled for all channels with manual fault clearing.
|
kFTM_Fault_AllChnlsAuto |
Enabled for all channels with automatic fault clearing.
|
- Note
- Actual available external trigger sources are SoC-specific
Enumerator |
---|
kFTM_Chnl0Trigger |
Generate trigger when counter equals chnl 0 CnV reg.
|
kFTM_Chnl1Trigger |
Generate trigger when counter equals chnl 1 CnV reg.
|
kFTM_Chnl2Trigger |
Generate trigger when counter equals chnl 2 CnV reg.
|
kFTM_Chnl3Trigger |
Generate trigger when counter equals chnl 3 CnV reg.
|
kFTM_Chnl4Trigger |
Generate trigger when counter equals chnl 4 CnV reg.
|
kFTM_Chnl5Trigger |
Generate trigger when counter equals chnl 5 CnV reg.
|
kFTM_Chnl6Trigger |
Available on certain SoC's, generate trigger when counter equals chnl 6 CnV reg.
|
kFTM_Chnl7Trigger |
Available on certain SoC's, generate trigger when counter equals chnl 7 CnV reg.
|
kFTM_InitTrigger |
Generate Trigger when counter is updated with CNTIN.
|
kFTM_ReloadInitTrigger |
Available on certain SoC's, trigger on reload point.
|
Enumerator |
---|
kFTM_SoftwareTrigger |
Software triggers PWM sync.
|
kFTM_HardwareTrigger_0 |
Hardware trigger 0 causes PWM sync.
|
kFTM_HardwareTrigger_1 |
Hardware trigger 1 causes PWM sync.
|
kFTM_HardwareTrigger_2 |
Hardware trigger 2 causes PWM sync.
|
- Note
- Actual available reload points are SoC-specific
Enumerator |
---|
kFTM_Chnl0Match |
Channel 0 match included as a reload point.
|
kFTM_Chnl1Match |
Channel 1 match included as a reload point.
|
kFTM_Chnl2Match |
Channel 2 match included as a reload point.
|
kFTM_Chnl3Match |
Channel 3 match included as a reload point.
|
kFTM_Chnl4Match |
Channel 4 match included as a reload point.
|
kFTM_Chnl5Match |
Channel 5 match included as a reload point.
|
kFTM_Chnl6Match |
Channel 6 match included as a reload point.
|
kFTM_Chnl7Match |
Channel 7 match included as a reload point.
|
kFTM_CntMax |
Use in up-down count mode only, reload when counter reaches the maximum value.
|
kFTM_CntMin |
Use in up-down count mode only, reload when counter reaches the minimum value.
|
kFTM_HalfCycMatch |
Available on certain SoC's, half cycle match reload point.
|
- Note
- Actual available interrupts are SoC-specific
Enumerator |
---|
kFTM_Chnl0InterruptEnable |
Channel 0 interrupt.
|
kFTM_Chnl1InterruptEnable |
Channel 1 interrupt.
|
kFTM_Chnl2InterruptEnable |
Channel 2 interrupt.
|
kFTM_Chnl3InterruptEnable |
Channel 3 interrupt.
|
kFTM_Chnl4InterruptEnable |
Channel 4 interrupt.
|
kFTM_Chnl5InterruptEnable |
Channel 5 interrupt.
|
kFTM_Chnl6InterruptEnable |
Channel 6 interrupt.
|
kFTM_Chnl7InterruptEnable |
Channel 7 interrupt.
|
kFTM_FaultInterruptEnable |
Fault interrupt.
|
kFTM_TimeOverflowInterruptEnable |
Time overflow interrupt.
|
kFTM_ReloadInterruptEnable |
Reload interrupt; Available only on certain SoC's.
|
- Note
- Actual available flags are SoC-specific
Enumerator |
---|
kFTM_Chnl0Flag |
Channel 0 Flag.
|
kFTM_Chnl1Flag |
Channel 1 Flag.
|
kFTM_Chnl2Flag |
Channel 2 Flag.
|
kFTM_Chnl3Flag |
Channel 3 Flag.
|
kFTM_Chnl4Flag |
Channel 4 Flag.
|
kFTM_Chnl5Flag |
Channel 5 Flag.
|
kFTM_Chnl6Flag |
Channel 6 Flag.
|
kFTM_Chnl7Flag |
Channel 7 Flag.
|
kFTM_FaultFlag |
Fault Flag.
|
kFTM_TimeOverflowFlag |
Time overflow Flag.
|
kFTM_ChnlTriggerFlag |
Channel trigger Flag.
|
kFTM_ReloadFlag |
Reload Flag; Available only on certain SoC's.
|
status_t FTM_Init |
( |
FTM_Type * |
base, |
|
|
const ftm_config_t * |
config |
|
) |
| |
- Note
- This API should be called at the beginning of the application using the FTM driver.
- Parameters
-
base | FTM peripheral base address |
config | Pointer to the user configuration structure. |
- Returns
- kStatus_Success indicates success; Else indicates failure.
void FTM_Deinit |
( |
FTM_Type * |
base | ) |
|
- Parameters
-
base | FTM peripheral base address |
The default values are:
config->reloadPoints = 0;
config->faultFilterValue = 0;
config->deadTimeValue = 0;
config->extTriggers = 0;
config->chnlInitState = 0;
config->chnlPolarity = 0;
config->useGlobalTimeBase = false;
- Parameters
-
config | Pointer to the user configuration structure. |
Call this function to configure the PWM signal period, mode, duty cycle, and edge. Use this function to configure all FTM channels that are used to output a PWM signal.
- Parameters
-
base | FTM 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 ftm_pwm_mode_t |
pwmFreq_Hz | PWM signal frequency in Hz |
srcClock_Hz | FTM counter clock in Hz |
- Returns
- kStatus_Success if the PWM setup was successful kStatus_Error on failure
void FTM_UpdatePwmDutycycle |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlNumber, |
|
|
ftm_pwm_mode_t |
currentPwmMode, |
|
|
uint8_t |
dutyCyclePercent |
|
) |
| |
- Parameters
-
base | FTM peripheral base address |
chnlNumber | The channel/channel pair number. In combined mode, this represents the channel pair number |
currentPwmMode | The current PWM mode set during PWM setup |
dutyCyclePercent | New PWM pulse width; The value should be between 0 to 100 0=inactive signal(0% duty cycle)... 100=active signal (100% duty cycle) |
void FTM_UpdateChnlEdgeLevelSelect |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlNumber, |
|
|
uint8_t |
level |
|
) |
| |
- Parameters
-
base | FTM 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 Kinetis SoC reference manual for details about this field. |
When the edge specified in the captureMode argument occurs on the channel, the FTM counter is captured into the CnV register. The user has to read the CnV register separately to get this value. The filter function is disabled if the filterVal argument passed in is 0. The filter function is available only for channels 0, 1, 2, 3.
- Parameters
-
base | FTM peripheral base address |
chnlNumber | The channel number |
captureMode | Specifies which edge to capture |
filterValue | Filter value, specify 0 to disable filter. Available only for channels 0-3. |
When the FTM 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 | FTM 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 sets up the dual edge capture mode on a channel pair. The capture edge for the channel pair and the capture mode (one-shot or continuous) is specified in the parameter argument. The filter function is disabled if the filterVal argument passed is zero. The filter function is available only on channels 0 and 2. The user has to read the channel CnV registers separately to get the capture values.
- Parameters
-
base | FTM peripheral base address |
chnlPairNumber | The FTM 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. Available only for channel pair 0 and 1. |
- Parameters
-
base | FTM peripheral base address |
phaseAParams | Phase A configuration parameters |
phaseBParams | Phase B configuration parameters |
quadMode | Selects encoding mode used in quadrature decoder mode |
FTM can have up to 4 fault inputs. This function sets up fault parameters, fault level, and a filter.
- Parameters
-
base | FTM peripheral base address |
faultNumber | FTM fault to configure. |
faultParams | Parameters passed in to set up the fault |
void FTM_EnableInterrupts |
( |
FTM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | FTM peripheral base address |
mask | The interrupts to enable. This is a logical OR of members of the enumeration ftm_interrupt_enable_t |
void FTM_DisableInterrupts |
( |
FTM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | FTM peripheral base address |
mask | The interrupts to enable. This is a logical OR of members of the enumeration ftm_interrupt_enable_t |
uint32_t FTM_GetEnabledInterrupts |
( |
FTM_Type * |
base | ) |
|
- Parameters
-
base | FTM peripheral base address |
- Returns
- The enabled interrupts. This is the logical OR of members of the enumeration ftm_interrupt_enable_t
uint32_t FTM_GetStatusFlags |
( |
FTM_Type * |
base | ) |
|
- Parameters
-
base | FTM peripheral base address |
- Returns
- The status flags. This is the logical OR of members of the enumeration ftm_status_flags_t
void FTM_ClearStatusFlags |
( |
FTM_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
- Parameters
-
base | FTM peripheral base address |
mask | The status flags to clear. This is a logical OR of members of the enumeration ftm_status_flags_t |
- Parameters
-
base | FTM peripheral base address |
clockSource | FTM clock source; After the clock source is set, the counter starts running. |
static void FTM_StopTimer |
( |
FTM_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
static void FTM_SetSoftwareCtrlEnable |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlNumber | Channel to be enabled or disabled |
value | true: channel output is affected by software output control false: channel output is unaffected by software output control |
static void FTM_SetSoftwareCtrlVal |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address. |
chnlNumber | Channel to be configured |
value | true to set 1, false to set 0 |
static void FTM_SetGlobalTimeBaseOutputEnable |
( |
FTM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
enable | true to enable, false to disable |
static void FTM_SetOutputMask |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlNumber, |
|
|
bool |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlNumber | Channel to be configured |
mask | true: masked, channel is forced to its inactive state; false: unmasked |
static void FTM_SetFaultControlEnable |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlPairNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlPairNumber | The FTM channel pair number; options are 0, 1, 2, 3 |
value | true: Enable fault control for this channel pair; false: No fault control |
static void FTM_SetDeadTimeEnable |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlPairNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlPairNumber | The FTM channel pair number; options are 0, 1, 2, 3 |
value | true: Insert dead time in this channel pair; false: No dead time inserted |
static void FTM_SetComplementaryEnable |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlPairNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlPairNumber | The FTM channel pair number; options are 0, 1, 2, 3 |
value | true: enable complementary mode; false: disable complementary mode |
static void FTM_SetInvertEnable |
( |
FTM_Type * |
base, |
|
|
ftm_chnl_t |
chnlPairNumber, |
|
|
bool |
value |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
chnlPairNumber | The FTM channel pair number; options are 0, 1, 2, 3 |
value | true: enable inverting; false: disable inverting |
static void FTM_SetSoftwareTrigger |
( |
FTM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
enable | true: software trigger is selected, false: software trigger is not selected |
static void FTM_SetWriteProtection |
( |
FTM_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | FTM peripheral base address |
enable | true: Write-protection is enabled, false: Write-protection is disabled |