|
From: | Georg-Johann Lay |
Subject: | Re: [avr-gcc-list] Newbie question |
Date: | Wed, 25 Feb 2009 23:37:45 +0100 |
User-agent: | Mozilla Thunderbird 1.0.7 (Windows/20050923) |
David VanHorn schrieb:
:) Interrupt latency. I have an app on a Mega32L, running at 4 MHz. I'm trying to measure the widths of pulses that could be as short as 5uS. The theory was to detect the first rising edge, and zero T1. Then on the second rising edge, grab the count from T1, which is running at CK/1 The problem I'm running into is that the generated ISR is showing a latency of >7uS between the high edge of the pulse that generates INT0 and where my code starts executing. Even taking the part to 8 MHZ doesn't look like it will work, yet I know that at 4 MHz I can do this job in asm. I understand what the compiler is doing, but the ISR it generates is way too slow. (see below)
Can't you benefit from the input capture functionality?Start T1 and as soon as an edge is detected, it's counter value will be backed up. If you manage to read the value before the complementary edge (which again can triggers T1 to be backed up, provided T1 is configured correctly) you can compute the difference of the two timestamps. So ISR latency is no concern and won't disturb the exactness of the measuring.
Georg-Johann
[Prev in Thread] | Current Thread | [Next in Thread] |