module ti.sysbios.timers.timer64.Timer

Timer Peripheral Manager

This Timer module manages the timer64 peripheral available on many devices. It is supported on the ARM and c64x+ DSP targets. This module supports the timer in '32-bit chained' and '32-bit unchained' mode. In the '32-bit unchained' mode, specify the lower or upper half to be used. The physical timer being used will be taken out of reset, only when its specified to be the master. [ more ... ]
C synopsis target-domain sourced in ti/sysbios/timers/timer64/Timer.xdc
#include <ti/sysbios/timers/timer64/Timer.h>
Functions
Void
Void
Void
Void
Void 
Functions common to all ITimer modules
UInt32 
Void 
UInt 
UInt32 
Void 
Void 
Bool 
Void 
Void 
Functions common to all target instances
Functions common to all target modules
Defines
#define
#define
Typedefs
typedef struct
typedef struct
typedef Void 
typedef struct
typedef struct
typedef enum
typedef Timer_Object *
typedef struct
typedef enum
typedef struct
typedef struct
typedef enum
typedef enum
typedef enum
typedef enum
typedef struct
typedef struct
Constants
extern const Bits32 
extern const Bits32 
extern const Assert_Id 
extern const Timer_Half 
extern const Error_Id 
extern const Error_Id 
extern const Error_Id 
extern const Timer_TimerSetting 
 
DETAILS
This Timer module manages the timer64 peripheral available on many devices. It is supported on the ARM and c64x+ DSP targets. This module supports the timer in '32-bit chained' and '32-bit unchained' mode. In the '32-bit unchained' mode, specify the lower or upper half to be used. The physical timer being used will be taken out of reset, only when its specified to be the master.
For shared timers on a homogeneous multicore device (ie. c6472), each core can create the timer, but only one core will initialize the timer and take it out of reset. The core that does the initialization can be specified by the module configuration parameter timerSettings[].ownerCoreId in the *.cfg file. By default, Core 0 is the owner for all shared timers.
Note: Creating a timer with 'Timer.ANY' specified as the id will not return a shared timer on a homogeneous multicore device. To use a shared timer, specify the timer id explicitly when creating it. On these devices Timer.ANY specifies the local timer id. This allows a single image to run on multiple cores since each core will program a different local timer.
The following sample .cfg code sets core 1 to initialize a shared timer with id 4.
  var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');

  // sets core 1 to init and release Timer 4.
  Timer.timerSettings[4].ownerCoreId = 1;
The following sample .cfg code sets core 0 to initialize a shared timer with id 4. It also configures the Clock module to use this timer. This allows multiple cores to share timer 4 for the Clock module's interrupt source.
  // sets core 0 to init and release Timer 4.
  var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
  Timer.timerSettings[4].ownerCoreId = 0;

  var Clock = xdc.useModule('ti.sysbios.knl.Clock');
  Clock.timerId = 4;

Calling Context

Function Hwi Swi Task Main Startup
getNumTimers Y Y Y Y N
getStatus Y Y Y Y N
Params_init Y Y Y Y N
construct Y Y Y Y N
create N N Y Y N
delete N N Y Y N
destruct Y Y Y Y N
getCount Y Y Y N N
getFreq Y Y Y Y N
getFunc Y Y Y Y N
getPeriod Y Y Y Y N
reconfig Y Y Y Y N
setFunc Y Y Y Y N
setPeriod Y Y Y Y N
setPeriodMicroSecs Y Y Y Y N
start Y Y Y N N
stop Y Y Y N N
Definitions:
  • Hwi: API is callable from a Hwi thread.
  • Swi: API is callable from a Swi thread.
  • Task: API is callable from a Task thread.
  • Main: API is callable during any of these phases:
    • In your module startup after this module is started (e.g. Timer_Module_startupDone() returns TRUE).
    • During xdc.runtime.Startup.lastFxns.
    • During main().
    • During BIOS.startupFxns.
  • Startup: API is callable during any of these phases:
    • During xdc.runtime.Startup.firstFxns.
    • In your module startup before this module is started (e.g. Timer_Module_startupDone() returns FALSE).

Timer Mapping Tables

The Timer module allows the user to use and configure the various timers that exist on a particular device. This is achieved by specifying a timer ID when calling ti.sysbios.hal.Timer.Timer_create. However, the timer ID specified may not always map to that timer; for example, specifying an ID value of 1 does not necessarily mean that this will map to "GPTimer1". These tables are provided to show which timers map to which timer IDs.

Timer Mapping Tables
 
const Timer_ANY

Const used to specify any timer

C synopsis target-domain
#define Timer_ANY (UInt)~0
 
 
const Timer_MAX_PERIOD

Max value of Timer period for PeriodType_COUNTS

C synopsis target-domain
#define Timer_MAX_PERIOD (UInt)0xffffffff
 
 
enum Timer_Half

In 32-bit modes, used to specify which half of Timer to use

C synopsis target-domain
typedef enum Timer_Half {
    Timer_Half_LOWER,
    Timer_Half_UPPER,
    Timer_Half_DEFAULT
} Timer_Half;
 
 
enum Timer_Mode

The different modes of the Timer. These values match the TIMMODE bit fields of the Timer Global Control Register

C synopsis target-domain
typedef enum Timer_Mode {
    Timer_Mode_64BITGPTIMER,
    Timer_Mode_UNCHAINED,
    Timer_Mode_WATCHDOG,
    Timer_Mode_CHAINED
} Timer_Mode;
 
 
enum Timer_PeriodType

Timer period units

C synopsis target-domain
typedef enum Timer_PeriodType {
    Timer_PeriodType_MICROSECS,
    // period in microsecs
    Timer_PeriodType_COUNTS
    // period in counts
} Timer_PeriodType;
 
VALUES
PeriodType_MICROSECS — Period value is in microseconds.
PeriodType_COUNTS — Period value is in counts.
 
enum Timer_RunMode

Timer Run Modes

