178
Libraries
© 2008 Conrad Electronic
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
). 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
table par definitions:
Definition
Function
SR_5BIT
5 Bit char length
SR_6BIT
6 Bit char length
SR_7BIT
7 Bit char length
SR_8BIT
8 Bit char length
SR_1STOP
1 stop bit
SR_2STOP
2 stop bit
SR_NO_PAR
no parity
SR_EVEN_PAR
even parity
SR_ODD_PAR
odd parity
Содержание C-Control Pro Mega Series
Страница 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Страница 9: ...VIII Inhalt 2008 Conrad Electronic ...
Страница 10: ...Part 1 ...
Страница 17: ...Part 2 ...
Страница 23: ...Part 3 ...
Страница 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Страница 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Страница 58: ...Part 4 ...
Страница 91: ...82 IDE 2008 Conrad Electronic ...
Страница 92: ...Part 5 ...
Страница 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Страница 136: ...Part 6 ...
Страница 231: ...Part 7 ...
Страница 240: ......