Instructions
320Libraries
© 2013 Conrad Electronic
serport interface number (0 = 1st serial port, 1 = 2nd serial port, ...)
par interface parameter (see par table)
baud baud rate
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.5 Serial_Init_IRQ (Mega)
Serial Functions Example
Syntax
void Serial_Init_IRQ(byte serport, byte ramaddr[], byte recvlen,
byte sendlen, byte par, word divider);
Sub Serial_Init_IRQ(serport As Byte,ByRef ramaddr As Byte,recvlen As Byte,
sendlen As Byte, par As Byte, divider As Word)
Description
The serial interface gets initialized for usage in interrupt mode. The user has to provide a global variable
as a serial buffer. This buffer services as a storage for the data that is sent to the serial interface and is re-
ceived from it. The size of the buffer must be length of the send buffer plus the length of the receive buf-
fer plus SR_BUF (see Example).
The maximum value for the size of the send and the receive buffer is 255 bytes each. 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).
The user supplied buffer must be available the whole time the serial interface is working. Since after
leaving a function the local variables are no longer available, it is most times a good idea to provide the
user supplied buffer as a global variable.
It is possible to activate the DoubleClock Mode of the Atmel AVR. See Divider.