# cdiStartTimer

Starts (or restarts) a timer on this port.

#### Prototype

DWORD cdiStartTimer ( CTAHD ctahd, DWORD timeout, DWORD count)

Argument | Description
ctahd | Context handle.
timeout | Time out value in milliseconds.
count | Number of events.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | Argument is not in the valid range.
CTAERR_INVALID_CTAHD | Handle is invalid.

#### Events

Event | Description
CDIEVN_TIMER_DONE | The timer stopped. The event value field contains one of the following reason codes: CTA_REASON_TIMEOUT The timer ran for the full specified time, and then expired. CTA_REASON_STOPPED The timer was halted with cdiStopTimer.
CDIEVN_TIMER_START | The timer started.
CDIEVN_TIMER_TICK | The timer ticked. Refer to the Details section for more information.

#### Details

The CDI service supports one on-board timer per context on a CX board. You can set up this timer to run for a specified amount of time and then expire, returning an event to the application. Alternatively, you can configure the timer to tick, generating a specified number of tick events at a periodic rate before expiring:

Timer task | Steps
--- | ---
Run once and then expire | Set timeout to timeout length (in ms). Set count to 1. When the timer is started, CDIEVN_TIMER_START is generated. When the timer expires, CDIEVN_TIMER_DONE is returned. The value field of this event contains CTA_REASON_FINISHED.
Tick | Set timeout to tick rate (in ms). Set count to number of ticks required. When the timer is started, CDIEVN_TIMER_START is generated. As the timer ticks, CDIEVN_TIMER_TICK events are generated. On the final tick, CDIEVN_TIMER_DONE is returned. The value field of this event contains CTA_REASON_FINISHED.

The timer has a 2 ms resolution.

You can abort a timer by invoking cdiStopTimer.

A running timer can be restarted at any time before normal expiration by a subsequent call to cdiStartTimer.