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

Back to Subject List

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


 
#161817 - Able to send from PC with the details..but. receive
Responding to: ???'s previous message
With your help I am succeded in receiving the data from PC to Micto controller..pla have a look in the code. .but I am unable to send the data back to PC. My connections are like this..

Pin 11 of 8051 connected to Pin 11 of Max 232 and
Pin 14 ofMax 232 Connected to Pin 2 DB-9(RXD)..

I am using simple VB program to send and receive data from COM1.

Is it require to connect other pins like DTR and DSR for the below code....

Jan I didn't find any connects in the PDF link sent by you i.e. RS232gd.pdf..

My latest code is...

*********************************************************************************
#include<stdio.h>
#include<at89x52.h>



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

void sendCharacter(unsigned int chr);

void main()
{

unsigned int chr = 0x31; /* 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 = 0xFD; /* reload value for 2400 baud */
TL1 = 0x00;
TR1 = 1;
TI = 1;



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

while (1==1)
{

chr = getCharacter ();

if ( chr == '1')
{

for ( i = 0 ; i < 30000; i++)
{
P1_0 = 1;
}
sendCharacter(chr);
}
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);
}

void sendCharacter(unsigned int chr)
{
chr = chr +1;

TI = 0;
SBUF = chr;
while(!TI);
TI = 0;
}

**********************************************

There is some mistake either in connection or in 'sendCharacter' part which I am unable to trace out..

I need information for Handshake and to work above code to send data from 8051 to PC.

your help always takes us new hights...

thanks


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