I decided to keep this post separate from my last one because it's mostly a rant about stupid bugs. I spent the last two days tracking down a bug that I had though was due to race condition in the stack. When I run the board without a JTAG, then everything is fine and it runs with no problems. However when I run it on a JTAG debugger, then the system hangs at a certain point. I figured that the JTAG was causing some type of timing change which was able to hit a specific condition to cause a hang. Hence I spent the last two days stepping through the circuit and tracing different areas to see if I could locate where it was hanging. I couldn't.
I then checked the JTAG traces to see if there was any signal integrity problems on the lines. Finding nothing, I though the crystal settings on the JTAG ICE might be incorrect causing an unstable clock when the ICE was used. No change on any setting. Nearly in tears from the frustration this was causing me, I started probing around the board with the scope. I then found that the supply voltage was at 4.2V instead of 5V coming in from the USB bus. Looking down at the USB hub, I saw that the power cord was slightly unplugged from the power jack.
So to make a long story short, the USB hub had lost its power connection and had reverted to supplying bus power directly from the PC. When a hub is bus powered rather than self powered (having its own DC supply), each port can only supply a max of 100 mA. Had the power been fully plugged in, it would have been able to go up to 500 mA. That's why when I ran the board alone with the JTAG ICE turned off, it was completely fine, but using the JTAG ICE would suck enough power to drop the voltage down to 4.2V. That was just enough to let the microcontroller run a little and then go completely nuts at random points.
Man, sometimes I hate being an engineer...