Sie sind auf Seite 1von 3

Documentation for Arduino Timer

Module (Timers)
Ed Carryer, Matt Ohline, Betai Koffi, Stellios Leventis

Revision List (Most Recent First)


January 25, 2012
Updated for change to unsigned long timers.
January 23, 2012
Ported to run on the Arduino UNO (Rev 2).
October 15, 2006
Updated to clarify timer numbering.
October 16, 2005
Updated to reflect the use of enums & return types.
October 18, 2004
Updated to reflect the new names and addition of GetTime for the S12
timer library.
December 29, 2001
Removed example that used SES.
January 10, 2001
Removed reference to limited function version for cockroaches.

Introduction
PURPOSE OF MODULE
This module provides for 16 independent timer channels. These timers
can be started, stopped and tested for completion. All timers share a
common time base, with a basic tick rate of 1 ms.

INTERFACE
This is a software-only module, with no external hardware interactions.

Module Functions
Module functions are documented on following pages.

TMRArd_InitTimer

TMRArd_StartTimer

PROTOTYPE

PROTOTYPE

TMRArdReturn_t TMRArd_InitTimer(unsigned char Num,

TMRArdReturn_t TMRArd_StartTimer(unsigned char Num)

unsigned long NewTime)


PARAMETERS

PARAMETERS
unsigned char Num the number of the timer to start (0-15)

unsigned char Num the number of the timer to set & start (0-15)
unsigned long NewTime the number of ticks to be counted
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_OK otherwise.
DESCRIPTION
Sets the NewTime into the chosen timer, clears any previous event flag,
and sets the timer active to begin counting immediately.

RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_OK otherwise.
DESCRIPTION
Sets the active flag in TMRArd_ActiveFlags to start a timer that was
previously set, or to restart a stopped timer.

TMRArd_StopTimer
PROTOTYPE

TMRArd_SetTimer

TMRArdReturn_t TMRArd_StopTimer(unsigned char Num)

PROTOTYPE
TMRArdReturn_t TMRArd_SetTimer(unsigned char Num,
unsigned long NewTime)
PARAMETERS
unsigned char Num the number of the timer to be set (0-15)
unsigned long NewTime the number of ticks to be counted
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_OK otherwise.
DESCRIPTION
Sets the NewTime into the chosen timer, but does not make it active.

PARAMETERS
unsigned char Num the number of the timer to stop (0-15)
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_OK otherwise.
DESCRIPTION
Clears the bit in TMRArd_ActiveFlags associated with this timer. This
will cause it to stop counting..

TMRArd_IsTimerActive

TMRArd_ClearTimerExpired

PROTOTYPE

PROTOTYPE

TMRArdReturn_t TMRArd_IsTimerActive(unsigned char Num)

TMRArdReturn_t TMRArd_ClearTimerExpired(

PARAMETERS
unsigned char Num the number of the timer to check (0-15)
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_NOT_ACTIVE if the requested timer is not active (stopped),
TMRArd_ACTIVE if the requested timer is active (running).
DESCRIPTION
This function is used to determine if a timer is currently counting.

TMRArd_IsTimerExpired
PROTOTYPE
TMRArdReturn_t TMRArd_IsTimerExpired(unsigned char
Num)
PARAMETERS
unsigned char Num the number of the timer to test (0-15)
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_NOT_EXPIRED if the requested timer is not expired,
TMRArd_EXPIRED if the requested timer is expired.
DESCRIPTION
This function tests flags to determine if the requested timer has
expired.

unsigned char
Num)
PARAMETERS
unsigned char Num timer whose event flag is to be cleared (0-15)
RETURNS
TMRArd_ERR if the requested timer does not exist,
TMRArd_OK otherwise.
DESCRIPTION
Clears the appropriate bit in TMRArd_EventFlags to show that the
associated timer expiration event has been serviced.

TMRArd_GetTime
PROTOTYPE
unsigned long TMRArd_GetTime(void)
PARAMETERS
None
RETURNS
An unsigned 32-bit number between 0 and 4,294,967,295 (232-1)
reflecting the current number of ticks on the master timer. Timer
rollover occurs after about fifty days.
DESCRIPTION
Simply returns the value of a free-running counter kept by the module.

Das könnte Ihnen auch gefallen