Serial Communication With AVR Microcontroller

by embeddedbymedhavi in Circuits > Microcontrollers

72 Views, 0 Favorites, 0 Comments

Serial Communication With AVR Microcontroller

seial.png

BASICS OF SERIAL COMMUNICATION:

  • serial communication uses single data line making it much cheaper ·
  • enables two computers in different cities to communicate over the telephone ·
  • byte of data must be converted to serial bits using a parallel-in-serial-out shift register and transmitted over a single data line ·
  • receiving end there must be a serial-in-parallel-out shift register ·
  • if transferred on the telephone line, it must be converted to audio tones by modem ·
  • for short distance the signal can be transferred using wire ·
  • how PC keyboards transfer data to the motherboard ·
  • 2 methods, asynchronous and synchronous ·
  • synchronous method transfers a block of data (characters) at a time ·
  • asynchronous method transfers a single byte at a time ·
  • Uses special IC chips called UART (universal asynchronous receiver-transmitter) and USART (universal synchronous asynchronous receiver-transmitter) ·

Half- and Full-duplex Transmission

serial3.png
  • if the data can be transmitted and received, it is a duplex transmission
  • simplex transmissions the computer only sends data ·
  • duplex transmissions can be half or full duplex ·
  • depends on whether or not the data transfer can be simultaneous ·
  • If one way at a time, it is half duplex ·
  • If can go both ways at the same time, it is full duplex ·
  • full duplex requires two wire conductors for the data lines (in addition to the signal ground)

Asynchronous Serial Communication and Data Framing

seriel 4.png

· Asynchronous serial communication and data framing

  • ·data coming in 0s and 1s ·
  • to make sense of the data sender and receiver agree on a set of rules ·
  • Protocol ·
  • how the data is packed ·
  • how many bits/character ·
  • when the data begins and ends ·
  • Start and stop bits ·
  • asynchronous method, each character is placed between start and stop bits · called framing ·
  • start bit is always one bit ·
  • stop bit can be one or two bits ·
  • start bit is always a 0 (low) ·
  • stop bit(s) is 1 (high) ·
  • LSB is sent out first

RS232 Standards

serial 4.png
serrial 5.png

  • most widely used serial I/O interfacing standard
  • input and output voltage levels are not TTL compatible ·
  • 1 bit is represented by -3 to -25 V ·
  • 0 bit is +3 to +25 V ·
  • -3 to +3 is undefined ·
  • to connect RS232 to a microcontroller system must use voltage converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa ·
  • MAX232 IC chips are commonly referred to as line drivers

Data Communication Classification

serial6.png

  • DTE (data terminal equipment)
  • DCE (data communication equipment) ·
  • DTE - terminals and computers that send and receive data ·
  • DCE - communication equipment responsible for transferring the data ·
  • simplest connection between a PC and microcontroller requires a minimum of three pins, TxD, RxD, and ground

Write a Program to Transfer Letter "A" Serially at 9600 Baud, Continuously

avrtrans1.png

Simulation of transmit " A" is given in above.

C Code of transmit " A " :

Downloads

Write a Program to Transfer the Message " Welcome to All " Serially at 9600 Baud, 8-bit Data, 1 Stop Bit. Do This Continuously.

avrtran2.png

Simulation of transmit " Welcome To All " is given in above.

C Code of transmit " Welcome To All " :

Downloads

Program the AVR to Receive Bytes of Data Serially and Put Them on PORTB. Set the Baud Rate at 9600, 8-bit Data, and 1 Stop Bit.

avrreceive.png

Simulation of receive is given in above.

C Code of receive :

Downloads

Any Query related Embedded System , IOT and Raspberry PI go to My Blog:
embeddedbymedhavi