Serial_Init - Conrad C-Control Pro Mega Series Manual

Table of Contents

Advertisement

6.15.3 Serial_Init

Serial Functions
Syntax
void Serial_Init(byte serport,byte par,byte divider);
Sub Serial_Init(serport As Byte,par As Byte,divider As Byte)
Description
The serial interface gets initialized. The parameter par is defined through successive or-ing of predefined
bit values. The values of character length, stop bits and parity are or'd together. E.g. "SR_7BIT | SR_2STOP
| SR_EVEN_PAR" means 7 bit character length, 2 stop bits and even parity (see Example). An example in
BASIC Syntax: "SR_7BIT Or SR_2STOP Or SR_EVEN_PAR". The baud rate is defined as a divider value
(see divider table).
It is possible to activate the DoubleClock Mode of the Atmel AVR. This happens if the Hi-bit of the
divider is set. In DoubleClock mode the normal value from the divider table must be doubled to get the
same baudrate. This has the advantage that baudrates, that have no exact divider value can be
represented. E.g. MIDI: The new value SB_MIDI (=0x803a) lies much nearer at the correct value of
31250baud. An example for 19200 baud: The normal divider value for 19200 baud is 0x002f. If
DoubleClock Mode is used, the divider must be doubled (=0x005e). Then set the Hi-bit, and the alternative
divider value for 19200 baud is 0x805e.
Parameter
serport interface number (0 = 1st serial port, 1 = 2nd serial port, ...)
par
interface parameter (see par table)
divider baud rate initialization (see table)
table par definitions:
SR_1STOP
SR_2STOP
SR_NO_PAR
SR_EVEN_PAR
SR_ODD_PAR
© 2008 Conrad Electronic
Example
Definition
SR_5BIT
SR_6BIT
SR_7BIT
SR_8BIT
Function
5 Bit char length
6 Bit char length
7 Bit char length
8 Bit char length
1 stop bit
2 stop bit
no parity
even parity
odd parity
Libraries
178

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

C-control pro mega32C-control pro mega128

Table of Contents