Data Structures | Macros | Typedefs | Enumerations | Functions
LGPTimerLPF3.h File Reference

Detailed Description

LGPTimer driver implementation for Low Power F3 devices.


Overview

The LGPTimer driver allows you to measure elapsed time with simple and portable APIs. It also allows for asynchronous callbacks after a certain amount of time has elapsed. In addition the driver supports APIs for both capture and compare of of IO signals muxable to the three channels of each LGPT peripheral instance. The channel capture functionality can be used to measure period and duty cycle of an input signal. The channel compare functionality can be used for generating PWM signals.

The LGPTimer driver also handles the general purpose timer resource allocation. For each driver that requires use of a general purpose timer, it calls LGPTimerLPF3_open() to occupy the specified timer, and calls LGPTimerLPF3_close() to release the occupied timer resource.

LGPT peripheral properties

The LGPT peripherals support different timer counter widths depending on the peripheral instance number (LGPT0, LGPT1, ..). The table below lists supported counter widths for each peripheral instance number on available device types. The timer counter clock is sourced from the internal prescaler stage which has the high frequency clock (CLKSVT) as input. The prescaler can be configured to divide the input system clock, effectively extending the maximal time interval for the timer counter while reducing the timer resolution.

Device type LGPT0 LGPT1 LGPT2 LGPT3
CC2340R2 16 bits 16 bits N.A N.A
CC2340R5 16 bits 16 bits 16 bits 24 bits
CC27XX 16 bits 16 bits 16 bits 32 bits

Counter Modes

The LGPTimer driver supports the following timer counter modes:

LGPT peripheral features not supported by the LGPTimer driver

Power Management

The power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.

The LGPTimer driver will set constraints on disallowed power modes when needed, removing the need for the application to handle this. The following statements are valid:

Accuracy

The timer clock of the LGPT peripheral is dependent on the high frequency clock (CLKSVT).

Usage

This documentation provides some basic examples in the form of commented code fragments.


Examples

Note
The following examples are intended for reference only and are not intended for application use.

Periodic timer example

The code example below will generate an interrupt using the LGPTimer every 1 ms. Note that when a count-up counter mode is used, the number of counter ticks to reach the target value equals target value + 1.

void timerCallback(LGPTimerLPF3_Handle lgptHandle, LGPTimerLPF3_IntMask interruptMask) {
// interrupt callback code goes here. Minimize processing in interrupt.
}
void* taskFxn(void* arg) {
LGPTimerLPF3_Handle lgptHandle;
uint32_t counterTarget;
// Initialize parameters and assign callback function to be used
params.hwiCallbackFxn = timerCallback;
// Open driver
lgptHandle = LGPTimerLPF3_open(0, &params);
// Set counter target
counterTarget = 48000 - 1; // 1 ms with a system clock of 48 MHz
LGPTimerLPF3_setInitialCounterTarget(lgptHandle, counterTarget, true);
// Enable counter target interrupt
// Start counter in count-up-periodic mode
// Generate counter target interrupt every 1 ms forever
while(1);
}

Output signal generation example

The code example below will generate an output signal of 32 kHz with a 50 % duty cycle on channel 2. With an up/down counter mode, the counter target value determines the signal period and the value must be set to half the number of the total counter ticks per signal period. With a channel action of toggle-on-compare, the channel compare value must be set to (counter target value)/2 in order to obtain a 50 % duty cycle of the output signal. The period of a 32 kHz signal equals 1500 counter ticks when the counter has a 48 MHz clock.

void* taskFxn(void* arg) {
LGPTimerLPF3_Handle lgptHandle;
uint32_t cntTargetVal = 1500/2;
uint32_t chCompVal = cntTargetVal/2;
// Configure channel 2 action
// Open driver
lgptHandle = LGPTimerLPF3_open(0, &params);
// Set channel output signal period
LGPTimerLPF3_setInitialCounterTarget(lgptHandle, cntTargetVal, false);
// Set channel output signal duty cycle
// Start the LGPTimer in up-down-periodic mode
// Output signal forever
while(1);
}

Opening the LGPTimerLPF3 Driver

Opening a LGPTimerLPF3 requires four steps:

  1. Create and initialize a LGPTimerLPF3_Params structure.
  2. Set non-default parameter values.
  3. Call LGPTimerLPF3_open(), passing the index of the timer in the LGPTimerLPF3_Config structure, and the address of the LGPTimerLPF3_Params structure. The timer instance is specified by the index in the LGPTimerLPF3_Config structure.
  4. Verify that the timer handle returned by LGPTimerLPF3_open() is non-NULL. The handle will be used to operate the timer driver instance you just opened.

Configuration

Refer to the Driver's Configuration section for driver configuration information.



#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/GPIO.h>
#include <ti/devices/DeviceFamily.h>
#include <DeviceFamily_constructPath(inc/hw_lgpt.h)>
Include dependency graph for LGPTimerLPF3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LGPTimerLPF3_ChannelProp
 LGPTimerLPF3 channel dependent properties struct. More...
 
