I wondering how figure out the period or time of a signal using input capture. I have one ATMega16 generating a square wave the period of it is 1920us. 1920us high then 1920us low. I'm the second ATMega16 to capture the siganl.
RisingEdge - FallingEgde = Period
If I capture the falling edge of the signal into the input capture register and save it to the variable FallingEdge
Then setup the input capture interrupt to capture the next rising edge.
Wait for the next input capture interrupt. Save the input capture register to RisingEgde. Then setup the input capture interrupt to capture the next Falling edge. Then do the math RisingEdge - FallingEdge = Period
How do you compute this if the fallingEgde value is greater than 0xd2FF. The Timer will overflow or goto Bottom value.
6Mhz crystal used so 1920us = 0x2d00
Rising - Falling = period
0x0CFF - 0xe000 = 0xffffff2cff wrong ???
0xffff = 0xd2ff = 0x2d00 ok that works fine
I hope I explained this correctly.