C synopsis target-domain
typedef enum Timer_RunMode {
    Timer_RunMode_CONTINUOUS,
    // periodic and continuous
    Timer_RunMode_ONESHOT,
    // one-shot
    Timer_RunMode_DYNAMIC
    // dynamically reprogrammed (available on subset of devices)
} Timer_RunMode;
 
VALUES
RunMode_CONTINUOUS — Timer is periodic and runs continuously.
RunMode_ONESHOT — Timer runs for a single period value and stops.
RunMode_DYNAMIC — Timer is dynamically reprogrammed for the next required tick. This mode is intended only for use by the Clock module when it is operating in TickMode_DYNAMIC; it is not applicable for user-created Timer instances.
 
enum Timer_StartMode

Timer Start Modes

C synopsis target-domain
typedef enum Timer_StartMode {
    Timer_StartMode_AUTO,
    // timer starts automatically
    Timer_StartMode_USER
    // timer will be started by user
} Timer_StartMode;
 
VALUES
StartMode_AUTO — Statically created/constructed Timers will be started in BIOS_start(). Dynamically created Timers will start at create() time. This includes timers created before BIOS_start().
StartMode_USER — Timer will be started by the user using start().
 
enum Timer_Status

Timer Status

C synopsis target-domain
typedef enum Timer_Status {
    Timer_Status_INUSE,
    // timer in use
    Timer_Status_FREE
    // timer is free
} Timer_Status;
 
VALUES
Status_INUSE — Timer is in use. A timer is marked in use from the time it gets created to the time it gets deleted.
Status_FREE — Timer is free and can be acquired using create.
 
typedef Timer_FuncPtr

Timer tick function prototype

C synopsis target-domain
typedef Void (*Timer_FuncPtr)(UArg);
 
 
struct Timer_Control

Timer Control Register struct

C synopsis target-domain
typedef struct Timer_Control {
    Bits8 tien;
    // 0=Clock not gated by TINP; 1=Clock gated
    Bits8 invout;
    // 0=Uninverted TSTAT drives TOUT; 1=Inverted TSTAT
    Bits8 invin;
    // 0=Uninverted TINP drives Timer; 1=Inverted TINP
    UInt8 pwid;
    // TSTATx goes inactive after pwid cycles (CP=0)
    Bits8 cp;
    // 0=pulse mode; 1=clock mode
} Timer_Control;
 
 
struct Timer_EmuMgt

Timer Emulation Management Register struct

C synopsis target-domain
typedef struct Timer_EmuMgt {
    Bool free;
    // 0=suspend for emu halt; 1=don't suspend
    Bool soft;
    // 0=stop immediately; 1=stop when count==period
} Timer_EmuMgt;
 
 
struct Timer_GpioDatDir

Timer GPIO Data and Direction Management Register struct

C synopsis target-domain
typedef struct Timer_GpioDatDir {
    Bits8 gpio_dati12;
    // 0=TINP12 is input; 1=TINP12 is output
    Bits8 gpio_dato12;
    // 0=TOUTP12 is input; 1=TOUTP12 is output
    Bits8 gpio_dati34;
    // 0=TINP34 is input; 1=TINP34 is output
    Bits8 gpio_dato34;
    // 0=TOUTP34 is input; 1=TOUTP34 is output
    Bits8 gpio_diri12;
    // 0=input as GPIO input; 1=input as GPIO output
    Bits8 gpio_diro12;
    // 0=output as GPIO input;1=output as GPIO output
    Bits8 gpio_diri34;
    // 0=input as GPIO input; 1=input as GPIO output
    Bits8 gpio_diro34;
    // 0=output as GPIO input;1=output as GPIO output
} Timer_GpioDatDir;
 
 
struct Timer_GpioIntEn

Timer GPIO interrupt control and enable Management Register struct

C synopsis target-domain
typedef struct Timer_GpioIntEn {
    Bits8 gpint12_eni;
    // 0=source by timer; 1=input to source event
    Bits8 gpint12_eno;
    // 0=source by timer; 1=output to source event
    Bits8 gpint12_invi;
    // 0=don't invert invput; 1=invert input
    Bits8 gpint12_invo;
    // 0=don't invert output; 1=invert output
    Bits8 gpint34_eni;
    // 0=source by timer; 1=input to source event
    Bits8 gpint34_eno;
    // 0=source by timer; 1=output to source event
    Bits8 gpint34_invi;
    // 0=don't invert invput; 1=invert input
    Bits8 gpint34_invo;
    // 0=don't invert output; 1=invert output
    Bits8 gpio_eni12;
    // 0=TINP12 as timer input; 1=TINP12 as GPIO
    Bits8 gpio_eno12;
    // 0=TOUTP12 as timer output; 1=TOUTP12 as GPIO
    Bits8 gpio_eni34;
    // 0=TINP34 as timer input; 1=TINP34 as GPIO
    Bits8 gpio_eno34;
    // 0=TOUTP34 as timer output; 1=TOUTP12 as GPIO
} Timer_GpioIntEn;
 
 
struct Timer_IntCtl

Timer interrupt control struct

C synopsis target-domain
typedef struct Timer_IntCtl {
    Bool prdinten_hi;
    // 0=Disable interrupt; 1=Enable interrupt
    Bool prdinten_lo;
    // 0=Disable interrupt; 1=Enable interrupt
} Timer_IntCtl;
 
 
struct Timer_TimerSetting

Timer Settings

C synopsis target-domain
typedef struct Timer_TimerSetting {
    Timer_Mode mode;
    // mode to put each Timer into
    Bool master;
    // for 'unchained' mode; 1=set mode and reset
    UInt16 ownerCoreId;
    // used only for homogeneous multicore DSPs
} Timer_TimerSetting;
 
 
config Timer_A_notAvailable  // module-wide

Assert raised when static created timer is not available

C synopsis target-domain
extern const Assert_Id Timer_A_notAvailable;
 
 
config Timer_E_cannotSupport  // module-wide

Error raised when period requested is not supported

