STC15W408AS library 0.9.0
|
frequency and ticks | |
Timer ticks to frequency and vice versa convertions | |
#define | timer0_uint16_ticks_to_freq100(ticks) (timer_uint16_ticks_to_freq100(ticks, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Convert ticks to timer frequency for timer0 multiplied by 100. More... | |
#define | timer0_frequency_to_ticks_unsafe(frequency) (timer_frequency_to_ticks_unsafe(frequency, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Unsafe approximation timer0 frequency corresponding to ticks. More... | |
#define | timer0_ticks_to_ms_usafe(ticks) (timer_ticks_to_ms_usafe(ticks, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Convert ticks count to ms. More... | |
#define | timer0_ms_to_ticks_usafe(ms) (timer_ms_to_ticks_usafe(ms, get_timer0_clock_divider())) |
Convert milliseconds to timer0 ticks. More... | |
tick to frequency conversions | |
Timer ticks to overlow frequency and vice versa convertions | |
#define | timer2_ticks_to_ms_usafe(ticks) (timer_ticks_to_ms_usafe(ticks, get_timer2_clock_divider(), get_frequency_divider_scale())) |
Convert ticks count to ms. More... | |
UART baud rate to ticks | |
UART baud rate to timer ticks to overlow frequency and vice versa convertions | |
#define | timer2_ms_to_ticks_usafe(ms) (timer_ms_to_ticks_usafe(ms, get_timer2_clock_divider())) |
Convert milliseconds to timer2 ticks. More... | |
Functions and data structures for converting timer ticks to frequency and times for timer0.
#define timer0_frequency_to_ticks_unsafe | ( | frequency | ) | (timer_frequency_to_ticks_unsafe(frequency, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Unsafe approximation timer0 frequency corresponding to ticks.
ticks = get_master_clock_frequency() / (2 * get_timer0_clock_divider() * frequency))
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
This method doesnt analyze corner cases and overflow of result. Be careful.
frequency | uint32_t frequency value in Hz. Should not be 0; |
#define timer0_ms_to_ticks_usafe | ( | ms | ) | (timer_ms_to_ticks_usafe(ms, get_timer0_clock_divider())) |
Convert milliseconds to timer0 ticks.
1 ms = ((get_master_clock_frequency_high_part() + 26) >> get_frequency_divider_scale()) / timer_clock_divider
This routine doesnt check overflows. Its unsafe.
ms | uint16_t ms to convert |
#define timer0_ticks_to_ms_usafe | ( | ticks | ) | (timer_ticks_to_ms_usafe(ticks, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Convert ticks count to ms.
This method doesnt analyze corner cases and overflow of result. Be careful.
ticks | uint16_t ticks count |
#define timer0_uint16_ticks_to_freq100 | ( | ticks | ) | (timer_uint16_ticks_to_freq100(ticks, get_timer0_clock_divider(), get_frequency_divider_scale())) |
Convert ticks to timer frequency for timer0 multiplied by 100.
The output frequency = (SYSclk/timer_clock_divider)/((65536-ticks) * 2). Multiplication by 100 is used for get frequency value without using float numbers.
Call this method after timer0 is initialized and MCU clock frequency divider scale is set.
uint16 ticks used in mode 0, 1, 3. Low byte of ticks is used in mode 2.
ticks | uint16_t timer ticks count to covert |
#define timer2_ms_to_ticks_usafe | ( | ms | ) | (timer_ms_to_ticks_usafe(ms, get_timer2_clock_divider())) |
Convert milliseconds to timer2 ticks.
1 ms = ((get_master_clock_frequency_high_part() + 26) >> get_frequency_divider_scale()) / timer_clock_divider
This routine doesnt check overflows. Its unsafe.
ms | uint16_t ms to convert |
#define timer2_ticks_to_ms_usafe | ( | ticks | ) | (timer_ticks_to_ms_usafe(ticks, get_timer2_clock_divider(), get_frequency_divider_scale())) |
Convert ticks count to ms.
This method doesnt analyze corner cases and overflow of result. Be careful.
ticks | uint16_t ticks count |