RtCreateTimerEx

RtCreateTimerEx creates a timer associated with the specified clock and returns a handle to the timer. Use this call instead of RtCreateTimer if you want to set the affinity for the timer handler.

Syntax

Copy
HANDLE RtCreateTimerEx(
    PSECURITY_ATTRIBUTES pThreadAttributes,
    ULONG StackSize,
    VOID (RTFCNDCL *pRoutine) (PVOID context),
    PVOID Context,
    ULONG Priority,
    CLOCK Clock,
    KAFFINITY ProcessorEnableMask
);

Parameters

pThreadAttributes (ignored by eRTOS)

An optional pointer to a SECURITY_ATTRIBUTES structure to be used at handler thread creation. Pass in NULL for default.

StackSize

The stack size for handler thread. Use a size of 0 for default.

Routine

A pointer to the routine to be run upon completion. The routine takes a single PVOID argument and returns VOID.

Context

The argument to the routine, cast as a PVOID.

Priority

The handler thread priority as defined below.

Clock

A clock identifier. Legal clock values are listed below:

Clock Value

Meaning

CLOCK_1

One millisecond timer.

CLOCK_2

eRTOS HAL timer. Default is 100 microseconds.

CLOCK_3

eRTOS HAL timer.  Use the actual timer period to set and deliver the clock values, to calculate the expiration values and response latencies of timers based on this clock.

CLOCK_FASTEST

The fastest available clock and time on the system. This is usually CLOCK_2.

CLOCK_SYSTEM

Same as CLOCK_1.

ProcessorEnableMask

Specifies the KAFFINITY mask that represents the set of processors on which the timer handler can run.

Return Value

If the function succeeds, it returns a non-zero handle to the timer. If the function fails, it returns a NULL handle.

To set the timer to expire, see RtSetTimer or RtSetTimerRelative. When the timer expires, the specified routine runs with the specified argument.

Remarks

The timer routine will run as a separate handling thread. pThreadAttributes, StackSize, Priority and ProcessorEnableMask are used to control the creation of the handler thread. See CreateThread and RtSetThreadPriority for details on these parameters.

To run a different handling routine/context, a new timer must be created.

Note: If your timer period is close to Real-time kernel’s HAL timer period, the overhead of kernel tick processing may cause a much larger response latency of your timer handling routine (IST). In this case, you should configure a much smaller HAL timer period. For example, if your timer period is 100 us, you should configure HAL period to a smaller value, such as 50 us, depending on your processor frequency.

Requirements

Minimum supported version Header Library

eRTOS 1.0 SDK

Rtapi.h rtkrnl.lib

See Also: