> -----Original Message from Andy Kunz ----- > > Is there a way to get an analysis of where my code is spending it's time? > I'm stuck in a loop somehow, somewhere, and don't know where it is. Some > kind of profiler, that will let me plug into my hardware. Well, if you don't have any kind of ICE, and you can't use MPSIM because of a high hardware dependancy, and you don't want to buy a hardware ICE, here's what I've done: If there's any RS232 output or LCD output or single pin output available (plus a few bytes code space), simply print something unique at some point in the code, either before or after a suspicious loop. Scatter in about 4 or so of these printouts, before and after suspicious blocks of code, then you can home in on the problem pretty quick. Shoot, even with only one printout in your entire code, it would probably only take a few iterations to find the sticking point (i.e. binary divide your code). If there's only a single output pin available, you can just flip the sense of the output to trigger a scope or even a flip-flop, which only tells you that you've reached a certain point in the code at least once. But since the PIC's have minimal code size, you often can still quickly home in on your problem with this. If it's only temporarily getting stuck and you want a timing analysis, you could also just send a few pulses to a single pin, a unique number of pulses for each desired point in the code. The first point in the code with this would simply turn the pin on & off again, the second point would turn it on & off twice, etc... A scope would be needed at the other end for measurement. And a digital scope with averaging and min/max functions increases the fun-factor substantially. This is my preferred method, because it's simple, uses minimal code, and has the lowest odds of disturbing other parts of the code. If you lack all forms of scopes but still want a measurement, and have a bunch of code space and a timer available, you can measure suspect code blocks internally and spew out a byte or two of serial data in any units you choose, direct to your PC serial port (after appropriate interfacing of course). There are tons of software methods for this one, the goods ones which are reusable on your future projects, use your imagination... -Ed VanderPloeg Agile Controls