C synopsis target-domain
extern const Error_Id Timer_E_cannotSupport;
 
 
config Timer_E_invalidTimer  // module-wide

Error raised when timer id specified is not supported

C synopsis target-domain
extern const Error_Id Timer_E_invalidTimer;
 
 
config Timer_E_notAvailable  // module-wide

Error raised when timer requested is in use

C synopsis target-domain
extern const Error_Id Timer_E_notAvailable;
 
 
config Timer_anyMask  // module-wide

Available mask to be used when select = Timer_ANY for timer id < 16. Set in xs file

C synopsis target-domain
extern const Bits32 Timer_anyMask;
 
 
config Timer_anyMaskHigh  // module-wide

Available mask to be used when select = Timer_ANY for timer id >= 16. Set in xs file

C synopsis target-domain
extern const Bits32 Timer_anyMaskHigh;
 
 
config Timer_defaultHalf  // module-wide

The default 32-bit half of the timer to be used

C synopsis target-domain
extern const Timer_Half Timer_defaultHalf;
 
 
config Timer_timerSettings  // module-wide

Global Control configuration for each physical timer

C synopsis target-domain
extern const Timer_TimerSetting Timer_timerSettings[];
 
DETAILS
mode: Mode_UNCHAINED 32-bit unchained mode. master: TRUE If TRUE, release Timer from reset.
 
Timer_getNumTimers()  // module-wide

Returns number of timer peripherals on the platform

C synopsis target-domain
UInt Timer_getNumTimers();
 
RETURNS
Number of timer peripherals.
 
Timer_getStatus()  // module-wide

Returns timer status (free or in use)

C synopsis target-domain
ITimer_Status Timer_getStatus(UInt id);
 
RETURNS
timer status
Module-Wide Built-Ins

C synopsis target-domain
Types_ModuleId Timer_Module_id();
// Get this module's unique id
 
Bool Timer_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle Timer_Module_heap();
// The heap from which this module allocates memory
 
Bool Timer_Module_hasMask();
// Test whether this module has a diagnostics mask
 
Bits16 Timer_Module_getMask();
// Returns the diagnostics mask for this module
 
Void Timer_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types

C synopsis target-domain
typedef struct Timer_Object Timer_Object;
// Opaque internal representation of an instance object
 
typedef Timer_Object *Timer_Handle;
// Client reference to an instance object
 
typedef struct Timer_Struct Timer_Struct;
// Opaque client structure large enough to hold an instance object
 
Timer_Handle Timer_handle(Timer_Struct *structP);
// Convert this instance structure pointer into an instance handle
 
Timer_Struct *Timer_struct(Timer_Handle handle);
// Convert this instance handle into an instance structure pointer
Instance Config Parameters

C synopsis target-domain
typedef struct Timer_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
    UArg arg;
    // Argument for tick function
    Timer_Control controlInit;
    // Control configuration. Default is all fields 0 or false except:
    Timer_EmuMgt emuMgtInit;
    // Emulation Management configuration. Default is:
    Types_FreqHz extFreq;
    // Timer frequency
    Timer_GpioDatDir gpioDatDir;
    // General Purpose IO data and direction Management configuration The default is all fields is 0
    Timer_GpioIntEn gpioIntEn;
    // General Purpose IO interrupt control and enable Management configuration. The default for all fields is 0
    Timer_Half half;
    // In 32-bit unchained mode, this field is used to specify which half of the timer to use
    Hwi_Params *hwiParams;
    // Hwi Params for Hwi Object. Default is null
    Timer_IntCtl intCtl;
    // Timer interrupt control struct
    Int intNum;
    // Hwi interrupt number to be used by Timer
    UInt32 period;
    // Period of a tick
    ITimer_PeriodType periodType;
    // Period type
    UInt prescalar;
    // 32-bit pre-scalar to TIM12 in '32-bit chained' mode. The default is 0
    ITimer_RunMode runMode;
    // Timer run mode
    ITimer_StartMode startMode;
    // Timer start mode
} Timer_Params;
 
Void Timer_Params_init(Timer_Params *params);
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
config Timer_Params.arg  // instance

Argument for tick function

