AM64x MCU+ SDK
10.01.00
The General-Purpose Timer driver provides APIs to configure the available timer modules in multiple modes.
Features Supported
Interrupts generated on overflow, compare, and capture
Free-running 32-bit upward counter
Compare and capture modes
Autoreload mode
Start/stop mode
Programmable divider clock source (2 exponent n, where n = [0-8])
Dedicated input trigger for capture mode and dedicated output trigger/PWM signal
On-the-fly read/write register
SysConfig Features
Note It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
Set mode of operation of the timer
Enable/Disable and Set counter Prescaler
Enable/Disable Auto reload Mode and set Auto reload Value
Enable Interrupt and Assign User Callback
Set Compare value when Compare Match mode is set
Set Counter mode and Capture event when Timer configured to capture input
Set PWM output Trigger mode and Compare Value in PWM mode
Set Default Output Polarity in PWM mode
Set Output Pin Modulation in PWM mode
Features NOT Supported
Atomic 64-bit timer value read of cascaded timers
Smart-idle with wake-up mode
Example Usage
Include the below file to access the APIs
Instance Open Example
gGpTimerObjects[CONFIG_GPTIMER0].overflowCallbackFunction = NULL,
gGpTimerObjects[CONFIG_GPTIMER0].compareMatchCallbackFunction = NULL,
gGpTimerObjects[CONFIG_GPTIMER0].captureCallbackFunction = NULL,
Instance Close Example
GPTIMER configuration in Free Running Mode without interrupt
void gptimer_free_run_no_interrupt(void )
{
uint32_t conifgMode;
(void *)NULL);
}
GPTIMER configuration in Free Running Mode with interrupt
{
}
void gptimer_free_run_interrupt(void )
{
uint32_t conifgMode;
(void *)NULL);
}
GPTIMER configuration in Output Compare Mode
{
}
void gptimer_output_compare_interrupt(void )
{
uint32_t conifgMode;
compareConfig.cntCompareValComp = (0x017D7840U);
(void *)(&compareConfig));
}
GPTIMER configuration in Input Capture Mode
{
}
void gptimer_input_capture_interrupt(void )
{
uint32_t conifgMode;
(void *)(&inputCaptureConfig));
}
GPTIMER configuration in PWM Generation Mode
void gptimer_pwm_gen(void )
{
uint32_t conifgMode;
pwmConfig.cntCompareValPWM = 4294954795,
(void *)(&pwmConfig));
}
API
APIs for GPTIMER
#define GPTIMER_INPUT_CAPTURE_MODE_SECOND
Capture Two Events.
Definition: gp_timer/v0/gp_timer.h:93
int32_t GPTIMER_setTimerConfigMode(GPTIMER_Handle handle, uint32_t timerConfigMode, void *config)
Change Timer Configuration.
void GPTIMER_setCallbackFxn(GPTIMER_Handle handle, GPTIMER_OverflowCallbackFxn overflowCbFxn, GPTIMER_CompareMatchCallbackFxn compMatchCbFxn, GPTIMER_CaptureCallbackFxn captureCbFxn)
Update Callback Functions.
#define GPTIMER_MODE_CONFIG_OUTPUT_COMPARE
Output Compare Mode.
Definition: gp_timer/v0/gp_timer.h:78
struct GPTIMER_Config_s * GPTIMER_Handle
A handle that is returned from a GPTIMER_open() call.
Definition: gp_timer/v0/gp_timer.h:178
#define GPTIMER_PWM_OUT_PIN_DEFAULT_0
Pin Default value 0.
Definition: gp_timer/v0/gp_timer.h:136
#define GPTIMER_MODE_CONFIG_PWM_GEN
PWM Generation Mode.
Definition: gp_timer/v0/gp_timer.h:80
#define GPTIMER_PWM_OUT_OVERFLOW_MATCH_TRIGGER
PWM uses overflow and compare match as a trigger.
Definition: gp_timer/v0/gp_timer.h:125
void GPTIMER_start(GPTIMER_Handle handle)
Start the Timer.
#define SystemP_WAIT_FOREVER
Value to use when needing a timeout of infinity or wait forver until resource is available.
Definition: SystemP.h:83
#define GPTIMER_MODE_CONFIG_FREE_RUN
Free Running Mode.
Definition: gp_timer/v0/gp_timer.h:74
bool oneShotMode
Definition: gp_timer/v0/gp_timer.h:260
uint32_t overflowMaskCount
Definition: gp_timer/v0/gp_timer.h:264
void SemaphoreP_destruct(SemaphoreP_Object *obj)
Cleanup, delete, destruct a semaphore object.
bool enablePrescaler
Definition: gp_timer/v0/gp_timer.h:256
void GPTIMER_Params_init(GPTIMER_Params *params)
Function to set default values of GPTIMER_Params in params.
#define GPTIMER_PWM_OUT_PIN_MODULATION_TOGGLE
Pin Modulation type Toggle.
Definition: gp_timer/v0/gp_timer.h:155
uint32_t cntPrescaler
Definition: gp_timer/v0/gp_timer.h:258
GPTIMER Parameters.
Definition: gp_timer/v0/gp_timer.h:253
void SemaphoreP_post(SemaphoreP_Object *obj)
Post a semaphore object or unlock a mutex.
uint32_t counterInitVal
Definition: gp_timer/v0/gp_timer.h:266
#define GPTIMER_INPUT_CAPTURE_EVENT_EDGE
Capture Event on both rising and falling edge.
Definition: gp_timer/v0/gp_timer.h:110
int32_t SemaphoreP_constructBinary(SemaphoreP_Object *obj, uint32_t initValue)
Create a binary semaphore object.
#define GPTIMER_MODE_CONFIG_INPUT_CAPTURE
Input Capture Mode.
Definition: gp_timer/v0/gp_timer.h:76
uint32_t cntReloadVal
Definition: gp_timer/v0/gp_timer.h:262
void GPTIMER_close(GPTIMER_Handle handle)
Function to close the GPTIMER Peripheral specified by the handle.
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:177
GPTIMER_Handle GPTIMER_open(uint32_t idx, const GPTIMER_Params *params)
Open the GPTIMER at index idx with parameters params.
int32_t SemaphoreP_pend(SemaphoreP_Object *obj, uint32_t timeToWaitInTicks)
Pend on a semaphore object or lock a mutex.