I have written a code which intializes 2 UARTs, i.e., UART-1 and UART-2. The code works pretty fine. I am using the same code on two different controllers.
Simply say i have a board with two controllers and are connected by UART-2. (LPC2368) Now i using same program in the two controllers.
I have used a LED in both the controllers to make them glow just before the program enters the while loop.
Now my problem when i power up the board the LED is not being glowing. So i have to assume that my code did not reach the while loop.
I have observed that if i comment UART2 intialization (which is used for inter communication between the two controllers) then the LED glows and the code is working fine.
So again i removed the comments at UART-2 intialization and started debugging one of the controller. Again it works fine.
Now what i did is i have made one controller in reset at power ON and let the other controller intilaize. and after some time say 5 secs i have released the 1st controller from reset and let it intialize. Now also it is working.
Now my conclusion if i run the board with the same code in both the controllers it is not working. I mean both the controllers are trying to intialize the UART-2 at the same time.
So how can i handle this? What could be the reason for this problem? I am unable to debug since only after power up i can debug which leads to the two controllers intializing at different time intervals.
Can some one please help me with this.
>>Sorry i couldnt insert tabs for readability.
Or apparently read the posting instructions telling you to use PRE tags for source code?
Ever connected a serial cable to a PC while you have a terminal program up and running and seen one or more random characters show up on the screen?
If the UART thinks it has seen the first flank of a start bit, it will start to run a full character cycle and then report back the outcome. So there is no need for the other side to actually send any character to trick the receiving end to think that a character has been sent.
So when initializing a UART, you need to always be prepared for data arriving - and be prepared for that data to be valid or invalid.