Most viewed

30 Nov 2011

Serial Communication RS232


Description

With serial communication you can exchange data with the AVR-microcontroller and your PC. Allmost all AVR-microcontroller have a UART (Universal Asynchronous Reciever/Transmitter) on board of the chip (accept for the AT1200 and some ATTiny microcontrollers). The data transmission between the PC and the microcontroller is serial and asynchronous, serial means that the bits are send one after the other and asynchronous means that there is no clock signal to clock in the data that is send or recieved. One byte is transmitted in 10 bits, 1 start bit, 8 data bits and one stop bit, as you can see in the figure below.
Serial Communication
The serial data transmission has a standard that is called RS232. According to this standard a logical "0" has a voltage level between -15V and -5V and a logical "1" has a level between +5V and +15V. The AVR-microcontrolers use 5V (TTL-level) to transmit signals. So the signals needs to be converted, this can be done with the MAX232, that only needs a 5V power supply to convert the signal from TTL-level to RS232 level and reverse.
Transmission between two RS232 devices can take place with a maximum distance of 15 meters.

Hardware

Below you can see the schematic of how the RS232 convertor is connected to the AT microcontroller.
Serial Communication sch

Software

With BASCOM you can easily write software to communicate with the AVR-microcontroller, because BASCOM has several commands for the serial communication. Below is an example program, as you can see it takes little effort with BASCOM to implement serial communication into your microcontroller system. The program will print text in the terminal program. To test the program you can use the BASCOM terminal emulator or Hyperterminal, or my own terminal program. The settings for the COM port are: COM1,9600,N,8,1.

Downloads
FileDescriptionFile size
Download this file (Serial Communication.bas)Serial Com~.basAVR BASCOM source file1 Kb
Download this file (Serial Communication.hex)Serial Com~.hexhex file2 Kb

No comments:

Post a Comment

Confused? Feel free to ask

Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.

Note:
Please do not spam Spam comments will be deleted immediately upon my review.

 

Based on your view




You have to try this

This is trending now #