Action
Configures the UART of AVR chips that have an extended UART like the M2560.
Syntax
CONFIG COMx = baud , synchrone=0|1,parity=none|disabled|even|odd,stopbits=1|2,databits=4|6|7|8|9,clockpol=0|1
Remarks
COMx |
The COM port to configure. Value in range from 1-4 |
baud |
Baud rate to use. |
synchrone |
0 for asynchrone operation (default) and 1 for synchrone operation. |
Parity |
None, disabled, even or odd |
Stopbits |
The number of stopbits : 1 or 2 |
Databits |
The number of databits : 4,5,7,8 or 9. |
Clockpol |
Clock polarity. 0 or 1. |
Note that not all AVR chips have the extended UART. Most AVR chips have a UART with fixed communication parameters. These are : No parity, 1 stopbit, 8 data bits.
The Mega2560 does support 4 UART's.
See Also
Example
'-----------------------------------------------------------------------------------------
'name :
'copyright : (c) 1995-2008, MCS Electronics
'purpose : test for M2560 support
'micro : Mega2560
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
$regfile = "m2560def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$hwstack = 40 ' default use 32 for the hardware stack
$swstack = 40 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
'The M128 has an extended UART.
'when CO'NFIG COMx is not used, the default N,8,1 will be used
Config Com1 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com2 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com3 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Config Com4 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
'Open all UARTS
Open "com2:" For Binary As #1
Open "Com3:" For Binary As #2
Open "Com4:" For Binary As #3
Print "Hello" 'first uart
Dim B As Byte
Dim Tel As Word
Do
Incr Tel
Print Tel ; " test serial port 1"
Print #1 , Tel ; " test serial port 2"
Print #2 , Tel ; " test serial port 3"
Print #3 , Tel ; " test serial port 4"
B = Inkey(#3)
If B <> 0 Then
Print #3 , B ; " from port 4"
End If
Waitms 500
Loop
Close #1
Close #2
Close #3
End