From 516dc48d0a1c47e354856d3f71b2e5bd0454cf4e Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Tue, 8 Oct 2013 22:39:39 +0200 Subject: [PATCH] fix interrupt locking cli/sei were reversed --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index e434690..923a8ea 100644 --- a/main.c +++ b/main.c @@ -173,16 +173,16 @@ static void poll_input_capture(void) if ((TIFR1 & _BV(ICF1)) == 0) return; - sei(); - icp = ICR1; cli(); + icp = ICR1; + sei(); rising = TCCR1B & _BV(ICES1); /* change the edge type */ TCCR1B ^= _BV(ICES1); - /* clear the flag */ + /* clear the flag by writing a one */ TIFR1 = TIFR1 | _BV(ICF1); diff = icp - icp_prev; -- 2.39.5