InputCaptureEx oddity

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

InputCaptureEx oddity

Post by GTBecker »

I'm using InputCaptureEx to measure the high and low periods of a '555 output cycle, usually correctly. Maybe 1% of the time, however, I see an entire cycle, not just a high or low period, in the high (first) count. For example:
ZX-24n:

Code: Select all

2127 1015
2120 1016
2112 1017
2117 1020
3097 1021 **
2127 1030
2140 1044
2149 1055
2144 1047
ZX24:

Code: Select all

2159 1013
2152 1014
2152 1013
2152 1014
3111 1013 **
2155 1014
2155 1014
2147 1015
2148 1015
What might cause this?

Later edit:
I see different behavior if the capture starts on the falling edge:
ZX-24n:

Code: Select all

1027 2148
1027 2148
1027 2152
1025 2153
995 2155
1024 2158
1024 2157
1024 2159
1027 2165
Here the low period is occasionally a few percent short, but I do not see the full-cycle error. In both cases, scoping the signal shows some jitter, and some ground noise, but no glitches.
Tom
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

The only thing that I can think of is that another task is blocking interrupts at just the wrong moment. Does your application have other tasks that might interfere with input capture interrupt servicing?

You might try to strip down your program so that it only records the input capture, but does nothing else at the time. That might eliminate the possibility of another task interfering with the input capture.

-Tony
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

I am using three simple tasks (sampling, display and command receipt) but I'm not deliberately blocking interrupts anywhere. I found, though, that placing a pair of Locktask/Unlocktask functions around the capture served only to prevent remote downloads via AtnChar (the project is in a box at the wellhead and talks via Bluetooth). They had no effect on the capture.

I'm leaning toward a dirty signal so I'm going to try slowing the risetime of the '555 a little - and substitute a clean bench-generated squarewave - to see what that does.
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

As should be the case, a clean 400Hz squarewave is measured accurately by InputCaptureEx. I also tried capturing four periods so I could use the third and fourth periods to avoid the first two suspect periods; the result was the same as capturing two periods. I guess the '555 and processor breadboard is sufficiently noisy to cause the '555 to trigger irregularly.
Tom
Post Reply