timer2b.bas
来自「82 sample programs written in BASCOM-805」· BAS 代码 · 共 51 行
BAS
51 行
'--------------------------------------------------------------
' (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 + =
减小字号Ctrl + -
显示快捷键?