BASCOM 串口和定時器操作

<code>$regfile="m168def.dat"
$crystal= 8000000
Config Timer1 =Timer, Prescale=1

$baud = 19200 ' use baud rate

$hwstack = 32 ' default use 32 for the hardware stack

$swstack = 10 ' default use 10 for the SW stack

$framesize = 40 ' default use 40 for the frame space
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com1:" For Binary As #1

Enable Interrupts
Enable Ovf1
Enable URXC
On URXC Receive_isr
On Ovf1 Overflow_isr
dim b1 as byte

Ddrc=&Hff
Timer1=65130

Print "Hello"

Dim Bb1 As Byte


Do
Nop
if Bb1=&h31 then
Print #1 , "test serial port 2"
Print #1 , Bb1
Bb1=0
end if


Loop
End

Overflow_isr:
Portc.0=not Portc.0
Timer1=65130
Return

Receive_isr:
Inputbin Bb1,1
Portc.1=not Portc.1

Return/<code>


BASCOM 串口和定時器操作


分享到:


相關文章: