The project I'm currently working on uses an ATmega168, with a main loop that runs at 60 Hz. About 3/4 of a loop iteration is spent refreshing a display. The display output routine is coded in assembler and exact timing is critical for a good picture.
Now I'm adding a PS/2 keyboard interface. I dropped in an interrupt-based keyboard handler I had previously written based on AVR313, and it kinda works. However, if an interrupt is received during the display routine, the picture flickers/scrambles noticeably.
I can't disable interrupts during the display routine because it's so long; almost no keypresses will be received. It doesn't matter how tiny I make the interrupt handler, because a delay of just a few cycles is enough to throw everything off.
So, how should I read signals off a PS/2 keyboard if I can't use interrupts? Currently my idea is to use a second AVR as a buffer; it would receive scancodes asynchronously and stores them in a queue, and the main AVR could pull them out when it's done updating the display. I don't think I can interleave keyboard polls into the display routine, since the my scanline frequency could be lower than the keyboard's clock frequency and I'd likely miss bits.
Anyone have a suggestion that doesn't require another AVR?