![]() |
Kinetis SDK v.1.2 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the FlexTimer Peripheral driver.
The FlexTimer module is a timer that supports input capture, output compare, and generation of PWM signals. The current Kinetis SDK driver only supports the generation of PWM signals. The input capture and output compare will be supported in upcoming Kinetis SDK releases.
FTM calls the FTM_DRV_PwmStart() function to generate a PWM signal. Use this structure to configure different parameters for the PWM signal:
The mode options are kFtmEdgeAlignedPWM, kFtmCenterAlignedPWM, and kFtmCombinedPWM. For edge mode, the options available are kFtmHighTrue and kFtmLowTrue. Specify the PWM signal frequency in Hertz and the duty cycle percentage (value between 0-100). If the PWM mode is kFtmCombinedPWM and if the user chooses to specify a value for the uFirstEdgeDelayPercent, start of the PWM pulse is delayed.
Enumerations | |
enum | quadtmr_ip_bus_clock_source_t { kQuadTmrIpBusClkDiv1 = 0, kQuadTmrIpBusClkDiv2, kQuadTmrIpBusClkDiv4, kQuadTmrIpBusClkDiv8, kQuadTmrIpBusClkDiv16, kQuadTmrIpBusClkDiv32, kQuadTmrIpBusClkDiv64, kQuadTmrIpBusClkDiv128 } |
Quad timer IP bus clock options to run the counter. More... | |
Functions | |
void | QUADTMR_DRV_Init (uint8_t instance) |
Initializes the Quad Timer driver. More... | |
void | QUADTMR_DRV_Deinit (uint8_t instance) |
Shuts down the Quad Timer driver. More... | |
void | QUADTMR_DRV_Start64BitCounter (quadtmr_pri_count_source_t clk) |
Provides a 64-bit counter. More... | |
uint64_t | QUADTMR_DRV_Get64BitCountVal (void) |
Gets the current count value when running in 64-bit mode. More... | |
void | QUADTMR_DRV_SetupFlexPwm (uint8_t instance, quadtmr_ip_bus_clock_source_t clockSrc, uint32_t pwmPulsePeriod, uint32_t pulseWidthPeriod) |
Provides the PWM signal. More... | |
void | QUADTMR_DRV_UpdatePwm (uint8_t instance, uint32_t pwmPulsePeriod, uint32_t pulseWidthPeriod) |
Provides a way to update the current PWM signal. More... | |
void | QUADTMR_DRV_IRQHandler (uint8_t instance) |
Action to take when a Quad Timer interrupt is triggered. More... | |
Variables | |
TMR_Type *const | g_quadtmrBase [TMR_INSTANCE_COUNT] |
Table of base addresses for Quad Timer instances. More... | |
const IRQn_Type | g_quadtmrIrqId [TMR_INSTANCE_COUNT] |
Table to save Quad Timer IRQ enumeration numbers defined in the CMSIS header file. More... | |
void QUADTMR_DRV_Init | ( | uint8_t | instance | ) |
Initializes the Quad Timer registers, un-gates the module clock and enables Quad Timer interrupt in the system interrupt controller.
instance | The Quad Timer peripheral instance number. |
void QUADTMR_DRV_Deinit | ( | uint8_t | instance | ) |
Gates the module clock and disables the interrupt in the system interrupt controller.
instance | The Quad Timer peripheral instance number. |
void QUADTMR_DRV_Start64BitCounter | ( | quadtmr_pri_count_source_t | clk | ) |
The user gets to choose which source clock is used by the counter. The user must ensure that the QUADTMR_DRV_Init() function is called on all timer instances because all timer instances are used in this mode. Timer 0 is clocked via the source clock and Timers 1, 2, and 3 are set up in the cascade mode. All 4 counters count up to 0xFFFF, then roll-over and continue counting.
clk | Source clock that feeds timer 0 counter. |
uint64_t QUADTMR_DRV_Get64BitCountVal | ( | void | ) |
The function reads all 4 timer values and returns the value.
void QUADTMR_DRV_SetupFlexPwm | ( | uint8_t | instance, |
quadtmr_ip_bus_clock_source_t | clockSrc, | ||
uint32_t | pwmPulsePeriod, | ||
uint32_t | pulseWidthPeriod | ||
) |
The user provides the input clock source which is derived from the IP Bus clock. The user also provides the desired PWM signal's period in microseconds and the pulse width in microseconds. This function enables the pre-load function for each compare register to allow updating the PWM signal characteristics at a later time.
instance | The Quad timer peripheral instance number. |
clockSrc | Counter source clock, options available in quadtmr_ip_bus_clock_source_t enum |
pwmPulsePeriod | PWM period specified in microseconds |
pulseWidthPeriod | PWM pulse width specified in microseconds |
void QUADTMR_DRV_UpdatePwm | ( | uint8_t | instance, |
uint32_t | pwmPulsePeriod, | ||
uint32_t | pulseWidthPeriod | ||
) |
Prior to calling this function, the user should call the QUADTMR_DRV_SetupFlexPwm() function to start outputting a PWM signal. Call this function to update the PWM's period and/or pulse width. The PWM continues to be derived from the clock source provided during setup.
instance | The Quad timer peripheral instance number. |
pwmPulsePeriod | Updated PWM period specified in microseconds |
pulseWidthPeriod | Updated PWM pulse width specified in microseconds |
void QUADTMR_DRV_IRQHandler | ( | uint8_t | instance | ) |
The timer compare flags are checked and cleared if set.
instance | The Quad timer peripheral instance number. |
TMR_Type* const g_quadtmrBase[TMR_INSTANCE_COUNT] |
const IRQn_Type g_quadtmrIrqId[TMR_INSTANCE_COUNT] |