Functions and data structures for get chip CPU frequency. Chip CPU frequency defined in sys.h as a MAIN_Fosc constant.
- Author
- Michael Golovanov
◆ disable_master_clock_output
#define disable_master_clock_output |
( |
| ) |
(CLK_DIV &= 0x3f) |
◆ enable_master_clock_output_div1
#define enable_master_clock_output_div1 |
( |
| ) |
(CLK_DIV |= 0x40) |
◆ enable_master_clock_output_div2
#define enable_master_clock_output_div2 |
( |
| ) |
(CLK_DIV |= 0x80) |
◆ enable_master_clock_output_div4
#define enable_master_clock_output_div4 |
( |
| ) |
(CLK_DIV |= 0xC0) |
◆ get_frequency_divider
#define get_frequency_divider |
( |
| ) |
(1 << (CLK_DIV & 0x07)) |
◆ get_frequency_divider_scale
#define get_frequency_divider_scale |
( |
| ) |
(CLK_DIV & 0x07) |
◆ get_master_clock_frequency
#define get_master_clock_frequency |
( |
| ) |
(MAIN_Fosc) |
Get MAIN_Fosc value.
- Returns
- MAIN_Fosc value
◆ get_master_clock_frequency_high_part
#define get_master_clock_frequency_high_part |
( |
| ) |
(MAIN_FoscH) |
Get high part of MAIN_Fosc defined as MAIN_FoscH in sys.h.
- Returns
- MAIN_FoscH
◆ get_master_clock_frequency_low_part
#define get_master_clock_frequency_low_part |
( |
| ) |
(MAIN_FoscL) |
Get low part of MAIN_Fosc defined as MAIN_FoscL in sys.h.
- Returns
- MAIN_FoscL
◆ get_master_clock_output_pin
#define get_master_clock_output_pin |
( |
| ) |
((CLK_DIV & 0xC0) == 0 ? NONE : (CLK_DIV & 0x08) == 0 ? P5_4 : P1_6) |
Get master clock output.
- Returns
- info about current master clock output
◆ set_frequency_divider_scale
#define set_frequency_divider_scale |
( |
|
divider_scale | ) |
|
Value:{ \
CLK_DIV &= 0xf8; \
CLK_DIV |= (divider_scale & 0x07); \
}
Update and get master clock frequency divider (CLK_DIV bits [0..2])
Before setting divider value validate if divider scale is out of range 0..7.
- Parameters
-
divider_scale | uint8 scale from 0 to 7 corresponds dividers 1, 2, 4, ...128 |
- Returns
- master clock frequency divider value
- See also
- get_frequency_divider()
◆ set_master_clock_output_pin
#define set_master_clock_output_pin |
( |
|
pin | ) |
|
Value: { \
{ \
disable_master_clock_output(); \
} \
{ \
bit_clr(CLK_DIV, CBIT3); \
} \
{ \
bit_set(CLK_DIV, SBIT3); \
} \
}
@ P1_6
output to pin 1.6
Definition: frequency.h:138
@ P5_4
output to pin 5.4
Definition: frequency.h:136
@ NONE
output disabled
Definition: frequency.h:134
Set master clock output pin.
- Parameters
-
pin | master_clock_output_pin_t pin to set output |
◆ master_clock_output_pin_t
Master clock output pins enumeration.
Enumerator |
---|
NONE | output disabled
|
P5_4 | output to pin 5.4
|
P1_6 | output to pin 1.6
|