- Tue Nov 11, 2008 8:29 pm
#58840
After having just spent several hours picking my friend's brains about how we could go about this, we discovered a code sample based on a PIC controller that gave me a couple of ideas. The programmer chose to use his Timer to run a 1mS pulse, which would increment a base counter, and at every 1mS interval, take a snapshot of the PORTA and analyze each of the inputs, thus ensuring that you don't skew results by checking in order of 1-5.
We contemplated this idea, but ultimately decided that it wasn't that great a benefit. We also pondered the idea of waiting for a pin change ISR to trigger (to which all 5 lanes would be tied). At this point the ISR would check each of the 5 lanes and compute times and mask whichever one had finished.
What I think we're going to go with is pre-loading the Timer so that it runs in 100mS overflows. Every time if overflows, the ISR increases a variable by 1. In the main code it's only polling each of the unmasked lanes continuously, and in a rotating pattern. No other code involved in this loop. Both the ISR and the main loop are short enough that there shouldn't be issues with multiple lane finishes at once, especially at 8Mhz. Any abort commands issued by the computer would by in a USART ISR.
Ideas?
We contemplated this idea, but ultimately decided that it wasn't that great a benefit. We also pondered the idea of waiting for a pin change ISR to trigger (to which all 5 lanes would be tied). At this point the ISR would check each of the 5 lanes and compute times and mask whichever one had finished.
What I think we're going to go with is pre-loading the Timer so that it runs in 100mS overflows. Every time if overflows, the ISR increases a variable by 1. In the main code it's only polling each of the unmasked lanes continuously, and in a rotating pattern. No other code involved in this loop. Both the ISR and the main loop are short enough that there shouldn't be issues with multiple lane finishes at once, especially at 8Mhz. Any abort commands issued by the computer would by in a USART ISR.
Ideas?