From: Jason M. <jas...@gm...> - 2007-07-06 17:59:08
|
On 6/13/07, Dave Hylands <dhy...@gm...> wrote: > > How are you declaring your interrupt? If you're using an older gcc you > want to use SIGNAL and not INTERRUPT. For newer gcc's use ISR I double checked, this is correct for my gcc (ISR). I've done 1 Mb serial, which is generating interrupts 100,000/sec. > That still gives 160 instructions/interrupt. > > Make sure you're compiling with -Os Yep. Also, if it's at all possible make sure that there are NO function > calls in your interrupt handler. GCC is smart enough to only save the > registers that are actually used in the interrupt handler, but as soon > as you add a function call (inlined functions are fine), GCC no longer > knows which registers the called function might use, so it has to save > quite a few more. No function calls. > System clock / 256 is 62,500Hz and so I set Timer/Counter2 to increment > with > > the system clock and interrupt on the overflow, which I gather should > have > > the desired effect. However... my Robostix was soon unresponsive... > which > > makes sense I guess, as the quadrature decode logic is probably barely > > finished with the first interrupt before the next arrives at this > frequency. > > > > I am relatively new to this whole thing, but presuming I'm not > overlooking > > something, might anyone have a suggestion as to how to minimize the > error > > I'll observe on the encoder counts given the above? > > If you can't get that to work, I have some LS7366 chips for sale on my > web site. These have an SPI interface and maintain an internal 32-bit > counter. I was actually updating four counters in the ISR, I had managed to overlook this critical point. Further experimentation revealed the fourth was the straw that broke the camel's back. I scaled back to two, which works fine for now at the higher frequency... but eventually I'll need all of them. I may be back for those chips! :] Thanks for the help! |