BAUD

From MCS Wiki AVR
Jump to: navigation, search

Contents

Action

Changes the baud rate for the hardware UART.

 

 

Syntax

BAUD = var

BAUD #x , const

 

 

Remarks

Var

The baud rate that you want to use.

X

The channel number of the software UART.

Const

A numeric constant for the baud rate that you want to use.

 

Notice.jpg
 Do not confuse the BAUD statement with the $BAUD compiler directive.

 

And do not confuse $CRYSTAL and CRYSTAL

 

$BAUD overrides the compiler setting for the baud rate and BAUD will change the current baud rate.

So $BAUD is a global project setting in your source code while BAUD will change the baud rate during run time.

You could use BAUD to change the baud rate during run time after the user changes a setting.

 

BAUD = ... will work on the hardware UART.

 

BAUD #x, yyyy will work on the software UART.

 

When you use a software UART and change the baud rate at run time using BAUD, you must set the baud rate after the OPEN statements as well.

When you do not use BAUD, there is no need to set it. So for example :

 

Open "COMC.1:9600,8,N,1" For Output As #1

print #1 , "this is a test 9600"   'no need for BAUD since 1 baud rate is used

 

But when BAUD is changed :

Open "COMC.1:9600,8,N,1" For Output As #1

baud #1 , 9600  'we need to set it since we change baud at run time

print #1 , "this is a test 9600"

 

baud #1 , 115200

print #1 , "this is a test 115200"

  

See also

$CRYSTAL , $BAUD , BAUD1

 

 

ASM

NONE

 

  

 

Example


$regfile = "m48def.dat"
$crystal = 4000000
$baud = 19200
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
Print "Hello"
 
'Now change the baud rate in a program
Baud = 9600
Print "Did you change the terminal emulator baud rate too?"
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language