Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / Measurement and Acceptance

A 20 MHz crystal drives F28379D. Why does eCAP report a negative pulse width?

An F28379D board uses a 20 MHz passive crystal. The scope shows stable high and low widths at the input, while software reading four eCAP events reports a very short or negative result. Determine whether captured numbers share a running origin or the counter was reset after each event. Subtracting values that are already intervals can turn a valid capture into an impossible width.

Event settings define the raw count

TI provides four separately configurable capture events. Each can select an edge polarity and whether to reset time-base counter TSCTR after capture. With a free-running counter, the registers store positions on a common time axis. If each capture resets the timer, subsequent registers already contain the spacing between events. Partial reset configurations are also possible. Verify all four settings instead of trusting a global mode label.

Suppose an approved clock tree takes the 20 MHz crystal to a 200 MHz system clock and eCAP uses a five-nanosecond timebase tick. Apply a 25 kHz waveform, sixteen microseconds high and twenty-four low. Configure rising, falling, rising, and falling events. High and low intervals are 3,200 and 4,800 ticks, totaling 8,000 ticks or forty microseconds for a 40-percent duty cycle. Converting counts using the crystal's nominal period rather than the peripheral timebase introduces a separate factor-of-ten error.

With a free-running counter, suppose the first capture reads 10,000. The subsequent events are 13,200, 18,000, and 21,200. Subtract consecutive readings to obtain high and low widths. In reset-after-every-event mode, the first record can reflect time from arming to the first edge. Records two through four are then approximately 3,200, 4,800, and 3,200. Subtract the third value from the fourth and the calculation produces −1,600 ticks, or −8 microseconds. That difference is between consecutive pulse widths, not a width.

Establish the origin of each event with a known input

Measure input levels, pulse widths, and edge polarity on the scope, and keep a marker identifying the capture batch. Use a setup that retains all four events before reading them. Log raw values, reset controls, polarity, and prescaling. Replay the same words with absolute differences and with direct interval interpretation to see which matches the configured capture.

Where only the first value is unexpected, check whether it measures time from arming. Shift trigger phase without altering the input high and low durations. A first count that follows trigger placement while later widths are steady does not belong in the width statistics. Swap the high and low settings on the test generator as another cross-check of event polarity and array ordering.

A free-running counter can also wrap. The later absolute timestamp can be numerically smaller than the earlier one. Width-aware unsigned arithmetic can reconstruct intervals within the covered counter range. Longer intervals need separate overflow evidence. In reset-after-event operation, wrap arithmetic does not replace checking the event controls. Keep the mode and raw words with each measurement.

Partial reset is another useful check. Reset after event four only. The next group then starts a new count origin while its early values are cumulative. Subtraction within that group still works. An interval crossing the reset must use the new origin. Enable only the last reset during a controlled run and see how each group restarts. Mixing the previous group’s last count with the next group’s first can produce a repeatable negative value. Preserve the count origin rather than applying a fixed correction.

Accept real pulse widths

Debugger pauses can also change timebase behavior. Make the final capture without halting execution and use consistent hardware conditions. Verify widths at both slow and fast input settings. If only the fast case loses one polarity of edge, investigate input qualification, polarity, and the trigger path as well as count interpretation.

When both configurations can reconstruct sixteen and twenty-four microseconds from the known input, repeat with the actual signal. After a crystal change, verify derived clock and prescale paths before comparing. If only the software interpretation differs, the oscillator cannot fix it. If raw intervals move proportionally, compare the peripheral timebase with an independent reference and inspect the clock tree. Include event position, raw count, origin, and converted width in the result so others can replay it.

References

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.