One bit at a time, Slower and Less no of cables
required
Multiple bits at a a time, Faster and High number of cables required
Clock Skew: The time difference
between the data bits through
different channels of the same bus
From the above slide, parallel comm is a better option.
But, these are the few terminologies with which parallel comm is not preferred.
Cross Talk: Phenomenon or a change
in the signal by which a data
transmitted on one channel of bus
creates an undesired effect on
another channel.
This is how data sent serially
Serial Transmission Modes:
1) Asynchronous Data Transfer – Data bits are not synchronized with the clock line.
Format: One START bit(always 0), DATA bits, (PARITY bit) and a STOP bit(always 1).
2) Synchronous Data Transfer - Data bits are synchronized with the clock line.
Format: Data bits are sent in sismilar patter with the clock
Serial Comm Terminologies:
- Simplex Communication: In this mode of serial communication, data can only be
transferred from transmitter to receiver and not vice versa.
- Half Duplex Communication: this means that data transmission can occur in only
one direction at a time, i.e. either from master to slave, or slave to master, but not
both.
- Full Duplex Communication: full duplex communication means that data can be
transmitted from the master to the slave, and from slave to the master as
the same time!
- Baud rate: Signals per second or bits per seccond
Serial Comm Protocols:
- SPI: Serail Peripheral Interface (3 lines)
- I2C: Inter-Integrated Circuit (2 lines)
- Ethernet (8 lines)
- USB (4 lines)
- RS-232 (9 or 15 lines)
RS 232: Recommended Standard – 232 is a serial comm protocol
which is mostly used over the DB9 port also called serial port
RS232 is an interface to connect one DTE, data terminal
equipment to one DCE, data communication equipment at a
maximum speed of 20 kbps with a maximum cable length of
50 feet.
Logic Level: Is defined as a range of voltage that an IC can accept for a high(1)
and low(0).
Various logic levels are TTL, LVTTL and RS232.
HIGH LOW
TTL +3.5V to +5V 0 to +0.8V
LVTTL +2.2V to +3.3V 0 to +1.2V
RS232 -3 to -25V +3 to +25V
MAX232 is used to
convert TTL-RS232
logic levels
CP2101 is used
in USB-UART
conversions
USART in AVR
AVR has built-in USART with following features:
• Full Duplex Operation (Independent Serial Receive and
Transmit Registers)
• Asynchronous or Synchronous Operation
• Master or Slave Clocked Synchronous Operation
• High Resolution Baud Rate Generator
• Supports Serial Frames with 5, 6, 7, 8, or 9 Data bits
and 1 or 2 Stop Bits
The USART of the AVR can be operated in three
modes:
• Asynchronous Normal Mode
• Asynchronous Double Speed Mode
• Synchronous Mode
Setting up the frame….
First, set the baud rate (should be same for both
Tx and Rx)
Second, set the number of data bits to be sent
Next, get the buffer ready
Lastly, enable the transmitter/receiver
Registers in AVR:
UDR0: USART Data Register (16-bit)
The data is kept in this TxB and later it is taken by Tx shift
register and then it is serially transmitted on TxD pin.
Similarly for reception.
Registers in AVR:
UCSR0A: USART Control and Status Register A (8-bit)
Registers in AVR:
UCSR0B: USART Control and Status Register B (8-bit)
• RXCIEn: RX Complete Interrupt Enable Writing this bit to one enables
interrupt on the RXCn Flag. A USART Receive Complete interrupt will be
generated only if the RXCIEn bit is written to one, the Global Interrupt Flag
in SREG is written to one and the RXCn bit in UCSRnA is set.
Registers in AVR:
UCSR0C: USART Control and Status Register C (8-bit)
USBS0-USART Stop bit. 0:1-bit;1:2-bits
Registers in AVR:
UBRR: USART Baud Rate Register (16-bit)
Bits 0 to 11 are for USART Baud Rate (UBRRH contains the four MSB’s and UBRRL contains
the eight LSB’s of USART baud rate)
Bits 12 to 15 are reserved for future use.
Program to transmit letter “G” at 9600 baud with 8
data bits, 1 stop bit. With freq=8MHz
#include <avr/io.h>
Void usart_init (void)
{
UCSRB=(1<<TXEN);
UCSRC=(1<<UCSZ!)|(1<<UCSZ0)|(1<<URSEL);
UBRRL=0x33;
}
Void usart_send (unsigned char ch)
{ //wait until UDR is empty, transmit “G”
While (! (UCSRA & (1<<UDRE)) )
UDR=ch;
}
Int main(void)
{ //intializze the USART do forever transmit “G” letter
Usart_init();
While(1)
Usart_send (‘G’);
Return 0;
}
To send the message “The CDAC” to serial Port continuosly
{
Unsigned char str[10]=“The CDAC”;
Unsigned char strLenght=10;
Unsigned char i=0;
While(1)
{
Usart_send(str[i++]);
If (i>=strLength)
i=0;
}
Return 0;
}
To receive bytes of data serially and put them on PORTA. Set the baud rate at
9600, 8-bit data and 1 stop bit
#include <avr/io.h>
Int main(void)
{
DDRA=0xFF;
UCSRB=(1<<RXEN);
UCSRC=(1<<UCSZ1)|(1<<UCSZ0)|(1<<URSEL);
UBRRL=0x33;
While(1)
{
While(!(UCSRA & (1<<RXC)));
PORTA=UDR;
}
Return 0:
}