Purpose for ...capture/compare

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
what do the capture/compare feature is typically used for in embedded
application.  How is it related to PWM applications.



Re: Purpose for ...capture/compare
In comparator mode they are very useful for precision timing. I have used
them on PICs and 8052 derivatives.
The idea is that a 16bit register value is compared to a free-running timer.
Several actions can be set up to occur when the timer matches the register,
   automatically set, clear or toggle a pin with an accuracy of one timer
   trigger an adc conversion (the adc interrupt can then be used to process
the reading)
   clear the timer
   generate an interrupt
The interrupt is typically used to
   add a delay value to the comparator register for the next match - you can
change the delay each time.
   set up external hardware for the next match
   change the operating mode of the comparator
Here are some applications I have used them for:
   precise frequency generation
   multi-rate adc sampling
   generating quadrature step signals for a stepper motor, with ramp
calculation in the ISR.

In capture mode, you grab the timer value when an input changes state.
Useful for motor apps.

In PWM mode, the timer generates the period, and the comparator sets the
duty cycle.
One use for a pwm output as a cheap DAC.
The output voltage after low-pass filtering is proportional to the duty

For more info download a microcontroller datasheet eg PIC16F876 from the
Microchip site.

Dave Austin. .

Quoted text here. Click to load it

Site Timeline