need time calculation from rising edge to falling edge?

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Attachment(s): 

Last Edited: Mon. Sep 29, 2014 - 02:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Easiest way might be to start a timer running and use a pin change interrupt.

 

On the interrupt, read the time from the timer.

 

If the pin is high, it's a rising edge, save the time in a volatile variable.

 

If the pin is low, it's a falling edge, subtract the time you saved from the current time and there you have it.

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead.