Instructions

319 C-Control Pro IDE
© 2013 Conrad Electronic
baudrate. This has the advantage that baudrates, that have no exact divider value can be represented. E.g.
MIDI: The new value SB_MIDI (=803a Hex) lies much nearer at the correct value of 31250baud. An example
for 19200 baud: The normal divider value for 19200 baud is 002f (Hex). If DoubleClock Mode is used, the
divider must be doubled (=005e Hex). Then set the Hi-bit, and the alternative divider value for 19200 baud
is 805e (Hex).
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:
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
5.20.4 Serial_Init (AVR32)
Serial Functions Example
Syntax
void Serial_Init(byte serport, byte par, dword baud);
Sub Serial_Init(serport As Byte,par As Byte, baud As ULong)
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".
There is a chance to miss received characters when using the polled serial routines, especially at
high baud rates. If this is an issue, please use the interrupt driven serial routines with Serial_Init_IRQ() in-
stead of Serial_Init().
Parameter