ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8215
Скачиваний: 1
© MCS Electronics, 1995-2007
'The following code shows how to use the TIMER0 in interrupt mode 'The code is block remarked with '( en ')
'( |
|
'Configute the timer to use the clock divided by 1024 |
|
Config Timer0 = Timer , Prescale = 1024 |
|
'Define the ISR handler |
|
On Ovf0 Tim0_isr |
|
'you may also use TIMER0 for OVF0, it is the same |
|
Enable Timer0 |
' enable the timer |
interrupt |
'allow interrupts |
Enable Interrupts |
|
to occur |
|
Do |
|
'your program goes here |
|
Loop |
|
'the following code is executed when the timer rolls over |
|
Tim0_isr: |
|
Print "*"; |
|
Return |
|
') |
End
CONFIG TIMER1
Action
Configure TIMER1.
Syntax
CONFIG TIMER1 = COUNTER | TIMER | PWM ,
EDGE=RISING | FALLING , PRESCALE= 1|8|64|256|1024 ,
NOISE CANCEL=0 |1, CAPTURE EDGE = RISING | FALLING ,
CLEAR TIMER = 1|0,
COMPARE A = CLEAR | SET | TOGGLE I DISCONNECT ,
COMPARE B = CLEAR | SET | TOGGLE I DISCONNECT ,
PWM = 8 | 9 10 ,
COMPARE A PWM = CLEAR UP| CLEAR DOWN | DISCONNECT
COMPARE B PWM = CLEAR UP| CLEAR DOWN | DISCONNECT
Remarks
The TIMER1 is a 16 bit counter. See the hardware description of TIMER1. It depends on the chip if COMPARE B is available or not.
Some chips even have a COMARE C.
The syntax shown above must be on one line. Not all the options need to be selected.
Here is the effect of the various options.
EDGE |
You can select whether the TIMER will count on the falling or rising edge. |
page -390- |