Hi, I am trying to perform serial communication with two AT89S52 MCs. Now the problem is that sometime everything works fine, but sometimes not. ------ Hardware Config-------- ---> RC reset circuit ---> 11.0592 MHz crystal ---> Mode 1 for serial communication with 9600 baudrate ---> Port 2 as output port at receiver side
Hardware is working fine with simple programs like LED blinking, but when it comes to serial communication, nah ..........behaves randomly.... Any suggestion will be valuable for me.
Sorry, but we aren't capable enough to be able to guess what you mean with "behaves randomly". And you haven't really given us any information what your code looks like, or what attempts you have made to try to debug or if you have looked at signalling using an oscilloscope.
We can't even figure out if "sometime everything works fine" means you sometimes have working serial communication. Or if you mean that your blinky program runs fine but your serial communication code fails.
My LED blinking program is working fine. But in case of serial communication sometime it works but sometime not, means from 10 attempts 3 times my h/w will do right things and rest of the time just doing weird things. I am using leds for debugging purpose on port 2. According to my program when data is received two leds will glow, but in reality sometime only one led glows this is the weird thing which i tried to mention earlier. And there is one another issue that sequence of switching on Rx and Tx ckt matters or not??
And thanks for your time Per Westermark.....
Since I have read your code, it is instantly obvious to me why only one LED sometimes glows. Wait a minute - read what code??? Don't you think you have to help us a bit further and actually post some code or tell us exactly what your code does?
Maybe your issue is just the start sequence between the two processors - how do you synchronize the communication if sometimes unit A boots before unit B, and sometimes unit A boots after unit B?
I remember a time many moons ago where you wrote polite, direct and helpful responses. Not these sarky which you have become fond of posting.
And do you have any good suggestions how to get the posters to realize that the readers on this forum don't have access to any more information than the facts that the poster writes?
If someone complains that one LED sometimes doesn't behave as expected, we can't know why. We can't know what is expected. We can't know what decisions the program does to decide if the LED should be lit or not.
If you notice, I did point out the lack of information in my first post. So the OP did make a second post, that still requires the reader to have access to information we just can't have access to without first having hacked the OP:s computer.
Please tell, how we get posters to switch side and pretend that they are an outside forum reader, and try to figure out exactly how much is obvious from their posts?
When someone posts and relates to their code, we often do have to see that code to actually be able to understand the references made. In this case, we know zero about the meaning of the LEDs, so it means zero to us if a LED is lit or off or flashing wildly. Only the OP can help with that.
Ok Mr. Per Westermark, here my codes are, ; Written in assembly using keil ; Codes for transmitter org 00h mov tmod,#20h ; timer 1 in auto reload mode mov th1,#0fdh ; for baudrate 9600 mov scon,#50h ; for selection of mode 1 with REN set to 1 setb tr1 start: mov sbuf,#0fh ; as leds are connected at port 2 with pins 0,2,4,6 next: jnb ti,next clr ti sjmp start end
;For receiver ; UART initialization is similar to previous one ;uart is initialized ; timer 1 is started mov p2,#00h start: jnb ri,next mov a,sbuf mov p2,a clr ri sjmp start end And for your kind information as i am transmitting the data continuously, and i am using UART mode for serial communication then why does synchronization matters between Rx and Tx. Let me give you some more information --> Using wired communication in simplex mode...
Now i hope that this information is sufficient about my project, if you wanna know something else then no problem, i will try to share as much as i can....
many threads have gone astray because the code was retyped into the post use cut-and-paste and read the instructions for posting code
if that is not the case, then look at this one start: jnb ri,next
my mistake... extremely sorry about that
; Written in assembly using keil ; Codes for transmitter org 00h mov tmod,#20h ; timer 1 in auto reload mode mov th1,#0fdh ; for baudrate 9600 mov scon,#50h ; for selection of mode 1 with REN set to 1 setb tr1 start: mov sbuf,#0fh ; as leds are connected at port 2 with pins 0,2,4,6 next: jnb ti,next clr ti sjmp start end ; Codes for transmitter org 00h mov tmod,#20h ; timer 1 in auto reload mode mov th1,#0fdh ; for baudrate 9600 mov scon,#50h ; for selection of mode 1 with REN set to 1 setb tr1 mov p2,#00h start: jnb ri,start mov a,sbuf mov p2,a clr ri sjmp start end
The second block of code is for receiver not for transmitter.... and yes that line is commented so i think that is not affecting my hardware right......
you DO have a MAX232(equivalent) between your chip and the PC I hope
Erik
Thanks for your help, but as i mentioned earlier i am trying to perform serial communication in wired mode between two MCs, so MAX232 is still required..??
Yes, if you have some distance between your two processors then you should use MAX232 or similar on both sides. Logic-level communication isn't robust for longer distances - it is intended for use within a PCB or for shorter cable distances to a neighbour PCB.
Well lets see, i will try that too.. and once again thanks to all of you for your valuable time and comments.