struct  LGPTimerLPF3_Params
 LGPTimerLPF3 Parameters. More...
 
struct  LGPTimerLPF3_ChannelConf
 LGPTimerLPF3 channel dependent pin configuration struct. More...
 
struct  LGPTimerLPF3_HWAttrs
 LGPTimerLPF3 Hardware attributes. More...
 
struct  LGPTimerLPF3_Object
 LGPTimerLPF3 Object. More...
 
struct  LGPTimerLPF3_Config
 LGPTimer Global configuration. More...
 

Macros

#define NO_OF_LGPT_CHANNELS   3
 

Typedefs

typedef struct LGPTimerLPF3_Config LGPTimerLPF3_Config
 
typedef LGPTimerLPF3_ConfigLGPTimerLPF3_Handle
 
typedef uint16_t LGPTimerLPF3_IntMask
 
typedef void(* LGPTimerLPF3_HwiFxn) (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask interruptMask)
 The definition of a callback function used by the LGPTimer driver. More...
 
typedef struct LGPTimerLPF3_ChannelProp LGPTimerLPF3_ChannelProp
 LGPTimerLPF3 channel dependent properties struct. More...
 
typedef struct LGPTimerLPF3_Params LGPTimerLPF3_Params
 LGPTimerLPF3 Parameters. More...
 
typedef struct LGPTimerLPF3_ChannelConf LGPTimerLPF3_ChannelConf
 LGPTimerLPF3 channel dependent pin configuration struct. More...
 
typedef struct LGPTimerLPF3_HWAttrs LGPTimerLPF3_HWAttrs
 LGPTimerLPF3 Hardware attributes. More...
 
typedef struct LGPTimerLPF3_Object LGPTimerLPF3_Object
 LGPTimerLPF3 Object. More...
 

Enumerations

enum  LGPTimerLPF3_ChannelNo { LGPTimerLPF3_CH_NO_0 = 0, LGPTimerLPF3_CH_NO_1 = 1, LGPTimerLPF3_CH_NO_2 = 2 }
 Definitions for supported LGPTimer channel numbers. More...
 
enum  LGPTimerLPF3_ChannelDir { LGPTimerLPF3_CH_DIR_NONE = 0, LGPTimerLPF3_CH_DIR_INPUT = 1, LGPTimerLPF3_CH_DIR_OUTPUT = 2 }
 Definitions for supported LGPTimer channel direction. More...
 
enum  LGPTimerLPF3_ChannelLevel { LGPTimerLPF3_CH_LEVEL_LOW = LGPT_OUTCTL_CLROUT0, LGPTimerLPF3_CH_LEVEL_HIGH = LGPT_OUTCTL_SETOUT0 }
 Definitions for supported LGPTimer channel output levels. More...
 
enum  LGPTimerLPF3_ChannelInputEdge { LGPTimerLPF3_CH_EDGE_NONE = LGPT_C0CFG_EDGE_NONE, LGPTimerLPF3_CH_EDGE_RISE = LGPT_C0CFG_EDGE_RISE, LGPTimerLPF3_CH_EDGE_FALL = LGPT_C0CFG_EDGE_FALL, LGPTimerLPF3_CH_EDGE_BOTH = LGPT_C0CFG_EDGE_BOTH }
 Definitions for supported LGPTimer channel input edge. More...
 
enum  LGPTimerLPF3_Mode { LGPTimerLPF3_CTL_MODE_DIS = LGPT_CTL_MODE_DIS, LGPTimerLPF3_CTL_MODE_UP_ONCE = LGPT_CTL_MODE_UP_ONCE, LGPTimerLPF3_CTL_MODE_UP_PER = LGPT_CTL_MODE_UP_PER, LGPTimerLPF3_CTL_MODE_UPDWN_PER = LGPT_CTL_MODE_UPDWN_PER }
 Definitions for supported LGPTimer counting modes. More...
 
enum  LGPTimerLPF3_Interrupt {
  LGPTimerLPF3_INT_TGT = 1 << LGPT_RIS_TGT_S, LGPTimerLPF3_INT_ZERO = 1 << LGPT_RIS_ZERO_S, LGPTimerLPF3_INT_COUNTER_CHANGE = 1 << LGPT_RIS_CNTRCHNG_S, LGPTimerLPF3_INT_DIR_CHANGE = 1 << LGPT_RIS_DIRCHNG_S,
  LGPTimerLPF3_INT_CH0_CC = 1 << LGPT_RIS_C0CC_S, LGPTimerLPF3_INT_CH1_CC = 1 << LGPT_RIS_C1CC_S, LGPTimerLPF3_INT_CH2_CC = 1 << LGPT_RIS_C2CC_S
}
 Definitions for supported LGPTimer interrupts. LGPTimerLPF3_IntMask arguments should be a bit vector containing these definitions. More...
 
enum  LGPTimerLPF3_DebugMode { LGPTimerLPF3_DEBUG_STALL_OFF = LGPT_EMU_HALT_DIS, LGPTimerLPF3_DEBUG_STALL_IMMEDIATE = (LGPT_EMU_HALT_EN | LGPT_EMU_CTL_IMMEDIATE), LGPTimerLPF3_DEBUG_STALL_ON_ZERO = (LGPT_EMU_HALT_EN | LGPT_EMU_CTL_ZERCOND) }
 Definitions for controlling timer debug stall mode. More...
 
enum  LGPTimerLPF3_ChannelCmpDir { LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_BOTH = LGPT_CTL_CMPDIR_BOTH, LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_UP = LGPT_CTL_CMPDIR_UP, LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_DOWN = LGPT_CTL_CMPDIR_DOWN }
 Definitions for which direction the timer counter must have in order to set channel compare interrupt status flag. More...
 
enum  LGPTimerLPF3_ChannelAction {
  LGPTimerLPF3_CH_DISABLE = LGPT_C1CFG_CCACT_DIS, LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_TGL_ON_CMP, LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_CMP,
  LGPTimerLPF3_CH_SET_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_SET_ON_CMP_DIS, LGPTimerLPF3_CH_CLEAR_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_CLR_ON_CMP, LGPTimerLPF3_CH_CLEAR_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_CLR_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_CMP_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP,
  LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_SET_ON_0_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP, LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_CLR_ON_0_TGL_ON_CMP_DIS, LGPTimerLPF3_CH_PULSE_ON_COMPARE_PERIODIC = LGPT_C0CFG_CCACT_PULSE_ON_CMP,
  LGPTimerLPF3_CH_PULSE_ON_COMPARE_ONCE = LGPT_C0CFG_CCACT_PULSE_ON_CMP_DIS, LGPTimerLPF3_CH_SET_ON_CAPTURE_PERIODIC = LGPT_C0CFG_CCACT_SET_ON_CAPT, LGPTimerLPF3_CH_SET_ON_CAPTURE_ONCE = LGPT_C0CFG_CCACT_SET_ON_CAPT_DIS, LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE = LGPT_C0CFG_CCACT_PER_PULSE_WIDTH_MEAS
}
 Definitions for supported LGPTimer channel actions. More...
 

Functions

void LGPTimerLPF3_Params_init (LGPTimerLPF3_Params *params)
 Function that initializes the LGPTimerLPF3_Params struct to its default values. More...
 
LGPTimerLPF3_Handle LGPTimerLPF3_open (uint_least8_t index, const LGPTimerLPF3_Params *params)
 Function that opens a driver for the given LGPT peripheral. Will set power dependency on timer and configure it into specified configuration. More...
 
void LGPTimerLPF3_close (LGPTimerLPF3_Handle handle)
 Function that closes a LGPTimer driver specified by the LGPTimer handle. Closing LGPTimer driver will release power dependency on timer and clear configuration. More...
 
void LGPTimerLPF3_start (LGPTimerLPF3_Handle handle, LGPTimerLPF3_Mode mode)
 Function that starts the timer counter of the specified LGPTimer handle with current settings and specified timer counter mode. More...
 
void LGPTimerLPF3_stop (LGPTimerLPF3_Handle handle)
 Function that stops the timer counter of the specified LGPTimer driver. More...
 
void LGPTimerLPF3_setInitialCounterTarget (LGPTimerLPF3_Handle handle, uint32_t value, bool intFlagClr)
 Function that sets the initial timer counter target on the specified LGPTimer. This function must be called before the timer is started. Timer counter width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties). More...
 
void LGPTimerLPF3_setNextCounterTarget (LGPTimerLPF3_Handle handle, uint32_t value, bool intFlagClr)
 Function that sets the timer counter target for the next counter period on the specified LGPTimer. The specified target value will be valid as timer counter target on the upcoming zero crossing. When counting repeatedly upwards a zero crossing is regarded as when the timer counter restarts counting from 0. This function can be called after the timer has started. Timer counter width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties). More...
 
uint32_t LGPTimerLPF3_getCounter (LGPTimerLPF3_Handle handle)
 Function that returns the current timer counter value. More...
 
uint32_t LGPTimerLPF3_getArg (LGPTimerLPF3_Handle handle)
 Function to get a custom argument. More...
 
void LGPTimerLPF3_setArg (LGPTimerLPF3_Handle handle, void *arg)
 Function to set a custom argument. More...
 
void LGPTimerLPF3_enableInterrupt (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask intMask)
 Enable interrupt source for the LGPTimer handle. More...
 
void LGPTimerLPF3_disableInterrupt (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask intMask)
 Disable interrupt source for the LGPTimer handle. More...
 
void LGPTimerLPF3_setInitialChannelCompVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, uint32_t value, bool intFlagClr)
 Function that sets the initial channel compare value on the specified LGPTimer and channel. The compare value for the specified channel will be used by any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to LGPTimerLPF3_start(). Timer compare value width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties). More...
 
