I'm looking for some ideas on how you guys do this. That is, as you prototype, build hardware, crank code, how do you figure if your cpu or clock has enough cycles to do all the tasks ?
I know, I know, you're supposed to build a complete and detailed spec beforehand, sometimes down to the cycle ... Hmmm. But projects grow, you change features, you come up with new ideas to implement something in a better way, etc, etc.
Most embedded apps are interrupt driven. The mainline code is usually fairly (or relatively) simple, and the bulk of the work is done in interrupts. Not that you spend much time in interrupts - the idea is be in and out as quick as you can.
So how are you determining if you're allocating time correctly ? There are a couple of methods I use, all pretty simple.
Toggle a pin on entry and exit of an interrupt. It helps to have spare pins available in prototyping so you can dedicate one for each interrupt you want to instrument. I'll develop on a larger AVR just for that reason sometimes, knowing that I will port down to a target AVR.
This give you a nice easily read hardware vizualization of the code occupancy. You can quickly see where time is being spent inordinately, and can see when things happen "out of order". It's also a fairly simple and obvious method, documented all over the place, but it deserves mentioning since it works ...
Another method is to put out a voltage that is indicative of cpu business. Use an 8-bit variable to hold the business value. This gets incremented on each entry to an interrupt or entry to a mainline processing function, and decremented on each pass through the idle loop section of the mainline. Limit it to 0-254.
Each pass through the idle section then spits that value out on a (hopefully spare) port as an 8-bit binary value. The port can also be updated each time the value is updated for even more "accuracy". This port can be passed into an R2R ladder or a DAC to give a direct voltage indication of cpu activity. Note - I haven't tried this yet, but it sounds sound.
One could also stuff that value into a PWM register to alter the duty cycle of a hardware PWM signal. Then just watch the duty cycle of the pin on a scope, or put it into an averaging circuit. I have done this - works pretty well.
So how do you guys attack this ?