📄 timer2.bas
字号:
'--------------------------------------------------------------
' (c) 1997-2000 MCS Electronics
'--------------------------------------------------------------
' Note : BETA-status
' file: TIMER2.BAS
' demo: Capture mode of TIMER2
' *TIMER1 is used for RS-232 baudrate generator
' Select 8052.dat or 89s8252.dat !!!
'--------------------------------------------------------------
Dim Count As Byte , Gt As Byte , I As Word
Config Timer2 = Timer , Gate = External , Mode = 1
'Timer2 = timer : timer 2 operates as a counter
'Gate = External : a 1 to 0 transition on T2EX will capture the timer registers
'Mode = 1 : capture mode
Counter2 = 0 'reset timer2
On Timer2 Timer_2_int
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:
If T2con.6 = 1 Then 'caues by a transition
I = Capture 'get value from capture register
Print I
Else 'must be an overflow
Print "overflow"
End If
Return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -