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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/03/02 13:06
Read: times


 
#28443 - Serial port dilemma
Hi all! I am facing a strange problem.

DESCRIPTION OF WHAT I AM DOING
------------------------------
I am trying to communicate an AT89C51 with a PC. I configured baud rates on both systems to 19200 (SMOD = 1 in uC).

On the PC side, I have made a GUI in visual C. I am using CreateFile to open a handle to COM port. And using ReadFile / WriteFile to read / write to the COM port.

The GUI has the provision to open COM1 or COM2 at runtime, and also to close handle to any COM port using a button click. I can send any character using an edit box and any data that I receive is displayed in another edit box.

On the uC side, I simply transmit back anything that I receive. I am using MAX232 for...you know what..and I am also clearing TI after I transmit. I also clear RI as soon as I enter my Serial ISR. 11.0592 MHz crystal is used.

OBSERVATIONS
------------

1. Whatever I transmit (once the systems power-up), I receive correctly.

2. If I reset the uC, the data that I receive is not what I sent now, but what I sent the previous time, i.e. I have to send the data twice to receive the correct byte.

After re-setting uC, when I send something from PC, I get 0xFF in acknowledgement from uC. If I retry, I receive the correct byte. Now if I change the transmit byte, I still receive the previous byte. If I try again now, then byte received is correct.

This problem can only be rectified if I close the handle to the port (on PC) and then open it again. Then everything works as it was when it started (all OK). I have not tried lowering the speed.

3. If I remove the serial cable, reset the uC and then plug the cable back, the system functions normally.

Can anyone help or suggest anything ??

BTW I will try somethings today like, connect the LEDs to another uC port and output data on it, whatever the uC receives. I will surely bring you guys more results...meanwhile, you might have something interesting for me.

Regards
Aman



List of 11 messages in thread
TopicAuthorDate
Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      
RE: Serial port dilemma            01/01/70 00:00      

Back to Subject List