STC15W408AS library 0.9.0
|
Macros | |
#define | INTO P32 |
INT0 pin definition. | |
init | |
Timer initializaion functions | |
#define | timer0_mode0_12T_init() |
Initialize mode0 12T for timer0. More... | |
#define | timer0_mode0_1T_init() |
Initialize mode0 1T for timer0. More... | |
config | |
Timer configuration functions | |
#define | timer0_mode0_enable_P35_output() (bit_set(INT_CLKO, SBIT0)) |
Enable P35 meander output. | |
#define | timer0_mode0_disable_P35_output() (bit_clr(INT_CLKO, CBIT0)) |
Disable P35 meander output. | |
#define | is_timer0_mode0_P35_output_enabled() (test_if_bit_set(INT_CLKO, SBIT0)) |
Get output to pin P3.5 output flag enabled value. More... | |
#define | timer0_mode0_close_gate() (bit_set(TMOD, SBIT3)) |
Close timer starting gate. More... | |
#define | timer0_mode0_open_gate() (bit_clr(TMOD, CBIT3)) |
Open timer starting gate. More... | |
#define | is_timer0_mode0_gate_opened() (test_if_bit_cleared(TMOD, SBIT3)) |
Get timer starting gate state. More... | |
run in async mode | |
Timer run/stop/reload functions | |
#define | timer0_mode0_reload(ticks) |
Reload timer0 mode0 ticks on the fly. More... | |
#define | timer0_mode0_direct_reload(th0, tl0) |
Reload timer0 mode0 timer TL0 and TH0 on the fly. More... | |
#define | timer0_mode0_start(ticks) |
Run timer0. More... | |
#define | timer0_mode0_direct_start(th0, tl0) |
Run timer0 with direct set of TL0, TH0 registers. More... | |
#define | timer0_mode0_stop() |
Stop timer0. More... | |
#define | is_timer0_mode0_started() (TR0 == 1 && (is_timer0_mode0_gate_opened() || INT0 == 1)) |
Get timer0 mode0 started status. More... | |
run in sync mode | |
Timer run once functions | |
#define | timer0_mode0_delay(ticks) |
Run timer0 mode0 once and wait with program flow blocking timer not finished. More... | |
Functions and data structures for timer0 mode0.
This module supports general purpose timer0. Timer can work as COUNTER or TIMER.
Counter increments on external singnal (like pin 1/0 change state).
For timer0 in mode0:
Timer0 in mode0 can be used in sync (main prorgam flow blocked until timer overloaded) and interrupt (call interrupt handler on timer overloaded) modes.
#define is_timer0_mode0_gate_opened | ( | ) | (test_if_bit_cleared(TMOD, SBIT3)) |
Get timer starting gate state.
#define is_timer0_mode0_P35_output_enabled | ( | ) | (test_if_bit_set(INT_CLKO, SBIT0)) |
Get output to pin P3.5 output flag enabled value.
#define is_timer0_mode0_started | ( | ) | (TR0 == 1 && (is_timer0_mode0_gate_opened() || INT0 == 1)) |
Get timer0 mode0 started status.
#define timer0_mode0_12T_init | ( | ) |
Initialize mode0 12T for timer0.
#define timer0_mode0_1T_init | ( | ) |
Initialize mode0 1T for timer0.
#define timer0_mode0_close_gate | ( | ) | (bit_set(TMOD, SBIT3)) |
Close timer starting gate.
When gate is closed timer will ticks after start only when INT0 pin is HIGH
#define timer0_mode0_delay | ( | ticks | ) |
Run timer0 mode0 once and wait with program flow blocking timer not finished.
Before run timer0_mode0_12T_init or timer0_mode0_1T_init should be called.
After run program flow blocked until timer does not overloaded.
Dont mix call of timer0_mode0_delay with timer0_mode0_open_gate/timer0_mode0_close_gate calls.
ticks | uint16_t timer ticks count. |
#define timer0_mode0_direct_reload | ( | th0, | |
tl0 | |||
) |
Reload timer0 mode0 timer TL0 and TH0 on the fly.
Reload is available in modes 0, 2, 3.
th0 | uint8_t TH0 value |
tl0 | uint8_t TL0 value |
#define timer0_mode0_direct_start | ( | th0, | |
tl0 | |||
) |
Run timer0 with direct set of TL0, TH0 registers.
Before run timer0_mode0_12T_init or timer0_mode0_1T_init should be called.
After run program flow not blocked and interrupt will raised when timer is overloaded. Interrupt handler void timer0ISR(void) __interrupt(1) should be defined in user code. Interrupt is raised when TH0 = TL0 = 0xff + 1 (TH0, TL0 overload)
Timer rerun after overloaded and interupt handler called.
Dont mix call timer0_mode0_direct_start call with void timer0_mode0_delay call
th0 | uint8_t TH0 value |
tl0 | uint8_t TL0 value |
#define timer0_mode0_open_gate | ( | ) | (bit_clr(TMOD, CBIT3)) |
Open timer starting gate.
When gate is open timer ticks after starts
#define timer0_mode0_reload | ( | ticks | ) |
Reload timer0 mode0 ticks on the fly.
Reload is available in modes 0, 2, 3.
ticks | uint16_t timer ticks reloaded value. |
#define timer0_mode0_start | ( | ticks | ) |
Run timer0.
Before run timer0_mode0_12T_init or timer0_mode0_1T_init should be called.
After run program flow not blocked and interrupt will raised when timer is overloaded. Interrupt handler void timer0ISR(void) __interrupt(1) should be defined in user code.
Timer rerun after overloaded and interupt handler called.
Dont mix call timer0_mode0_start call with void timer0_mode0_delay call
ticks | uint16_t timer ticks count. |
#define timer0_mode0_stop | ( | ) |
Stop timer0.
Before stop timer0_start should be called. Dont mix timer0_stop call with timer0_mode0_delay call