In this program, I have a function where I have two for loops. Here's an example: "for (j = 0; j < 3; j++) { for (i = 0; i < 8; i++) { time = 1612 - (4 * i); wait (); } if (j < 2) { time = 1588; wait (); while (incoming); } }" Well, the software simulation works perfectly. However, when I try programming a chip and implimenting it, it gets stuck somewhere in this loop. Do any of you happen to know why? Thanks
Well, since you didn't specify the data types for i and j, or the wait function, or how time is used (and its data type), and what incoming does and is set to... My guess is that it is hanging in while(incoming). But, that's just a WAG and is probably not correct. If it works under simulation then there's something in your hardware that you must not be simulating. Jon
Allow me to correct myself. I have everything initialized. i, j, and time are all ints. The "while (incoming)" is for a pin. I have input coming in on P3.2 (which is incoming) and while that is high, the program waits until it is turned low again from an outside source.
How come you know it's stuck "somewhere in this loop", but not where exactly that is? And what about wait()? What is it, and why do you modify "time" before each call of it? Does it use "time"?
The loop is suppose to gather information from P3.2 at a certain baud rate. The wait() function uses timer0 to delay enough time so the next bit can be picked up off of the line. I know it's in this loop because I altered the code to have some LEDs turn off right before and right after this loop. They turn off before, but if it's after this loop, then they don't turn off, like they're getting stuck in it.
Nevermind, I got it working now.
What was the problem? Jon
I had a stack overflow that Keil does not account for.