I'm looking for any good advice on working with the capture/compare unit of the eZ8. (eZ8 documentation references below)
The goal is to capture the time between two events (high signals). It must reliability capture these events continuesly with the highest possible precision. To complicate the matter, the times scale beyond the 16-bit counter. Multiple interrupts are generated and while these are running they cannot be interrupted. This interrupt has the highest priority though.
The timer has a 16-bit up-counter, 16-bit reload register and 16-bit PWM/Compare register. It has a input pin and an output pin. The input pin is used for capturing the event.
The global design is:
- Interrupt (high-priority) driven capture stores value in a queue.
- Non-interrupt loop processes the queue (can process hold-off, corrections, etc...) it writes the data to an output queue
- Interrupt (low-priority) driven transfer from output queue
My idea was to use the "capture/compare" mode. The timer starts on the first external Timer Input transition.
Every Timer Input transition:
- writes the value to the PWM register
- Interrupt is generated
- counter resets to 0x0001 and continues. Upon overflow (compare value of 0x0000):
- Interrupt is generated
- counter resets to 0x0001 and continues.
The timer output is toggled on every counter reset (so with every overflow and input transition).
I can guarentee:
- Interrupt can be handled between overflows with ease.
- Another 16-bit counter is continuesly counting at the same speed.
I cannot guarentee:
- The interrupt is for an overflow AND external event.
I'm looking for a way to guarentee:
- Not miss any event.
- Proper seperation of events (analog filter). Can anyone help me with this?
- Joris
===
eZ8 site:
eZ8 Product Specification:
- "Timers" on page 57 (absolute page 75)
- "Interrupt controller" on page 44 (absolute page 62)