Bạn đọc hết đoạn này sẽ hiểu ngay.
Syntax:
setup_timer_2 (mode, period, postscale)
Parameters:
mode may be one of:
T2_DISABLED, T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16
period is a int 0-255 that determines when the clock value is reset,
postscale is a number 1-16 that determines how many timer overflows before an interrupt: (1 means once, 2 means twice, and so on).
Returns:
undefined
Function:
Initializes timer 2. The mode specifies the clock divisor (from the oscillator clock). The timer value may be read and written to using GET_TIMER2() and SET_TIMER2(). Timer 2 is a 8 bit counter/timer.
Availability:
This function is only available on devices with timer 2 hardware.
Requires:
Constants are defined in the devices .h file.
Examples:
setup_timer_2 ( T2_DIV_BY_4, 0xc0, 2);
// At 20mhz, the timer will increment every 800ns,
// will overflow every 154.4us,
// and will interrupt every 308.8us.
|