void LGPTimerLPF3_setNextChannelCompVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, uint32_t value, bool intFlagClr)
 Function that sets the channel compare value on the specified LGPTimer for the next cycle of the already started timer counter. The compare value for the specified channel is valid for any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value in the next and following timer counter cycles. This function can be called while the timer is active. More...
 
void LGPTimerLPF3_setChannelOutputLevel (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo, LGPTimerLPF3_ChannelLevel level)
 Function that manually sets the current channel output level high or low. Manual update of a channel output takes priority over automatic channel updates to the same output when occurring at the same time. The complementary channel output will be set to the complementary level of the specified level. More...
 
uint32_t LGPTimerLPF3_getChCompareVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo)
 Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal. More...
 
uint32_t LGPTimerLPF3_getChCaptureVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo)
 Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal. More...
 
uint32_t LGPTimerLPF3_getNextChCompareVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo)
 Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used. More...
 
uint32_t LGPTimerLPF3_getNextChCaptureVal (LGPTimerLPF3_Handle handle, LGPTimerLPF3_ChannelNo chNo)
 Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal() should be used. More...
 
uint32_t LGPTimerLPF3_getCounterWidth (LGPTimerLPF3_Handle handle)
 Function to get the width of the timer counter in number of bits. More...
 

Macro Definition Documentation

§ NO_OF_LGPT_CHANNELS

#define NO_OF_LGPT_CHANNELS   3

Typedef Documentation

§ LGPTimerLPF3_Config

§ LGPTimerLPF3_Handle

§ LGPTimerLPF3_IntMask

typedef uint16_t LGPTimerLPF3_IntMask

§ LGPTimerLPF3_HwiFxn

typedef void(* LGPTimerLPF3_HwiFxn) (LGPTimerLPF3_Handle handle, LGPTimerLPF3_IntMask interruptMask)

The definition of a callback function used by the LGPTimer driver.

Parameters
[in]handleA LGPTimer handle
[in]interruptMaskLGPTimer interrupt mask

§ LGPTimerLPF3_ChannelProp

LGPTimerLPF3 channel dependent properties struct.

LGPTimer struct used by the LGPTimerLPF3_Params.

§ LGPTimerLPF3_Params

LGPTimerLPF3 Parameters.

LGPTimer parameters are used by the LGPTimerLPF3_open() call. Default values for these parameters are set using LGPTimerLPF3_Params_init().

Note
The prescalerDiv parameter determines the division factor of the system clock being input to the timer counter:
  • 0x00: Divide by 1
  • 0x01: Divide by 2
  • ...
  • 0xFF: Divide by 256
The intPhaseLate parameter which determines if the LGPTimerLPF3_INT_TGT and LGPTimerLPF3_INT_ZERO interrupt status flags will be set early or late, is specified as follows:
  • false: Interrupt status flags are set one system clock cycle after counter = TARGET/ZERO.
  • true : Interrupt status flags are set one timer clock cycle after counter = TARGET/ZERO.

Please note that if the value of the intPhaseLate parameter is set to false while the prescalerDiv parameter value is high and either the LGPTimerLPF3_INT_TGT or LGPTimerLPF3_INT_ZERO interrupts are enabled, these interrupts might occur multiple times back-to-back when the interrupts are first triggered. While the counter is active, the timer will hold the state of the counter for one clock period of the timer clock before the counter gets updated. When the timer clock frequency is configured low by a high prescalerDiv parameter value, this hold time might be longer than it takes for the interrupt service routine to clear the interrupt status. This will cause a new interrupt to be immediatly generated. In order to avoid this situation, the intPhaseLate parameter value needs to be set to true. Then the interrupt will occur one timer clock cycle after the counter has reached the TARGET/ZERO value, meaning that the described hold time is reduced to 0.

See also
LGPTimerLPF3_Params_init()

§ LGPTimerLPF3_ChannelConf

LGPTimerLPF3 channel dependent pin configuration struct.

LGPTimer struct used by the LGPTimerLPF3_HWAttrs.

§ LGPTimerLPF3_HWAttrs

LGPTimerLPF3 Hardware attributes.

These fields are used by the driver to set up underlying LGPTimer driver statically. A sample structure is shown below:

// LGPTimer hardware attributes, one per supported LGPT peripheral
const LGPTimerLPF3_HWAttrs LGPTimerLPF3HWAttrs[] = {
{
.baseAddr = LGPT0_BASE,
.intNum = INT_LGPT0_COMB,
.intPriority = INT_PRI_LEVEL1,
.powerMngrId = PowerLPF3_PERIPH_LGPT0,
.channelConfig[0] = {
.pin = CONFIG_GPIO_LGPT0C0,
.nPin = CONFIG_GPIO_LGPT0C0N,
},
.channelConfig[1] = {
.pin = CONFIG_GPIO_LGPT0C1,
.nPin = CONFIG_GPIO_LGPT0C1N,
},
.channelConfig[2] = {
.pin = CONFIG_GPIO_LGPT0C2,
.nPin = CONFIG_GPIO_LGPT0C2N,
},
},
};

