Posts

Showing posts from February, 2011

Simple Serial Communication Using 8051

Code: #include <REGX51.H> #include <stdio.h> /* prototype declarations for I/O functions */ sbit MES1 = P2 ^ 0 ; sbit MES2 = P2 ^ 1 ; sbit MES3 = P2 ^ 2 ; sbit MES4 = P2 ^ 3 ; sbit MES5 = P2 ^ 4 ; int i; void time1ms (); void delay ( int n); void main ( void ) { /* execution starts here after stack init */ SCON = 0x52 ; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20 ; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xfd ; /* TH1: reload value for 9600 baud@11.0592mhz */ TR1 = 1 ; /* TR1: timer 1 run */ TI = 1 ; /* TI: set TI to send first char of UART */ while ( 1 ) { P2 = 0xFF ; if (MES1 == 0 ) { printf ( "Welcome Serial Data Transfer \n " ); printf ( "Inside Conditional 1 \n " ); delay( 1...