Functions and data structures for converting timer ticks to frequency and times for timer0 mode3.
- Author
- Michael Golovanov
◆ timer0_mode3_delay_ms
| #define timer0_mode3_delay_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode3_delay(ticks); \
} while(0);
#define timer0_mode3_ms_to_ticks(ms)
Convert milliseconds to timer0 ticks.
Definition timer0_mode3_to_ms.h:77
Run timer0 mode3 once and wait with program flow blocking timer not finished.
- Parameters
-
| ms | uint16_t delay ms duration |
◆ timer0_mode3_Hz_to_ticks
Converts frequency to ticks for timer0 mode3.
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
- Warning
- on result overflow returns 0. Be careful.
- Parameters
-
| frequency | uint32_t frequency value in Hz. Should not be 0; |
- Returns
- uint16_t timer0 ticks corresponding to frequency value or 0 on result overflow
◆ timer0_mode3_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_mode3_start_Hz
| #define timer0_mode3_start_Hz |
( |
|
freq | ) |
|
Value:do \
{ \
timer0_mode3_start(ticks); \
} while (0);
#define timer0_mode3_Hz_to_ticks(frequency)
Converts frequency to ticks for timer0 mode3.
Definition timer0_mode3_to_ms.h:53
Start timer0 in mode 3 with Hz frequency.
- Parameters
-
| freq | uint32_t timer overflow frequency in Hz |
◆ timer0_mode3_start_ms
| #define timer0_mode3_start_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode3_start(ticks); \
} while (0);
Start timer0 in mode 3 with ms duration.
- Parameters
-
| ms | uint16_t timer overflow duration |
◆ timer0_mode3_ticks_to_Hz
Converts ticks to timer overflow frequency for timer0 mode3.
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_mode3_ticks_to_ms
Convert ticks count to ms.
- Parameters
-
| ticks | uint16_t ticks count. Range 7...65535 |
- Returns
- milliseconds time corresponing to timer ticks. Range 0..9043