FOR ANY QUERRY REGARDING BIOMEDICAL PROJECTS             BIOTECHNOLOGY LABS FOR MAKING PROJECTS             Study Shows Significant Advantages of Computer-Assisted Robotic Total Knee Replacement             Online Examination - Computer/IT Project             Network Monitoring System Communication             TECHNICAL WRITING IN BIOMEDICAL             PROGRAM FOR SERIAL PORT COMMUNICATION WITH 8051             Tab Electronics Guide to Understanding Electricity and Electronics             Electronics Projects For Dummies             Bionic Eye Attempts to Restore Vision             DELAY TIMER PROJECT-BASIC ELECTRONICS             COMPUTER - IT PROJECT :- CREATE WEBSITE ON ONLINE NATIONAL POLLING             DEVELOPMENT OF AN AUTO-SUMMARIZATION TOOL -- IT PROJECT             Electronic Timer Switch - TIMER PROJECTS             DC motor speed control             BASIC ELECTRONICS-TIMER CIRCUIT DESIGN             BASIC ELECTRONICS- LDR PROBE             AUDIO WATTMETER             LOAD MATCHER             REMOTE SPEAKER SETUP            

Sunday, April 11, 2010

PROGRAM FOR SERIAL PORT COMMUNICATION WITH 8051

MOST OF US REQUIRE COMMUNICATION THROUGH SERIAL PORT OR COM PORT.

This program will read a complete line coming through my COM port in 8051.





This is the subroutine or function in c for accept line from serial port
void get_line(void)
{
char c, index=0;

while(c = getchar() != '\n')
{
buffer[index++] = c;
}
}


The main program
void main()
{
PCON = 0x80; // Double Baud Rate
SCON = 0x50; // SCON: mode 1, 8-bit UART, enable rcvr
TMOD |= 0x20; // TMOD: timer 1, mode 2, 8-bit reload
TH1 = BAUD_CONST; // TH1: reload value for desired baud. Calculate this for your crystal frequency
TR1 = 1; // TR1: timer 1 run
TI = 1;
RI = 0;

get_line(); //function call

}



REFERENCE BOOKS

No comments:

Post a Comment

Your Ad Here