Circuit is quite simple in any project we can add this facility to do serial communication with computer.
For that UART section of 8051 microcontroller is used. Rx and Tx line of microcontroller are connected to the computer’s serial port via MAX232. MAX232 is used to reverse the logic. Because RS232 works on negative logic and 8051 work on positive logic.
8051 is programmed in such a way that serial communication will take place at the speed of 9600 bps.
The circuit diagram is given below…
List of Components
1.8051 microcontroller (any variant)-one
2.MAX232 - one
4.Resistor 330 Ohm - two
5.Electrolytic disc capacitor 1uF/20V - four
6.Electrolytic disc capacitor 10uF/20V - four
7.Ceramic capacitor - 33 pf- two
8.DB9 9 Pin connector
For making of cable between 8051 circuit and PC serial port always use shielded cable.
Program is divided into modules.
Serial port function is used to initialize the UART of 8051 microcontroller.
Speed of serial communication is et to 9600 bps.
SerialPrint (long int arg)
unsigned char NumArray;
// Convert number into string
sprintf (NumArray, "%d", arg);
// Send string to HyperTerminal
} // End of SerialPrint
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
TMOD = 0x26;
EA = 1;
}// End of SerialInit
Void StringToTerminal (unsigned char *temp)
SBUF = *temp;
SBUF = LF;
SBUF = CR;
} // End of StringToTerminal
After that StringToTerminal() is used the string to the serial port of computer. SerialPrint() is used to send any integer variable to the serial port. These two function can be used in any project.
StringToTerminal() = to send any string to PC.
SerialPrint() = to send content of any variable to PC.
StringToTerminal function is most important. Here we are sending characters one by one. instead of checking flags we are giving 10 msec delay. our assumption is that within this time communication will take place.
Sending complete string, Line feed and carriage return characters are also send so that curser at hyper terminal will come to next line.
This is Keil Project and can be open directly in Keil IDE. If you do not have KEIL IDE, then you can download it from following link at free of cost.
At this page click on the Evaluation Software Link. This software is free of cost for evaluation purpose only.
Setup of HyperTerminal
1. Start Menu>> Programs >> Accessories >> Communications >> Hyper Terminal
After that HyperTerminal window will open. If it prompt for checking of default program as shown in fig, then say yes to it.
2. Click Yes
3. Type Connection Name as 8051 (or as per your Choice)
pic of connection description
3. Select COM PORT (1, 2, 3 etc) which ever is available. (NOTE: Very Less USB- TO Serial Converters as Reliable)
So use Standard Serial Port
pic of connect to
4. Do Port Setting as Given Below.
pic of port setting
Then Click Apply and OK.
5. Now you See Bottom Left side It shows “Connected”.
Pic of HyperTerminal Screen
6. Now burn the Hex File (Given) and Switch on the Circuit after Connecting Specified Serial Port .You will see output as Follows:
Pic of output at HyperTerminal
If every thing works fine you will see Hello World on the screen. Otherwise check your setup.
Debugging of 8051 application can be very easy if we able to send debug information to serial port of PC. And its output can be seen on HyperTerminal (in Windows ) or Minicom ( in Linux ). We can display content of any variable, memory location etc. We can also print other useful information on serial terminal which could replicate the flow of the code.
Such messages can be displayed like “Entering into function A”, “Existing from function B” , “Data is send” etc. So this is very cost effective solution because we do not need any In Circuit Emulator or any other debugging device. In this tutorial circuit and working code is shown.
Logos and brand names used in this site are belonging to their respected owners. We have used them here only for the purpose of information. Enable Active X control from internet options of internet explorer to view all element of this site.
Best viewed in 1024x768 pixels
8051 AND HYPERTERMINAL
Debugging 8051 Code with Serial Terminal
because information matters Tutorials | Infoletters | News | Search