Timer Interface
Timer Platform interface
Timer Overview
A timer is a critical component in microcontrollers and embedded systems, used for timekeeping, event scheduling, and generating precise delays or waveforms. Timers operate by counting clock cycles from the microcontroller’s clock source, allowing developers to execute tasks or generate signals at specified intervals.
Timer Operation Modes
The supportted operation modes, trigger sources as supported by the underlying timer.
Mode |
Description |
|---|---|
RS_TIMER_OPERATION_MODE_INPUT_CAPTURE |
Timer is configured for Input Capture operation |
RS_TIMER_OPERATION_MODE_OUTPUT_COMPARE |
Timer is configured for Output compare operation |
RS_TIMER_OPERATION_MODE_EDGE_PWM |
Timer is used to generate edge aligned PWM |
RS_TIMER_OPERATION_MODE_CENTER_PWM |
Timer is used to generate center aligned PWM |
RS_TIMER_OPERATION_MODE_ONE_PULSE |
Timer is used to generate single pulse |
Mode |
Description |
|---|---|
RS_TIMER_TRIGGER_MODE_CONTINUOUS |
Increment continuously |
RS_TIMER_TRIGGER_MODE_EXTERNAL |
Increment via external event |
Mode |
Description |
|---|---|
RS_TIMER_EVENT_TYPE_COUNTER_OVERFLOW |
On counter overflow |
RS_TIMER_EVENT_TYPE_COUNTER_UNDERFLOW |
On counter underflow |
RS_TIMER_EVENT_TYPE_INPUT_CAPTURE |
Input event happened |
Application Interface
The below table captures the functions that are to be called from the application layer.
Function |
Description |
|---|---|
rs_timer_init |
To open timer unit |
rs_timer_configure_channel |
To configures the timer channel |
rs_timer_start_channel |
To starts the timer for the given channel |
rs_timer_stop_channel |
To stops the timer for the given channel |
rs_timer_register_event_callback |
To registers the given callback function for event |
rs_timer_deinit |
To close the timer unit |
Error Code
Every API’s for the timer returns some success or failure values. Please refer below section,
Implementation Guide
Initialize the timer unit
Configure the timer channel under the unit
Register the callback function
Start the timer channel
Callback gets called.
Stop the timer once work is done
Un-Initialize the timer unit
Documentation from the relevant header as follows:
Warning
doxygenfile: Cannot find file “rs_timer.h