Detailed Description
The TIMER1 module gives an interface to a 16bit HW timer which can be used for custom application purposes.
This module offers:
- COUNTER mode - exact timing with callback functions and granularity 1/(16,384MHz) pro tick using 16,384MHz clock. The counter tick can be adjusted using a 1, 2, 4 postscaler.
- PWM mode - PWM signal generation on the SCSEDIO0 or ADIO0 or ADIO4 pin
See the source code and description of the
RSSI Example for more information how the PWM works.
- Note:
- Timer1 callback function will be called from interrupt. As timer1 interrupt belong to the group of interrupt with lowest priority it is possible that the Timer1 callback has to wait till radio, scheduler (timer0), i/o callback or uart interrupt is executed. It is not possible to guaranty a minimum time from triggering any interrupt till execution of the interrupt service routine.
Macro Definition Documentation
#define timer1_setConfig |
( |
|
pu16Param, |
|
|
|
u8Index, |
|
|
|
u16NewValue |
|
) |
| pu16Param[u8Index]=u16NewValue; timer1_init(pu16Param,u8Index); |
Sets one timer1 parameter
- Parameters:
-
[in] | *pu16Param | Pointer to the list of parameters to set. See #time_param[] |
[in] | u8Index | Index of parameter to set. See #TIME_PARAM_IDX |
[in] | u16NewValue | The parameter value |
- Returns:
- -
- See also:
- timer1_init, TIMER1_PARAM_IDX
Function Documentation
void timer1_init |
( |
uint16 * |
pu16Param, |
|
|
uint8 |
u8ParamToSet |
|
) |
| |
Sets all the timer1 parameters
- Parameters:
-
[in] | *pu16Param | Pointer to the list of parameters to set. See #timer1_param[] |
[in] | u8ParamToSet | It has to be SET_ALL_PARAM to set all parameters in the list |
- Returns:
- -
- See also:
- timer1_setConfig, TIMER1_PARAM_IDX
void timer1_initCB |
( |
void code * |
pu16FnPtr | ) |
|
Sets function pointer for callback function in interrupt and enables the callback interrupt generation
- Parameters:
-
[in] | *pu16FnPtr | Pointer to the callback function which will be called when timer1 generates an interrupt |
- Returns:
- -
- See also:
- timer1_enableCB
void timer1_enableCB |
( |
uint8 |
u8Enable | ) |
|
Enables or disables callback when timer1 generates an interrupt
- Parameters:
-
[in] | u8Enable | TRUE, callback enabled, FALSE, callback disabled |
- Returns:
- -
- Note:
- Do not stay in the callback function too long (not more than 100 us because that takes too much time away from the schedule)
-
The callback function will be called during an interrupt! Do not call other API functions than io_getDigital or io_getPort in callback function. Do not switch the registerbank. Do not use overlaying and optimizing in callback function.
-
If you did not initialised callback function pointer and you enable callback function, then the interrupt occurs, but function cannot be called and interrupt returns without function. Program will not crash, but resources are used.
void callback()
{
...
}
void yourFunction()
{
.....
.....
.....
}
- See also:
- timer1_initCB
void timer1_enable |
( |
uint8 |
u8Enable | ) |
|
Enables or disables function of timer1 (in both COUNTER and PWM mode)
- Parameters:
-
[in] | u8Enable | TRUE, timer1 function enabled, FALSE, timer1 function disabled |
- Returns:
- -
- Note:
- After enabling timer1 with timer_enable(TRUE) it will run in a loop until is stopped with timer_enable(FALSE)
-
This function is allowed to be used in an interrupt callback function ONLY if it is ensured that it is not used at the same time from the main program!
- See also:
- timer1_init
void timer1_getTimerCounter |
( |
uint16 * |
pu16Count | ) |
|
Returns actual counter value
- Parameters:
-
[out] | *pu16Count | Pointer to store the counting value of timer1 |
- Returns:
- -
- Note:
- This function is allowed to be used in an interrupt callback function ONLY if it is ensured that it is not used at the same time from the main program!
void timer1_resetCounter |
( |
| ) |
|
Resets actual counter value
- Parameters:
-
- Returns:
- -
- Note:
- This function is allowed to be used in an interrupt callback function ONLY if it is ensured that it is not used at the same time from the main program!