C synopsis target-domain
struct Timer_Params {
      ...
    UArg arg;
 
DETAILS
Default is null.
 
config Timer_Params.controlInit  // instance

Control configuration. Default is all fields 0 or false except:

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_Control controlInit;
 
DETAILS
pwid: 1
 
config Timer_Params.emuMgtInit  // instance

Emulation Management configuration. Default is:

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_EmuMgt emuMgtInit;
 
DETAILS
free: 0 soft: 0
 
config Timer_Params.extFreq  // instance

Timer frequency

C synopsis target-domain
struct Timer_Params {
      ...
    Types_FreqHz extFreq;
 
DETAILS
This parameter is meaningfull only on platforms where the timer's input clock can be changed. If value is left at zero, then input clock to the timer clock is assumed.
This value is used to convert timer ticks to real time units; seconds, milliseconds, etc.
 
config Timer_Params.gpioDatDir  // instance

General Purpose IO data and direction Management configuration The default is all fields is 0

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_GpioDatDir gpioDatDir;
 
 
config Timer_Params.gpioIntEn  // instance

General Purpose IO interrupt control and enable Management configuration. The default for all fields is 0

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_GpioIntEn gpioIntEn;
 
 
config Timer_Params.half  // instance

In 32-bit unchained mode, this field is used to specify which half of the timer to use

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_Half half;
 
 
config Timer_Params.hwiParams  // instance

Hwi Params for Hwi Object. Default is null

C synopsis target-domain
struct Timer_Params {
      ...
    Hwi_Params *hwiParams;
 
 
config Timer_Params.intCtl  // instance

Timer interrupt control struct

C synopsis target-domain
struct Timer_Params {
      ...
    Timer_IntCtl intCtl;
 
 
config Timer_Params.intNum  // instance

Hwi interrupt number to be used by Timer

C synopsis target-domain
struct Timer_Params {
      ...
    Int intNum;
 
 
config Timer_Params.period  // instance

Period of a tick

C synopsis target-domain
struct Timer_Params {
      ...
    UInt32 period;
 
DETAILS
The period can be specified in timer counts or microseconds and its default value is 0.
The implementation of ITimer will support a period of UInt32 timer counts and use pre-scalars if necessary.
 
config Timer_Params.periodType  // instance

Period type

C synopsis target-domain
struct Timer_Params {
      ...
    ITimer_PeriodType periodType;
 
DETAILS
Default is PeriodType_MICROSECS
 
config Timer_Params.prescalar  // instance

32-bit pre-scalar to TIM12 in '32-bit chained' mode. The default is 0

C synopsis target-domain
struct Timer_Params {
      ...
    UInt prescalar;
 
 
config Timer_Params.runMode  // instance

Timer run mode

C synopsis target-domain
struct Timer_Params {
      ...
    ITimer_RunMode runMode;
 
DETAILS
Default is RunMode_CONTINUOUS.
 
config Timer_Params.startMode  // instance

Timer start mode

C synopsis target-domain
struct Timer_Params {
      ...
    ITimer_StartMode startMode;
 
DETAILS
Default is StartMode_AUTO.
Runtime Instance Creation

C synopsis target-domain
Timer_Handle Timer_create(Int id, ITimer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb);
// Allocate and initialize a new instance object and return its handle
 
Void Timer_construct(Timer_Struct *structP, Int id, ITimer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb);
// Initialize a new instance object inside the provided structure
ARGUMENTS
id — Timer id ranging from 0 to a platform specific value, or ANY
tickFxn — function that runs upon timer expiry.
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
Create could fail if timer peripheral is unavailable. To request any available timer use ANY as the id. TimerId's are logical ids. The family-specific implementations map the ids to physical peripherals.
Instance Deletion

C synopsis target-domain
Void Timer_delete(Timer_Handle *handleP);
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void Timer_destruct(Timer_Struct *structP);
// Finalize the instance object inside the provided structure
 
Timer_getCount()  // instance

Read timer counter register

C synopsis target-domain
UInt32 Timer_getCount(Timer_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
RETURNS
timer counter value
 
Timer_getFreq()  // instance

Return timer frequency in Hz

C synopsis target-domain
Void Timer_getFreq(Timer_Handle handle, Types_FreqHz *freq);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
freq — frequency in Hz
DETAILS
This is the effective frequency of the clock incrementing the timer counter register after all scaling factors are taken into account. (including pre-scalars).
 
Timer_getFunc()  // instance

Get Timer function and arg

C synopsis target-domain
ITimer_FuncPtr Timer_getFunc(Timer_Handle handle, UArg *arg);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
arg — pointer for returning Timer's function argument
RETURNS
Timer's function
 
Timer_getPeriod()  // instance

Get timer period in timer counts

C synopsis target-domain
UInt32 Timer_getPeriod(Timer_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
RETURNS
period in timer counts
 
Timer_reconfig()  // instance

Used to modify static timer instances at runtime

C synopsis target-domain
Void Timer_reconfig(Timer_Handle handle, Timer_FuncPtr tickFxn, Timer_Params *timerParams, Error_Block *eb);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
timerParams — timer Params
tickFxn — functions that runs when timer expires
 
Timer_setFunc()  // instance

Overwrite Timer function and arg

C synopsis target-domain
Void Timer_setFunc(Timer_Handle handle, ITimer_FuncPtr fxn, UArg arg);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
fxn — pointer to function
arg — argument to function
DETAILS
Replaces a Timer object's tickFxn function originally provided in create.
 
Timer_setPeriod()  // instance

Set timer period specified in timer counts

C synopsis target-domain
Void Timer_setPeriod(Timer_Handle handle, UInt32 period);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
period — period in timer counts
DETAILS
Timer_setPeriod() invokes Timer_stop() prior to setting the period and leaves the timer in the stopped state.
To dynamically change the period of a timer you must protect against re-entrancy by disabling interrupts. Use the following call sequence to guarantee proper results:
  // disable interrupts if an interrupt could lead to
  // another call to Timer_start().
  key = Hwi_disable();
  Timer_setPeriod(period);
  Timer_start();
  Hwi_restore(key);
ITimer implementation must support UInt32 and use pre-scalars whenever necessary
SIDE EFFECTS
Calls Timer_stop(), and disables the timer's interrupt.
 
Timer_setPeriodMicroSecs()  // instance

Set timer period specified in microseconds

C synopsis target-domain
Bool Timer_setPeriodMicroSecs(Timer_Handle handle, UInt32 microsecs);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
period — period in microseconds
DETAILS
A best-effort method will be used to set the period register. There might be a slight rounding error based on resolution of timer period register. If the timer frequency cannot support the requested period, i.e. the timer period register cannot support the requested period, then this function returns false.
Timer_setPeriodMicroSecs() invokes Timer_stop() prior to setting the period and leaves the timer in the stopped state.
To dynamically change the period of a timer you must protect against re-entrancy by disabling interrupts. Use the following call sequence to guarantee proper results:
  // disable interrupts if an interrupt could lead to
  // another call to Timer_start().
  key = Hwi_disable();
  Timer_setPeriodMicroSecs(period);
  Timer_start();
  Hwi_restore(key);
 
Timer_start()  // instance

Reload and start the timer

C synopsis target-domain
Void Timer_start(Timer_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
DETAILS
Thread safety must be observed when using the start and stop APIs to avoid possible miss- configuration of the timers and unintended behaviors. To protect against re-entrancy, surround the start/stop invocations with Hwi_disable() and Hwi_restore() calls:
  // disable interrupts if an interrupt could lead to
  // another call to Timer_start().
  key = Hwi_disable();
  Timer_stop();
  ...
  Timer_start();
  Hwi_restore(key);
SIDE EFFECTS
Enables the timer's interrupt.
 
Timer_stop()  // instance

Stop the timer

C synopsis target-domain
Void Timer_stop(Timer_Handle handle);
 
ARGUMENTS
handle — handle of a previously-created Timer instance object
DETAILS
Thread safety must be observed when using the start and stop APIs to avoid possible miss- configuration of the timers and unintended behaviors. To protect against re-entrancy, surround the start/stop invocations with Hwi_disable() and Hwi_restore() calls:
  // disable interrupts if an interrupt could lead to
  // another call to Timer_start().
  key = Hwi_disable();
  Timer_stop();
  ...
  Timer_start();
  Hwi_restore(key);
SIDE EFFECTS
Disables the timer's interrupt.
Instance Convertors

C synopsis target-domain
ITimer_Handle Timer_Handle_upCast(Timer_Handle handle);
// unconditionally move one level up the inheritance hierarchy
 
Timer_Handle Timer_Handle_downCast(ITimer_Handle handle);
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins

C synopsis target-domain
Int Timer_Object_count();
// The number of statically-created instance objects
 
Timer_Handle Timer_Object_get(Timer_Object *array, Int i);
// The handle of the i-th statically-created instance object (array == NULL)
 
Timer_Handle Timer_Object_first();
// The handle of the first dynamically-created instance object, or NULL
 
Timer_Handle Timer_Object_next(Timer_Handle handle);
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle Timer_Object_heap();
// The heap used to allocate dynamically-created instance objects
 
Types_Label *Timer_Handle_label(Timer_Handle handle, Types_Label *buf);
// The label associated with this instance object
 
String Timer_Handle_name(Timer_Handle handle);
// The name of this instance object
 
Configuration settings sourced in ti/sysbios/timers/timer64/Timer.xdc
var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
module-wide constants & types
 
        const Timer.Half_LOWER;
        const Timer.Half_UPPER;
        const Timer.Half_DEFAULT;
 
        const Timer.Mode_64BITGPTIMER;
        const Timer.Mode_UNCHAINED;
        const Timer.Mode_WATCHDOG;
        const Timer.Mode_CHAINED;
 
 
    values of type Timer.RunMode// Timer Run Modes
        const Timer.RunMode_ONESHOT// one-shot;
 
    values of type Timer.StartMode// Timer Start Modes
 
    values of type Timer.Status// Timer Status
        const Timer.Status_INUSE// timer in use;
        const Timer.Status_FREE// timer is free;
 
        obj.tien// 0=Clock not gated by TINP; 1=Clock gated = Bits8  ...
        obj.pwid// TSTATx goes inactive after pwid cycles (CP=0) = UInt8  ...
        obj.cp// 0=pulse mode; 1=clock mode = Bits8  ...
 
        obj.free// 0=suspend for emu halt; 1=don't suspend = Bool  ...
        obj.soft// 0=stop immediately; 1=stop when count==period = Bool  ...
 
        obj.gpio_dati12// 0=TINP12 is input; 1=TINP12 is output = Bits8  ...
        obj.gpio_dato12// 0=TOUTP12 is input; 1=TOUTP12 is output = Bits8  ...
        obj.gpio_dati34// 0=TINP34 is input; 1=TINP34 is output = Bits8  ...
        obj.gpio_dato34// 0=TOUTP34 is input; 1=TOUTP34 is output = Bits8  ...
 
        obj.gpint12_invi// 0=don't invert invput; 1=invert input = Bits8  ...
        obj.gpint12_invo// 0=don't invert output; 1=invert output = Bits8  ...
        obj.gpint34_invi// 0=don't invert invput; 1=invert input = Bits8  ...
        obj.gpint34_invo// 0=don't invert output; 1=invert output = Bits8  ...
        obj.gpio_eni12// 0=TINP12 as timer input; 1=TINP12 as GPIO = Bits8  ...
        obj.gpio_eni34// 0=TINP34 as timer input; 1=TINP34 as GPIO = Bits8  ...
 
        obj.prdinten_hi// 0=Disable interrupt; 1=Enable interrupt = Bool  ...
        obj.prdinten_lo// 0=Disable interrupt; 1=Enable interrupt = Bool  ...
 
    var obj = new Timer.TimerSetting// Timer Settings;
        obj.mode// mode to put each Timer into = Timer.Mode  ...
        obj.master// for 'unchained' mode; 1=set mode and reset = Bool  ...
        obj.ownerCoreId// used only for homogeneous multicore DSPs = UInt16  ...
module-wide config parameters
        msg: "A_notAvailable: static created timer not available"
    };
        msg: "E_cannotSupport: Timer cannot support requested period %d"
    };
        msg: "E_invalidTimer: Invalid Timer Id %d"
    };
        msg: "E_notAvailable: Timer not available %d"
    };
 
per-instance config parameters
    var params = new Timer.Params// Instance config-params object;
        params.arg// Argument for tick function = UArg null;
            tien: 0,
            invout: 0,
            invin: 0,
            pwid: 1,
            cp: 0
        };
            free: 0,
            soft: 0
        };
        params.extFreq// Timer frequency = Types.FreqHz {
            lo: 0,
            hi: 0
        };
            gpio_dati12: 0,
            gpio_dato12: 0,
            gpio_dati34: 0,
            gpio_dato34: 0,
            gpio_diri12: 0,
            gpio_diro12: 0,
            gpio_diri34: 0,
            gpio_diro34: 0
        };
            gpint12_eni: 0,
            gpint12_eno: 0,
            gpint12_invi: 0,
            gpint12_invo: 0,
            gpint34_eni: 0,
            gpint34_eno: 0,
            gpint34_invi: 0,
            gpint34_invo: 0,
            gpio_eni12: 0,
            gpio_eno12: 0,
            gpio_eni34: 0,
            gpio_eno34: 0
        };
            prdinten_hi: 1,
            prdinten_lo: 1
        };
        params.intNum// Hwi interrupt number to be used by Timer = Int -1;
        params.period// Period of a tick = UInt32 0;
per-instance creation
    var inst = Timer.create// Create an instance-object(Int id, Void(*)(UArg) tickFxn, params);
 
 
const Timer.ANY

Const used to specify any timer

Configuration settings
const Timer.ANY = ~0;
 
C SYNOPSIS
 
const Timer.MAX_PERIOD

Max value of Timer period for PeriodType_COUNTS

Configuration settings
const Timer.MAX_PERIOD = 0xffffffff;
 
C SYNOPSIS
 
enum Timer.Half

In 32-bit modes, used to specify which half of Timer to use

Configuration settings
values of type Timer.Half
    const Timer.Half_LOWER;
    const Timer.Half_UPPER;
    const Timer.Half_DEFAULT;
 
C SYNOPSIS
 
enum Timer.Mode

The different modes of the Timer. These values match the TIMMODE bit fields of the Timer Global Control Register

Configuration settings
values of type Timer.Mode
    const Timer.Mode_64BITGPTIMER;
    const Timer.Mode_UNCHAINED;
    const Timer.Mode_WATCHDOG;
    const Timer.Mode_CHAINED;
 
C SYNOPSIS
 
enum Timer.PeriodType

Timer period units

Configuration settings
values of type Timer.PeriodType
    const Timer.PeriodType_MICROSECS;
    // period in microsecs
    const Timer.PeriodType_COUNTS;
    // period in counts
 
VALUES
PeriodType_MICROSECS — Period value is in microseconds.
PeriodType_COUNTS — Period value is in counts.
C SYNOPSIS
 
enum Timer.RunMode

Timer Run Modes

Configuration settings
values of type Timer.RunMode
    const Timer.RunMode_CONTINUOUS;
    // periodic and continuous
    const Timer.RunMode_ONESHOT;
    // one-shot
    const Timer.RunMode_DYNAMIC;
    // dynamically reprogrammed (available on subset of devices)
 
VALUES
RunMode_CONTINUOUS — Timer is periodic and runs continuously.
RunMode_ONESHOT — Timer runs for a single period value and stops.
RunMode_DYNAMIC — Timer is dynamically reprogrammed for the next required tick. This mode is intended only for use by the Clock module when it is operating in TickMode_DYNAMIC; it is not applicable for user-created Timer instances.
C SYNOPSIS
 
enum Timer.StartMode

Timer Start Modes

Configuration settings
values of type Timer.StartMode
    const Timer.StartMode_AUTO;
    // timer starts automatically
    const Timer.StartMode_USER;
    // timer will be started by user
 
VALUES
StartMode_AUTO — Statically created/constructed Timers will be started in BIOS_start(). Dynamically created Timers will start at create() time. This includes timers created before BIOS_start().
StartMode_USER — Timer will be started by the user using start().
C SYNOPSIS
 
enum Timer.Status

Timer Status

Configuration settings
values of type Timer.Status
    const Timer.Status_INUSE;
    // timer in use
    const Timer.Status_FREE;
    // timer is free
 
VALUES
Status_INUSE — Timer is in use. A timer is marked in use from the time it gets created to the time it gets deleted.
Status_FREE — Timer is free and can be acquired using create.
C SYNOPSIS
 
struct Timer.Control

Timer Control Register struct

Configuration settings
var obj = new Timer.Control;
 
    obj.tien = Bits8  ...
    // 0=Clock not gated by TINP; 1=Clock gated
    obj.invout = Bits8  ...
    // 0=Uninverted TSTAT drives TOUT; 1=Inverted TSTAT
    obj.invin = Bits8  ...
    // 0=Uninverted TINP drives Timer; 1=Inverted TINP
    obj.pwid = UInt8  ...
    // TSTATx goes inactive after pwid cycles (CP=0)
    obj.cp = Bits8  ...
    // 0=pulse mode; 1=clock mode
 
C SYNOPSIS
 
struct Timer.EmuMgt

Timer Emulation Management Register struct

Configuration settings
var obj = new Timer.EmuMgt;
 
    obj.free = Bool  ...
    // 0=suspend for emu halt; 1=don't suspend
    obj.soft = Bool  ...
    // 0=stop immediately; 1=stop when count==period
 
C SYNOPSIS
 
struct Timer.GpioDatDir

Timer GPIO Data and Direction Management Register struct

Configuration settings
var obj = new Timer.GpioDatDir;
 
    obj.gpio_dati12 = Bits8  ...
    // 0=TINP12 is input; 1=TINP12 is output
    obj.gpio_dato12 = Bits8  ...
    // 0=TOUTP12 is input; 1=TOUTP12 is output
    obj.gpio_dati34 = Bits8  ...
    // 0=TINP34 is input; 1=TINP34 is output
    obj.gpio_dato34 = Bits8  ...
    // 0=TOUTP34 is input; 1=TOUTP34 is output
    obj.gpio_diri12 = Bits8  ...
    // 0=input as GPIO input; 1=input as GPIO output
    obj.gpio_diro12 = Bits8  ...
    // 0=output as GPIO input;1=output as GPIO output
    obj.gpio_diri34 = Bits8  ...
    // 0=input as GPIO input; 1=input as GPIO output
    obj.gpio_diro34 = Bits8  ...
    // 0=output as GPIO input;1=output as GPIO output
 
C SYNOPSIS
 
struct Timer.GpioIntEn

Timer GPIO interrupt control and enable Management Register struct

Configuration settings
var obj = new Timer.GpioIntEn;
 
