See Quick start guide for Timeout service.
The timeout service uses the asynchronous RTC/RTC32 in order to have a system tick. Typical tick rate is 1-1000Hz. Clock sources available:
The timeout service is configurable to a number of independent timeout channels, each with different delay setup in a number of ticks. Both singleshot and periodic timeouts are supported.
As this service provides a software layer on top of the RTC/RTC32 module it will have some performance penalty, so for high performance it would be recommended to implement a more specific use by implementing your own interrupt handler based on this as a reference.
Configuration is done in the config file : conf_timeout.h
Configuration defines:
The timeout internal setup needs to be configured and this is done by the function tc_timeout_init().
There are different functions for starting a timer:
Polling for timer status can be done with timeout_test_and_clear_expired(), and this will also clear the expired flag in case of periodic timer.
A running timer can be stopped with timeout_stop().
Common to all the function arguments are a timeout identifier, this is a number starting from 0 to identify the timeout channel. Maximum of this parameter is controlled by the configuration TIMEOUT_COUNT.
The start timeout functions uses timeout values represented in number of ticks.
First of all, the include file is needed:
Then the timeout internals need to be set up by calling:
For simple usage starting a singleshot timeout for timeout id 0 and a timeout value of 100 ticks:
Since this is a timeout layer on top of a system tick; the trigger time of a timeout is fully depending on this system tick. This means that you might not know when the next tick will count down your timeout, and this inaccuracy can be from 0 to 1 system tick.
E.g.: If you want a timeout of 1 system tick and use 1 as your timeout value, this might trigger immediately. So, if you have a requirement to wait at least 1 system tick, it would be recommended to use the requested value
However, if you know the system tick has passed or are using periodic timeout you can be confident in the timing.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the Timeout service XMEGA. | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the Timeout service XMEGA. | |