Functions and data structures for converting timer ticks to frequency and times for timer0 mode2.
- Author
- Michael Golovanov
◆ timer0_mode2_delay_ms
| #define timer0_mode2_delay_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode2_delay(ticks); \
} while(0);
#define timer0_mode2_ms_to_ticks(ms)
Convert milliseconds to timer0 ticks.
Definition timer0_mode2_to_ms.h:77
Run timer0 mode2 once and wait with program flow blocking timer not finished.
- Parameters
-
| ms | uint16_t delay ms duration |
◆ timer0_mode2_Hz_to_ticks
Converts frequency corresponding to ticks for timer0 mode2.
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
- Warning
- On result iverflow returns 0. Be careful.
- Parameters
-
| frequency | uint32_t frequency value in Hz. Should not be 0; |
- Returns
- uint8_t timer0 ticks corresponding to frequency value
◆ timer0_mode2_ms_to_ticks
Convert milliseconds to timer0 ticks.
- Parameters
-
| ms | uint16_t ms to convert. Range is 1..~9000 |
- Returns
- uint16_t Number of timer ticks corresponding to the input time. Returns 0 if the result overflows uint16_t range.
◆ timer0_mode2_start_Hz
| #define timer0_mode2_start_Hz |
( |
|
freq | ) |
|
Value:do \
{ \
timer0_mode2_start(ticks); \
} while (0);
#define timer0_mode2_Hz_to_ticks(frequency)
Converts frequency corresponding to ticks for timer0 mode2.
Definition timer0_mode2_to_ms.h:53
Start timer0 in mode 2 with Hz frequency.
- Parameters
-
| freq | uint32_t timer overflow frequency in Hz |
◆ timer0_mode2_start_ms
| #define timer0_mode2_start_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode2_start(ticks); \
} while (0);
Start timer0 in mode 2 with ms duration.
- Parameters
-
| ms | uint8_t timer overflow duration |
◆ timer0_mode2_ticks_to_Hz
Converts ticks to timer overflow frequency for timer0 mode2.
The output frequency = (SYSclk/timer_clock_divider)/(1 + ticks) .
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
uint16 ticks used in timer mode 0, 1, 3. For timer mode2 (8 bit autoreladable timer) ticks can be in 0..255 range.
- Parameters
-
| ticks | uint16_t timer ticks count to covert |
- Returns
- uint32_t frequency multiplied by 100 corresponding to ticks count
◆ timer0_mode2_ticks_to_mcs
Convert ticks count to microseconds.
- Parameters
-
| ticks | uint8_t ticks count. |
- Returns
- uint16_t microseconds time corresponing to timer ticks.