    obj.gpint12_eni = Bits8  ...
    // 0=source by timer; 1=input to source event
    obj.gpint12_eno = Bits8  ...
    // 0=source by timer; 1=output to source event
    obj.gpint12_invi = Bits8  ...
    // 0=don't invert invput; 1=invert input
    obj.gpint12_invo = Bits8  ...
    // 0=don't invert output; 1=invert output
    obj.gpint34_eni = Bits8  ...
    // 0=source by timer; 1=input to source event
    obj.gpint34_eno = Bits8  ...
    // 0=source by timer; 1=output to source event
    obj.gpint34_invi = Bits8  ...
    // 0=don't invert invput; 1=invert input
    obj.gpint34_invo = Bits8  ...
    // 0=don't invert output; 1=invert output
    obj.gpio_eni12 = Bits8  ...
    // 0=TINP12 as timer input; 1=TINP12 as GPIO
    obj.gpio_eno12 = Bits8  ...
    // 0=TOUTP12 as timer output; 1=TOUTP12 as GPIO
    obj.gpio_eni34 = Bits8  ...
    // 0=TINP34 as timer input; 1=TINP34 as GPIO
    obj.gpio_eno34 = Bits8  ...
    // 0=TOUTP34 as timer output; 1=TOUTP12 as GPIO
 
C SYNOPSIS
 
struct Timer.IntCtl

Timer interrupt control struct

Configuration settings
var obj = new Timer.IntCtl;
 
