ps/2 protocol interrupts


i’m playing around with two touchpads connected to
one arduinoNG.

everything seems to work fine - i can read extended
packets from the pads:
absolute x, absolute y, z (pressure)

i modified the ps/2-mouse-example from the playground
and attached an interrupt instead of the while-loops to
check if the CLOCK-line is FALLING (which means that the
pad is ready to send data).

it doesn’t work perfectly because i shouldn’t use any
delays anymore. now the first call of the interrupt works
perfect but then the program stucks again inside of
a whileloop, which is essentially for datatransmisson
(i think)

for(count=0; count<n; count++);

what has n to be to delay, for example 100us?

thanks in advance,

Instead of using a busy loop, maybe you should count timer ticks. Look at the actual code in delayMicroseconds() - you want to do the same thing except not disable interrupts.

Using a for loop like that isn't very reliable. First of all, how the compiler optimizes things will effect how (or sometimes if) the loop is done. So if a new avr-gcc or IDE comes out you might have to recalibrate. Second, how long the loop takes willl vary depending on how many interrupts the arduino services - which you don't have much control over. And finally, although it's rare, not all chips use the same clock speed.

Counting ticks is better. The timer is just a register and the math isn't that hard.

just a suggestion...

thanks for your thoughts!

i have some code from the manufacture of the pads (cirque) for interfacing the touchpads.

they define functions like delay_100us() for delaying during the program and inside of these functions the use for-loops...

i also heard that you should not use delays if you're working with interrupts?