dkinzer wrote:Some web pages that I've looked at show a waveform where the trailing edge of the channel 1 pulse is coincident with the leading edge of the channel 2 pulse and so on down the line.
This round-robin method of doing the PWM should be relatively easy to handle. If the PC interrupt is set up to trigger on both edges, then you have to do the XOR of the port with the last port state, then go sequentially through each of the "true" bits. If the state change on a particular pin was a rising edge, then grab the timer reading and save it.
If the edge was a falling edge, then grab the timer reading and subtract it from the saved value. Then store that resulting value somewhere for future processing. Probably a flag would need to be set as well.
One question would be about when to reset the timer to zero. It would be nice to be able to reset the timer rather than let it wrap around as it overflows. However it might take too much effort (and another timer?) to do.
This still does not answer the question of how accurate (how often the same measurement results in the same answer) and how precise (how different measured variables need to be to get the reading of the two to be different) this is going to be.
An interrupt that takes a long time to process will reduce the overall precision. An interrupt that takes a variable amount of time to process will reduce accuracy. Other interrupts occuring at the sime time will also reduce accuracy.
The only way to find out how it will actually work is to try it and see. I think you are well along the process to being able to try it out!
Oh, to answer the question of whether I2C requires interrupts. The answer is YES. The hardware I2C functions do use interrupts. If you do your own software I2C then you will not need interrupts. If you were concerned about the latency in servicing a Pin Change interrupt, then it is probably better to use the hardware I2C rather than use a new task for the software I2C. The added overhead to OS to serivce the extra task is likely to be worse than the I2C interrupt.
-Tony