    obj.prdinten_hi = Bool  ...
    // 0=Disable interrupt; 1=Enable interrupt
    obj.prdinten_lo = Bool  ...
    // 0=Disable interrupt; 1=Enable interrupt
 
C SYNOPSIS
 
struct Timer.TimerSetting

Timer Settings

Configuration settings
var obj = new Timer.TimerSetting;
 
    obj.mode = Timer.Mode  ...
    // mode to put each Timer into
    obj.master = Bool  ...
    // for 'unchained' mode; 1=set mode and reset
    obj.ownerCoreId = UInt16  ...
    // used only for homogeneous multicore DSPs
 
C SYNOPSIS
 
config Timer.A_notAvailable  // module-wide

Assert raised when static created timer is not available

Configuration settings
Timer.A_notAvailable = Assert.Desc {
    msg: "A_notAvailable: static created timer not available"
};
 
C SYNOPSIS
 
config Timer.E_cannotSupport  // module-wide

Error raised when period requested is not supported

Configuration settings
Timer.E_cannotSupport = Error.Desc {
    msg: "E_cannotSupport: Timer cannot support requested period %d"
};
 
C SYNOPSIS
 
config Timer.E_invalidTimer  // module-wide

Error raised when timer id specified is not supported

Configuration settings
Timer.E_invalidTimer = Error.Desc {
    msg: "E_invalidTimer: Invalid Timer Id %d"
};
 
C SYNOPSIS
 
config Timer.E_notAvailable  // module-wide

Error raised when timer requested is in use

Configuration settings
Timer.E_notAvailable = Error.Desc {
    msg: "E_notAvailable: Timer not available %d"
};
 
C SYNOPSIS
 
config Timer.anyMask  // module-wide

Available mask to be used when select = Timer_ANY for timer id < 16. Set in xs file

Configuration settings
Timer.anyMask = Bits32 undefined;
 
C SYNOPSIS
 
config Timer.anyMaskHigh  // module-wide

Available mask to be used when select = Timer_ANY for timer id >= 16. Set in xs file

Configuration settings
Timer.anyMaskHigh = Bits32 undefined;
 
C SYNOPSIS
 
config Timer.defaultHalf  // module-wide

The default 32-bit half of the timer to be used

Configuration settings
Timer.defaultHalf = Timer.Half Timer.Half_LOWER;
 
C SYNOPSIS
 
config Timer.timerSettings  // module-wide

Global Control configuration for each physical timer

Configuration settings
Timer.timerSettings = Timer.TimerSetting[] [ ];
 
DETAILS
mode: Mode_UNCHAINED 32-bit unchained mode. master: TRUE If TRUE, release Timer from reset.
C SYNOPSIS
 
metaonly config Timer.common$  // module-wide

Common module configuration parameters

Configuration settings
Timer.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
 
metaonly config Timer.intFreqs  // module-wide

Default internal timer input clock frequency array

Configuration settings
Timer.intFreqs = Types.FreqHz[] undefined;
 
DETAILS
This array can be used to change the input clock frequency for a particular timer.
For example, if it is required to change the input clock frequency for timer id 2 to 32768Hz on a device that has 4 timers, the intFreqs[2] config param can be set to {hi:0, lo:32768} in the config script.
  var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');

