Hi Barry,
The question really is how short of an event you MUST be able to capture. If we're talking microseconds then you really NEED hardware interrupts. If we're getting up into millisconds or possibly the hundreds of microseconds range then a software aproach, in line with what I, and I think Amoque was saying, might work - YMMV.
Here's something in the line of what I'm thinking
Code:
SignalLines VAR WORD ' Current state of inputs
oldSignalLines VAR WORD ' Previous state of inputs
Result VAR WORD ' Result of XORing
Counter VAR WORD[9] ' 9 counters, one for each line
idx VAR BYTE ' Index variable
' Subroutine to poll and evalute the signal lines, GOSUB this periodically.
Test:
SignalLines.LowByte = PortB ' 8 lines on PortB and...
SignalLines.Bit9 = PortC.0 ' ...and one on PortC.0 for a total of 9.
' Any bit that is set in Result indicates a state change, 1->0 and 0->1.
Result = SignalLines XOR oldSignalLines
' Iterate thru the bits in result and increment the counter for each
' respective counter if the bit is set.
For idx = 0 to 8 ' 9 bits, 9 counters
Counter[idx] = Counter[idx] + Result.Bit0[idx] ' Increment counter if bit is set
NEXT
oldSignalLines = SignalLines ' Clear any mismatch.
RETURN
Compiles but is not tested, meant as food for thought.
/Henrik.
Bookmarks