§ LGPTimerLPF3_Object

LGPTimerLPF3 Object.

These fields are used by the driver to store and modify LGPTimer configuration during run-time. The application must not edit any member variables of this structure. Appplications should also not access member variables of this structure as backwards compatibility is not guaranteed. An example structure is shown below:

// LGPTimer objects, one per LGPT peripheral (LGPT0, LGPT1..)
LGPTimerLPF3_Object LGPTimerLPF3Objects[];

Enumeration Type Documentation

§ LGPTimerLPF3_ChannelNo

Definitions for supported LGPTimer channel numbers.

Enumerator
LGPTimerLPF3_CH_NO_0 
LGPTimerLPF3_CH_NO_1 
LGPTimerLPF3_CH_NO_2 

§ LGPTimerLPF3_ChannelDir

Definitions for supported LGPTimer channel direction.

Enumerator
LGPTimerLPF3_CH_DIR_NONE 
LGPTimerLPF3_CH_DIR_INPUT 
LGPTimerLPF3_CH_DIR_OUTPUT 

§ LGPTimerLPF3_ChannelLevel

Definitions for supported LGPTimer channel output levels.

Enumerator
LGPTimerLPF3_CH_LEVEL_LOW 
LGPTimerLPF3_CH_LEVEL_HIGH 

§ LGPTimerLPF3_ChannelInputEdge

Definitions for supported LGPTimer channel input edge.

Enumerator
LGPTimerLPF3_CH_EDGE_NONE 
LGPTimerLPF3_CH_EDGE_RISE 
LGPTimerLPF3_CH_EDGE_FALL 
LGPTimerLPF3_CH_EDGE_BOTH 

§ LGPTimerLPF3_Mode

Definitions for supported LGPTimer counting modes.

Enumerator
LGPTimerLPF3_CTL_MODE_DIS 

Disable timer. Updates to counter and events are stopped.

LGPTimerLPF3_CTL_MODE_UP_ONCE 

Count up one-shot. The timer increments from 0 to target value, then stops and sets MODE to LGPTimerLPF3_CTL_MODE_DIS.

LGPTimerLPF3_CTL_MODE_UP_PER 

Count up periodically. The timer increments from 0 to target value, repeatedly.

LGPTimerLPF3_CTL_MODE_UPDWN_PER 

Count up and down periodically. The timer counts from 0 to target value and back to 0, repeatedly.

§ LGPTimerLPF3_Interrupt

Definitions for supported LGPTimer interrupts. LGPTimerLPF3_IntMask arguments should be a bit vector containing these definitions.

Enumerator
LGPTimerLPF3_INT_TGT 

Timer counter target interrupt

LGPTimerLPF3_INT_ZERO 

Timer counter zero interrupt

LGPTimerLPF3_INT_COUNTER_CHANGE 

Timer counter increment/decrement interrupt

LGPTimerLPF3_INT_DIR_CHANGE 

Timer counter direction change interrupt

LGPTimerLPF3_INT_CH0_CC 

Channel 0 capture or compare interrupt

LGPTimerLPF3_INT_CH1_CC 

Channel 1 capture or compare interrupt

LGPTimerLPF3_INT_CH2_CC 

Channel 2 capture or compare interrupt

§ LGPTimerLPF3_DebugMode

Definitions for controlling timer debug stall mode.

Enumerator
LGPTimerLPF3_DEBUG_STALL_OFF 

The LGPT is not halted when CPU is halted in debug

LGPTimerLPF3_DEBUG_STALL_IMMEDIATE 

Halt LGPT immediatly when CPU is halted in debug

LGPTimerLPF3_DEBUG_STALL_ON_ZERO 

Halt LGPT when counter equals 0 while CPU is halted in debug

§ LGPTimerLPF3_ChannelCmpDir

Definitions for which direction the timer counter must have in order to set channel compare interrupt status flag.

Enumerator
LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_BOTH 

Channel compare interrupt status flag is set on up count and down count.

LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_UP 

Channel compare interrupt status flag is only set on up count

LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_DOWN 

Channel compare interrupt status flag is only set on down count

§ LGPTimerLPF3_ChannelAction

Definitions for supported LGPTimer channel actions.

Enumerator
LGPTimerLPF3_CH_DISABLE 

Channel disabled

LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_PERIODIC 

Toggle on compare repeatedly.

Toggle channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal().

LGPTimerLPF3_CH_TOGGLE_ON_COMPARE_ONCE 

Toggle on compare, and then disable channel.

Toggle channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal().

LGPTimerLPF3_CH_SET_ON_COMPARE_PERIODIC 

Set on compare repeatedly.

Set channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal().

LGPTimerLPF3_CH_SET_ON_COMPARE_ONCE 

Set on compare, and then disable channel.

Set channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal().

LGPTimerLPF3_CH_CLEAR_ON_COMPARE_PERIODIC 

Clear on compare repeatedly.

Clear channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal().

LGPTimerLPF3_CH_CLEAR_ON_COMPARE_ONCE 

Clear on compare, and then disable channel.

Clear channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal().

LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_CMP_PERIODIC 

Set on zero, toggle on compare repeatedly.

Set channel output when timer counter value equals zero. Toggle channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal().

LGPTimerLPF3_CH_SET_ON_0_TOGGLE_ON_COMPARE_ONCE 

Set on zero, toggle on compare, and then disable channel.

Set channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal().

LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_PERIODIC 

Clear on zero, toggle on compare repeatedly.

Clear channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal().

LGPTimerLPF3_CH_CLR_ON_0_TOGGLE_ON_COMPARE_ONCE 

Clear on zero, toggle on compare, and then disable channel.

Clear channel output when timer counter equals zero. Toggle channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal().

LGPTimerLPF3_CH_PULSE_ON_COMPARE_PERIODIC 

Pulse on compare repeatedly.

Pulse channel output when the timer counter equals the compare value set by either LGPTimerLPF3_setInitialChannelCompVal() or LGPTimerLPF3_setNextChannelCompVal(). The channel output is high for two timer clock periods.

LGPTimerLPF3_CH_PULSE_ON_COMPARE_ONCE 

Pulse on compare, and then disable channel.

Pulse channel output when the timer counter equals the compare value set by LGPTimerLPF3_setInitialChannelCompVal(). The channel output is high for two timer clock periods.

LGPTimerLPF3_CH_SET_ON_CAPTURE_PERIODIC 

Set on capture repeatedly.

The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the signal edge selected by the ch<x>InputEdge element in the LGPTimerLPF3_Params structure, is detected on the channel input signal.

LGPTimerLPF3_CH_SET_ON_CAPTURE_ONCE 

Set on capture, and then disable channel.

The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the signal edge selected by the ch<x>InputEdge element in the LGPTimerLPF3_Params structure, is detected on the channel input signal.

LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE 

Period and pulse width measurement.

Continuously capture period and pulse width of the channel input signal relative to the signal edge selected by the ch<x>InputEdge element in the LGPTimerLPF3_Params structure. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the signal period and pulse width have been captured. The period and pulse width are reported in numbers of counter ticks. The LGPTimerLPF3_getChCompareVal() function returns the measured period and the LGPTimerLPF3_getNextChCompareVal() functions returns the measured pulse width.

Note
Note that when selecting this channel action, LGPTimerLPF3_start() function must be called with either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER as function argument.
Note that the timer counter restarts regularly when this action is used, so other channel actions must be chosen with this in mind. The timer counter restarts when the period of the channel input signal has been captured.
If multiple channels are configured with this channel action, the measurements are not performed simultaneously on the channels. The measurements are done in a time-interleaved manner between the channels.

Signal property requirements for this channel action:

  • Signal Period >= 2 * (1 + params.prescalerDiv) * high frequency clock (CLKSVT) period.
  • Signal Period <= MAX(timer counter) * (1 + params.prescalerDiv) * high frequency clock (CLKSVT) period.
  • Signal low and high phase >= (1 + params.prescalerDiv) * high frequency clock (CLKSVT) period.

Function Documentation

§ LGPTimerLPF3_Params_init()

void LGPTimerLPF3_Params_init ( LGPTimerLPF3_Params params)

Function that initializes the LGPTimerLPF3_Params struct to its default values.

Parameters
[in]paramsAn pointer to LGPTimerLPF3_Params structure for initialization

Default values:

Parameter Default value
Interrupt callback fxn NULL
Interrupt phase late true
Prescaler division 0
Timer debug stall mode LGPTimerLPF3_DEBUG_STALL_OFF
Counter dir ch cmp LGPTimerLPF3_CH_COMPARE_COUNTER_DIR_BOTH
Channel 0 action LGPTimerLPF3_CH_DISABLE
Channel 0 input edge LGPTimerLPF3_CH_EDGE_NONE
Channel 1 action LGPTimerLPF3_CH_DISABLE
Channel 1 input edge LGPTimerLPF3_CH_EDGE_NONE
Channel 2 action LGPTimerLPF3_CH_DISABLE
Channel 2 input edge LGPTimerLPF3_CH_EDGE_NONE

§ LGPTimerLPF3_open()

LGPTimerLPF3_Handle LGPTimerLPF3_open ( uint_least8_t  index,
const LGPTimerLPF3_Params params 
)

Function that opens a driver for the given LGPT peripheral. Will set power dependency on timer and configure it into specified configuration.

Parameters
[in]indexIndex in the LGPTimerLPF3_config table.
[in]paramsPointer to a parameter block. If NULL, it will use default values.
Returns
A LGPTimerLPF3_Handle on success or NULL on an error or if it has been opened already. If NULL is returned, further LGPTimerLPF3 API calls will result in undefined behaviour.
See also
LGPTimerLPF3_close()

§ LGPTimerLPF3_close()

void LGPTimerLPF3_close ( LGPTimerLPF3_Handle  handle)

Function that closes a LGPTimer driver specified by the LGPTimer handle. Closing LGPTimer driver will release power dependency on timer and clear configuration.

Precondition
LGPTimerLPF3_open() has to be called first.
LGPTimerLPF3_stop() should to be called first if LGPTimer is started.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
See also
LGPTimerLPF3_open()
LGPTimerLPF3_start()
LGPTimerLPF3_stop()

§ LGPTimerLPF3_start()

void LGPTimerLPF3_start ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_Mode  mode 
)

Function that starts the timer counter of the specified LGPTimer handle with current settings and specified timer counter mode.

Note
The timer counter width may be 16, 24, or 32 bits depending on the LGPT instance (see LGPT peripheral properties).
When signal measurement (LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE) has been selected for one or more channels, the value of mode must be either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER.
Precondition
LGPTimerLPF3_open() has to be called first successfully.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open().
[in]modeThe timer counter mode.
Postcondition
LGPTimerLPF3_stop()

§ LGPTimerLPF3_stop()

void LGPTimerLPF3_stop ( LGPTimerLPF3_Handle  handle)

Function that stops the timer counter of the specified LGPTimer driver.

Precondition
LGPTimerLPF3_open() has to be called first successfully.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
See also
LGPTimerLPF3_open()
LGPTimerLPF3_start()

§ LGPTimerLPF3_setInitialCounterTarget()

void LGPTimerLPF3_setInitialCounterTarget ( LGPTimerLPF3_Handle  handle,
uint32_t  value,
bool  intFlagClr 
)

Function that sets the initial timer counter target on the specified LGPTimer. This function must be called before the timer is started. Timer counter width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties).

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]valueInitial target value of the timer counter. Max value: LGPT peripheral properties The number of counter ticks required to reach target value is value + 1. Note that if either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if LGPTimerLPF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2.
[in]intFlagClrControls if the LGPTimerLPF3_INT_TGT and LGPTimerLPF3_INT_ZERO interrupt status flags are cleared or not when this function is executed.
See also
LGPTimerLPF3_open()
LGPTimerLPF3_start()

§ LGPTimerLPF3_setNextCounterTarget()

void LGPTimerLPF3_setNextCounterTarget ( LGPTimerLPF3_Handle  handle,
uint32_t  value,
bool  intFlagClr 
)

Function that sets the timer counter target for the next counter period on the specified LGPTimer. The specified target value will be valid as timer counter target on the upcoming zero crossing. When counting repeatedly upwards a zero crossing is regarded as when the timer counter restarts counting from 0. This function can be called after the timer has started. Timer counter width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties).

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]valueNext target value of the timer counter. Max value Max value: LGPT peripheral properties" The number of counter ticks required to reach target value on the next counter period is value + 1. Note that if either LGPTimerLPF3_CTL_MODE_UP_ONCE or LGPTimerLPF3_CTL_MODE_UP_PER counter modes are used for generating a PWM signal, the signal period equals value + 1. Note that if LGPTimerLPF3_CTL_MODE_UPDWN_PER counter mode is used for generating a PWM signal, the signal period equals value * 2.
[in]intFlagClrControls if the LGPTimerLPF3_INT_TGT and LGPTimerLPF3_INT_ZERO interrupt status flags are cleared or not when this function is executed.
See also
LGPTimerLPF3_open()
LGPTimerLPF3_start()

§ LGPTimerLPF3_getCounter()

uint32_t LGPTimerLPF3_getCounter ( LGPTimerLPF3_Handle  handle)

Function that returns the current timer counter value.

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
Returns
The current timer counter value
See also
LGPTimerLPF3_open()

§ LGPTimerLPF3_getArg()

uint32_t LGPTimerLPF3_getArg ( LGPTimerLPF3_Handle  handle)

Function to get a custom argument.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setArg() has to be called first
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
Returns
The custom argument
See also
LGPTimerLPF3_setArg()
LGPTimerLPF3_open()

§ LGPTimerLPF3_setArg()

void LGPTimerLPF3_setArg ( LGPTimerLPF3_Handle  handle,
void *  arg 
)

Function to set a custom argument.

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]argPointer to a custom argument
See also
LGPTimerLPF3_getArg()
LGPTimerLPF3_open()

§ LGPTimerLPF3_enableInterrupt()

void LGPTimerLPF3_enableInterrupt ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_IntMask  intMask 
)

Enable interrupt source for the LGPTimer handle.

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]intMaskA bit mask of interrupt flags to enable

§ LGPTimerLPF3_disableInterrupt()

void LGPTimerLPF3_disableInterrupt ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_IntMask  intMask 
)

Disable interrupt source for the LGPTimer handle.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_enableInterrupt() has to be called first
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]intMaskA bit mask of interrupt flags to disable

§ LGPTimerLPF3_setInitialChannelCompVal()

void LGPTimerLPF3_setInitialChannelCompVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo,
uint32_t  value,
bool  intFlagClr 
)

Function that sets the initial channel compare value on the specified LGPTimer and channel. The compare value for the specified channel will be used by any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value. This function must be called prior to LGPTimerLPF3_start(). Timer compare value width (16, 24, or 32 bits) depends on selected peripheral instance (see LGPT peripheral properties).

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
[in]valueChannel compare value for specified channel number
[in]intFlagClrControls if the channel number dependent compare/capture interrupt status flag is cleared or not when this function is executed.
See also
LGPTimerLPF3_open()

§ LGPTimerLPF3_setNextChannelCompVal()

void LGPTimerLPF3_setNextChannelCompVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo,
uint32_t  value,
bool  intFlagClr 
)

Function that sets the channel compare value on the specified LGPTimer for the next cycle of the already started timer counter. The compare value for the specified channel is valid for any compare type channel action LGPTimerLPF3_ChannelAction specified by the LGPTimer params. The channel number dependent interrupt status flag (LGPTimerLPF3_INT_CH0_CC for channel number LGPTimerLPF3_CH_NO_0) will be set when the timer counter equals the channel compare value in the next and following timer counter cycles. This function can be called while the timer is active.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setInitialChannelCompVal() has to be called first successfully
LGPTimerLPF3_start() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
[in]valueChannel compare value for specified channel number. Width (16, 24, or 32 bits) of value depends on selected peripheral instance (see LGPT peripheral properties).
[in]intFlagClrControls if the channel number dependent compare/capture interrupt status flag is cleared or not when this function is executed.
See also
LGPTimerLPF3_open()
LGPTimerLPF3_setInitialChannelCompVal()

§ LGPTimerLPF3_setChannelOutputLevel()

void LGPTimerLPF3_setChannelOutputLevel ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo,
LGPTimerLPF3_ChannelLevel  level 
)

Function that manually sets the current channel output level high or low. Manual update of a channel output takes priority over automatic channel updates to the same output when occurring at the same time. The complementary channel output will be set to the complementary level of the specified level.

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
[in]levelChannel level for specified channel number
See also
LGPTimerLPF3_open()

§ LGPTimerLPF3_getChCompareVal()

uint32_t LGPTimerLPF3_getChCompareVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo 
)

Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setInitialChannelCompVal() has to be called first when channel compare action type is used.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
Returns
The compare value or input signal pulse width
See also
LGPTimerLPF3_open()
LGPTimerLPF3_setInitialChannelCompVal()

§ LGPTimerLPF3_getChCaptureVal()

uint32_t LGPTimerLPF3_getChCaptureVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo 
)

Function to get the channel compare value or channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the current channel compare value or the channel-updated capture value. The channel-updated capture value is returned if a successful channel capture event, as specified by the channel action, has occured on the specified channel. For a channel action of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful channel capture event, represents the measured period of the selected channel input signal.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setInitialChannelCompVal() has to be called first when channel compare action type is used.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
Returns
The compare value or input signal pulse width
See also
LGPTimerLPF3_open()
LGPTimerLPF3_setInitialChannelCompVal()

§ LGPTimerLPF3_getNextChCompareVal()

uint32_t LGPTimerLPF3_getNextChCompareVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo 
)

Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal should be used.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setInitialChannelCompVal() has to be called first when channel compare action type is used.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
Returns
The custom argument
See also
LGPTimerLPF3_open()
LGPTimerLPF3_setInitialChannelCompVal()

§ LGPTimerLPF3_getNextChCaptureVal()

uint32_t LGPTimerLPF3_getNextChCaptureVal ( LGPTimerLPF3_Handle  handle,
LGPTimerLPF3_ChannelNo  chNo 
)

Function to get the channel compare value for the next counter cycle or the channel-updated capture value. Dependent on the selected channel action for the specified channel, the function will return either the channel compare value for the next counter cycle or the channel-updated capture value. For a channel action mode of LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the returned value after a successful capture event will be the width of the low or high phase of the selected channel input signal. The phase is specified by LGPTimerLPF3_ChannelInputEdge parameter for the selected channel. In order to get the channel-updated capture value for other capture channel actions than LGPTimerLPF3_CH_PULSE_WIDTH_MEASURE, the function LGPTimerLPF3_getChCompareVal() should be used.

Precondition
LGPTimerLPF3_open() has to be called first successfully
LGPTimerLPF3_setInitialChannelCompVal() has to be called first when channel compare action type is used.
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
[in]chNoChannel number
Returns
The custom argument
See also
LGPTimerLPF3_open()
LGPTimerLPF3_setInitialChannelCompVal()

§ LGPTimerLPF3_getCounterWidth()

uint32_t LGPTimerLPF3_getCounterWidth ( LGPTimerLPF3_Handle  handle)

Function to get the width of the timer counter in number of bits.

Precondition
LGPTimerLPF3_open() has to be called first successfully
Parameters
[in]handleA LGPTimerLPF3_Handle returned from LGPTimerLPF3_open()
Returns
The timer counter width in number of bits
See also
LGPTimerLPF3_open()
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale