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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/18/05 17:06
Read: times


 
#87899 - Serial Communication problem
Hello.
I'm trying to establish a communication between a AT89c51ED2 and a computer. I'm using RS232. I wrote the software and a program for microcontroller. the computer program uses a thread to read the serial port and microcontroller sends data in pre known format. it is supposed to send 10 bytes in each frame(every frame starts with 3 0xFF). the communication already has been established and works but from time to time the received data become irregular. I took precautions to make the thread safe( it uses a Semaphore-in VC++- for synchronization). in debug I also checked the received data(in serial read thread and in main thread) and it seems the arrived data has not the expected format and computer program works fine.this happens in very irregular patterns sometime 1 out of ten frame is faulty sometimes 1 out of 30000 so debug was a nightmare for me in past few days. many time during debug I noticed an extra 0xa is transmitted in the frame this repeats many times and causes loss of synchronization.
I rechecked microcontroller program many times.
for(j=0;j<10;j++) //transmit 10 characters
{
switch(j)
{
case 0:
Buf = 0;
Buf &= 0x7;
break;
case 1:
Buf = mV[0];
break;
case 2:
Buf = lV[0];
break;
case 3:
Buf = Prog[0];
Buf &= 0x7F;
break;
case 4:
Buf = mI[0];
break;
case 5:
Buf = lI[0];
break;
case 6:
Buf = ProgIndex[0];
Buf &= 0x7F;
break;
case 7:
Buf = mT[0];
break;
case 8:
Buf = lT[0];
break;
case 9:
Buf = cycleIndex[0];
Buf &= 0x7F;
break;
}//end switch
putchar(Buf);
}
can anybody gives any idea for debugging. how should I find out the problem. how can I narrow down the problem.
thank you.


List of 13 messages in thread
TopicAuthorDate
Serial Communication problem            01/01/70 00:00      
   are you            01/01/70 00:00      
      232            01/01/70 00:00      
         It should work            01/01/70 00:00      
   Perhaps it's a problem on the computer            01/01/70 00:00      
      really            01/01/70 00:00      
      COM port test            01/01/70 00:00      
   putchar()            01/01/70 00:00      
   Maybe it is just Noise            01/01/70 00:00      
   Baud Rate            01/01/70 00:00      
      Connections            01/01/70 00:00      
         me too            01/01/70 00:00      
            Thanks Erik            01/01/70 00:00      

Back to Subject List