  // Set Timer 2's frequency to 32.768 Khz
  Timer.intFreqs[2] = { hi:0, lo: 32768 };
For a list of default timer frequencies for different devices, please refer Timer Mapping Tables.
Instance Config Parameters

Configuration settings
var params = new Timer.Params;
// Instance config-params object
    params.arg = UArg null;
    // Argument for tick function
    params.controlInit = Timer.Control {
    // Control configuration. Default is all fields 0 or false except:
        tien: 0,
        invout: 0,
        invin: 0,
        pwid: 1,
        cp: 0
    };
    params.emuMgtInit = Timer.EmuMgt {
    // Emulation Management configuration. Default is:
        free: 0,
        soft: 0
    };
    params.extFreq = Types.FreqHz {
    // Timer frequency
        lo: 0,
        hi: 0
    };
    params.gpioDatDir = Timer.GpioDatDir {
    // General Purpose IO data and direction Management configuration The default is all fields is 0
        gpio_dati12: 0,
        gpio_dato12: 0,
        gpio_dati34: 0,
        gpio_dato34: 0,
        gpio_diri12: 0,
        gpio_diro12: 0,
        gpio_diri34: 0,
        gpio_diro34: 0
    };
    params.gpioIntEn = Timer.GpioIntEn {
    // General Purpose IO interrupt control and enable Management configuration. The default for all fields is 0
        gpint12_eni: 0,
        gpint12_eno: 0,
        gpint12_invi: 0,
        gpint12_invo: 0,
        gpint34_eni: 0,
        gpint34_eno: 0,
        gpint34_invi: 0,
        gpint34_invo: 0,
        gpio_eni12: 0,
        gpio_eno12: 0,
        gpio_eni34: 0,
        gpio_eno34: 0
    };
    params.half = Timer.Half Timer.Half_DEFAULT;
    // In 32-bit unchained mode, this field is used to specify which half of the timer to use
    params.hwiParams = Hwi.Params* null;
    // Hwi Params for Hwi Object. Default is null
    params.intCtl = Timer.IntCtl {
    // Timer interrupt control struct
        prdinten_hi: 1,
        prdinten_lo: 1
    };
    params.intNum = Int -1;
    // Hwi interrupt number to be used by Timer
    params.period = UInt32 0;
    // Period of a tick
    params.periodType = ITimer.PeriodType ITimer.PeriodType_MICROSECS;
    // Period type
    params.prescalar = UInt 0;
    // 32-bit pre-scalar to TIM12 in '32-bit chained' mode. The default is 0
    params.runMode = ITimer.RunMode ITimer.RunMode_CONTINUOUS;
    // Timer run mode
    params.startMode = ITimer.StartMode ITimer.StartMode_AUTO;
    // Timer start mode
 
config Timer.Params.arg  // instance

Argument for tick function

Configuration settings
var params = new Timer.Params;
  ...
params.arg = UArg null;
 
DETAILS
Default is null.
C SYNOPSIS
 
config Timer.Params.controlInit  // instance

Control configuration. Default is all fields 0 or false except:

Configuration settings
var params = new Timer.Params;
  ...
params.controlInit = Timer.Control {
    tien: 0,
    invout: 0,
    invin: 0,
    pwid: 1,
    cp: 0
};
 
DETAILS
pwid: 1
C SYNOPSIS
 
config Timer.Params.emuMgtInit  // instance

Emulation Management configuration. Default is:

Configuration settings
var params = new Timer.Params;
  ...
params.emuMgtInit = Timer.EmuMgt {
    free: 0,
    soft: 0
};
 
DETAILS
free: 0 soft: 0
C SYNOPSIS
 
config Timer.Params.extFreq  // instance

Timer frequency

Configuration settings
var params = new Timer.Params;
  ...
params.extFreq = Types.FreqHz {
    lo: 0,
    hi: 0
};
 
DETAILS
This parameter is meaningfull only on platforms where the timer's input clock can be changed. If value is left at zero, then input clock to the timer clock is assumed.
This value is used to convert timer ticks to real time units; seconds, milliseconds, etc.
C SYNOPSIS
 
config Timer.Params.gpioDatDir  // instance

General Purpose IO data and direction Management configuration The default is all fields is 0

Configuration settings
var params = new Timer.Params;
  ...
params.gpioDatDir = Timer.GpioDatDir {
    gpio_dati12: 0,
    gpio_dato12: 0,
    gpio_dati34: 0,
    gpio_dato34: 0,
    gpio_diri12: 0,
    gpio_diro12: 0,
    gpio_diri34: 0,
    gpio_diro34: 0
};
 
C SYNOPSIS
 
config Timer.Params.gpioIntEn  // instance

General Purpose IO interrupt control and enable Management configuration. The default for all fields is 0

Configuration settings
var params = new Timer.Params;
  ...
params.gpioIntEn = Timer.GpioIntEn {
    gpint12_eni: 0,
    gpint12_eno: 0,
    gpint12_invi: 0,
    gpint12_invo: 0,
    gpint34_eni: 0,
    gpint34_eno: 0,
    gpint34_invi: 0,
    gpint34_invo: 0,
    gpio_eni12: 0,
    gpio_eno12: 0,
    gpio_eni34: 0,
    gpio_eno34: 0
};
 
C SYNOPSIS
 
config Timer.Params.half  // instance

In 32-bit unchained mode, this field is used to specify which half of the timer to use

Configuration settings
var params = new Timer.Params;
  ...
 
C SYNOPSIS
 
config Timer.Params.hwiParams  // instance

Hwi Params for Hwi Object. Default is null

Configuration settings
var params = new Timer.Params;
  ...
params.hwiParams = Hwi.Params* null;
 
C SYNOPSIS
 
config Timer.Params.intCtl  // instance

Timer interrupt control struct

Configuration settings
var params = new Timer.Params;
  ...
params.intCtl = Timer.IntCtl {
    prdinten_hi: 1,
    prdinten_lo: 1
};
 
C SYNOPSIS
 
config Timer.Params.intNum  // instance

Hwi interrupt number to be used by Timer

Configuration settings
var params = new Timer.Params;
  ...
params.intNum = Int -1;
 
C SYNOPSIS
 
config Timer.Params.period  // instance

Period of a tick

Configuration settings
var params = new Timer.Params;
  ...
params.period = UInt32 0;
 
DETAILS
The period can be specified in timer counts or microseconds and its default value is 0.
The implementation of ITimer will support a period of UInt32 timer counts and use pre-scalars if necessary.
C SYNOPSIS
 
config Timer.Params.periodType  // instance

Period type

Configuration settings
var params = new Timer.Params;
  ...
 
DETAILS
Default is PeriodType_MICROSECS
C SYNOPSIS
 
config Timer.Params.prescalar  // instance

32-bit pre-scalar to TIM12 in '32-bit chained' mode. The default is 0

Configuration settings
var params = new Timer.Params;
  ...
params.prescalar = UInt 0;
 
C SYNOPSIS
 
config Timer.Params.runMode  // instance

Timer run mode

Configuration settings
var params = new Timer.Params;
  ...
 
DETAILS
Default is RunMode_CONTINUOUS.
C SYNOPSIS
 
config Timer.Params.startMode  // instance

Timer start mode

Configuration settings
var params = new Timer.Params;
  ...
 
DETAILS
Default is StartMode_AUTO.
C SYNOPSIS
Static Instance Creation

Configuration settings
var params = new Timer.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = Timer.create(Int id, Void(*)(UArg) tickFxn, params);
// Create an instance-object
ARGUMENTS
id — Timer id ranging from 0 to a platform specific value, or ANY
tickFxn — function that runs upon timer expiry.
params — per-instance config params, or NULL to select default values (target-domain only)
eb — active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
Create could fail if timer peripheral is unavailable. To request any available timer use ANY as the id. TimerId's are logical ids. The family-specific implementations map the ids to physical peripherals.
generated on Fri, 10 Jun 2016 23:28:52 GMT