Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/28/09 12:47
Read: times


 
#161780 - max232 and 8051 serial communication problem
Dear all,

I am using below code for glowing LED using PC control. I am unable to switch on LED. Kindly correct belwo code. I am using max232(Maxim) for RS232 interface and AT89C51(atmel) as micro controller. The below code is not working. Kindly send me code in 'C' for 'getChar' and 'sendChar' using serial communication.


#include<stdio.h>
#include<at89x51.h>


unsigned int getCharacter(void); /* read a character from the serial port */


void main()
{

unsigned int chr; /* variable to hold characters in */
unsigned int i;


SCON = 0x50; /* mode 1, 8-bit uart, enable receiver */
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xF4; /* reload value for 2400 baud */
TR1 = 1;
TI = 1;


while (1)
{

chr = getCharacter ();

if ( chr == 20)
{

for ( i = 0 ; i < 30000; i++)
{
P1_0 = 1;
}
}
else
{
for ( i = 0 ; i < 30000; i++)
{
P1_0 = 0;
}

}

}
}

unsigned int getCharacter (void)
{
unsigned int chr; /* variable to hold the new character */


while (RI != 1) {;}

chr = SBUF;

RI = 0;
return(chr);
}

I tried replacing 'unsigned int' as 'char'. but no use. I am using Keil uvision 3 V 3.60 and flasher device using 'www.nskelectronics.com' product 8051 V 3. I am using similar cicuit only given in the follwoing link.. I used 1uF capacitors.



http://www.8051projects.net/lofiversi...89c51.html

List of 16 messages in thread
TopicAuthorDate
max232 and 8051 serial communication problem            01/01/70 00:00      
   max232 and 8051 serial communication problem            01/01/70 00:00      
   FAQ            01/01/70 00:00      
      Circuit is cleared            01/01/70 00:00      
         Keil            01/01/70 00:00      
            Keil and assembler            01/01/70 00:00      
               RE: Keil and assembler, etc...            01/01/70 00:00      
                  Able to send from PC with the details..but. receive            01/01/70 00:00      
                     unusable info            01/01/70 00:00      
                        package is MAX232 DIP package            01/01/70 00:00      
                           Do the Loopback!            01/01/70 00:00      
                           COM port configuration            01/01/70 00:00      
                              8051 hardware loop back is ok..but PC loop back            01/01/70 00:00      
   success at last            01/01/70 00:00      
      So what was the secret?            01/01/70 00:00      
         Corrected VB program            01/01/70 00:00      

Back to Subject List