CONFIG PRINT

From MCS Wiki AVR
Jump to: navigation, search

Contents

Action

Configure the UART to be used for RS-485

 

 

Syntax

CONFIG PRINT0 = pin

CONFIG PRINT1 = pin

CONFIG PRINT2 = pin

CONFIG PRINT3 = pin

CONFIG PRINT4 = pin

CONFIG PRINT5 = pin

CONFIG PRINT6 = pin

CONFIG PRINT7 = pin

Remarks

pin

The name of the PORT pin that is used to control the direction of an RS-485 driver.

mode

SET or RESET

 

Use PRINT or PRINT0 for the first serial port. Use PRINT1 for the second serial port. PRINT2 for the third UART and PRINT3 for the fourth UART.

 

When you use RS-485 half duplex communication you need a pin for the direction of the data. The CONFIG PRINT automates the manual setting/resetting. It will either SET or RESET the logic level of the specified pin before data is printed with the BASCOM print routines. After the data is sent, it will inverse the pin so it goes into receive mode.

You need to set the direction of the used pin to output mode yourself.

 

When CONFIG PRINT is used, the PRINT and PRINTBIN statements will switch the pin logic level, send the data, wait till all data is sent, and then will switch the pin logic level back.

CONFIG PRINT will not work with dynamic Xmega UARTS (BUART). You need to use a constant channel with the Xmega like PRINTBIN #1.

CONFIG PRINT will does not work with buffered serial output.

 

 

See also

CONFIG PRINTBIN

 

 

Example


'------------------------------------------------------------------------------
'name : rs485.bas
'copyright : (c) 1995-2006, MCS Electronics
'purpose : demonstrates
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'------------------------------------------------------------------------------
$regfile = "m48def.dat" ' we use the M48
$crystal = 8000000
$baud = 19200
 
$hwstack = 32
$swstack = 32
$framesize = 32
 
Config Print0 = Portb.0 , Mode = Set
Config Pinb.0 = Output 'set the direction yourself
 
Dim Resp As String * 10
Do
Print "test message"
Input Resp ' get response
Loop

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