@CHIP-RTOS C Library V2.06 - Hardware API
hal_init_timer
Initialize timer settings void hal_init_timer ( unsigned char timer,
unsigned short mode,
unsigned short divider ); Parameters
timer
- Timer
0=Timer0 / 1=Timer1
mode
- Timer mode:
Bit 0: 0=run single time / 1=run continuous
Bit 1: 0=disable timer interrupt / 1=enable timer interrupt
Bit 2: 0=use internal clock / 1=use TMRIN pin as external clock
Bit 3..15: not used
divider
- Clock divider (maximum count value)
Return Value
- -- none --.
Comments
- Initialize the timer settings of timer0 or timer1.
The clock divider value serves as a comparator for the associated timer
count. The timer count is a 16 bit value that is incremented by the processor
internal clock (see hal_get_frequencies
function) or can also be configured to increment based on the TMRIN0
or TMRIN1 external signals (see PFE
pfe_enable_timer).
The TMROUT0 und TMROUT1 signals can be used to generate waveforms
of various duty cycles. The default is a 50% duty cycle waveform
(Change waveform with HAL
hal_set_duty_cycle_waveform function).
Note that TMRIN pin and TMROUT pin can not be used at the same time.
- When the timer is configured to run in single time mode, the timer
clears the count and then halts on reaching the maximum count (clock
divider value).
If the timer interrupt is enabled, the interrupt request is generated
when the count equals the clock divider value. Use HAL
hal_install_isr function
to install your interrupt service routine.
If "use internal clock" is selected the associated TMRIN pin serves
as a gate. A "high" on the TMRIN pin keeps the timer counting.
A "low" holds the timer value.
SC1x Comments- If the clock divider value is set to 0000h, the timer will count from 0000h
to FFFFh (maximum divider). When the timer reaches the clock divider
value, it resets to 0 during the same clock cycle. The timer count
never dwells equals to the clock divider value (except for special case
when divider value is set to 0000h).
SC1x3 Comments- When the timer reaches the clock divider value, it
resets to 0 during the same clock cycle. The timer count never dwells equals to
the clock divider value.
If the clock divider value is set to 0000h, the timer will not count from 0000h
to FFFFh like on SC12 and SC13.
See Also
RTOS API
- This library function invokes a RTOS software interrupt.
Refer to this RTOS API function's
documentation
for more details.
Developer Notes The timer output frequency is dependent on the internal processor clock.
For compatibility with future versions of @Chip, please use the HAL
hal_get_frequencies to compute the
correct clock divider value.
Available examples
1. TimerIn example, timerin.c
2. TimerOut example, timerout.c
Supported since or modified in @CHIP-RTOS version-
SC12 | SC13 | SC11 | SC1x3 |
-
V1.00 | V1.00 | V1.00 | V0.90 |
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|