Purpose for ...capture/compare

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

Thanks.

Leslie.

Reply to
John Tan
Loading thread data ...

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, eg: automatically set, clear or toggle a pin with an accuracy of one timer period 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 cycle.

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

Dave Austin. .

Reply to
david austin

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.