|
Delay using timer
|
| #define | timer0_mode0_delay_ms(ms) |
| | Run timer0 mode0 once and wait with program flow blocking timer not finished.
|
| |
Functions and data structures for converting timer ticks to frequency and times for timer0 mode0.
- Author
- Michael Golovanov
◆ timer0_mode0_delay_ms
| #define timer0_mode0_delay_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode0_delay(ticks); \
} while(0);
#define timer0_mode0_ms_to_ticks(ms)
Convert milliseconds to timer0 ticks.
Definition timer0_mode0_to_ms.h:77
Run timer0 mode0 once and wait with program flow blocking timer not finished.
- Parameters
-
| ms | uint16_t delay ms duration |
◆ timer0_mode0_Hz_to_ticks
Converts frequency to timer0 mode0 ticks.
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
- Warning
- On uint16_t overflow this routine returns 0.
- Parameters
-
| frequency | 3uint32_t frequency value in Hz. Should not be 0;1 |
- Returns
- uint16_t timer0 ticks corresponding to frequency value or 0 on uint16_t overflow
◆ timer0_mode0_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_mode0_start_Hz
| #define timer0_mode0_start_Hz |
( |
|
freq | ) |
|
Value:do \
{ \
timer0_mode0_start(ticks); \
} while (0);
#define timer0_mode0_Hz_to_ticks(frequency)
Converts frequency to timer0 mode0 ticks.
Definition timer0_mode0_to_ms.h:53
Start timer0 in mode 0 with Hz frequency.
- Parameters
-
| freq | uint32_t timer overflow frequency in Hz |
◆ timer0_mode0_start_ms
| #define timer0_mode0_start_ms |
( |
|
ms | ) |
|
Value:do \
{ \
timer0_mode0_start(ticks); \
} while (0);
Start timer0 in mode 0 with ms duration.
- Parameters
-
| ms | uint16_t timer overflow duration |
◆ timer0_mode0_ticks_to_Hz
Converts ticks to timer frequency for timer0 multiplied by 100.
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 timer overflow frequency corresponding to given ticks count
◆ timer0_mode0_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