📄 timer2b.bas
字号:
'--------------------------------------------------------------
' (c) 1997-2000 MCS Electronics
'--------------------------------------------------------------
' file: TIMER2b.BAS
' *TIMER2 used in auto reload mode
' Select 8052.dat or 89s8252.dat !!!
'--------------------------------------------------------------
Dim Count As Byte , Gt As Byte
'--------------- TIMER 2 modes ------------------
'0=16-bit auto reload
'1=16-bit capture
'2=baudrate generator
'3=receive only
'4=transmit only
'5=clock output
'------------------------------------------------
Config Timer2 = Timer , Gate = Internal , Mode = 0
'you could also count up or down by specifying :
'Config Timer2 = Timer , Gate = Internal , Mode = 0 , direction=up|down
'the direction controlled with the T2EX pin. See helpfile for more details
On Timer2 Timer_2_int
Load Timer2 , 10000 'when the timer reaches 10000 an interrupt will occur
Enable Interrupts 'enable the use of interrupts
Enable Timer2 'enable the timer
Rem Setting Of Priority
Priority Set Timer2 'highest priority
Start Timer2 'start the timer
Count = 0 'reset counter
Do
Input "Number " , Gt
Print "You entered : " ; Gt
Loop Until Gt = 1 'loop until users presses ESC key
Stop Timer2
End
Rem The Interrupt Handler For The Timer2 Interrupt
Timer_2_int:
Inc Count
If Count = 100 Then
Print "Timer2 Interrupt occured after 1 sec"
Count = 0
End If
Return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -