Input Capture and Output Compare blocks provide hardware-based event timing and waveform generation capabilities for precise measurement and control applications. These peripherals operate independently of CPU execution, ensuring deterministic timing for frequency measurement, pulse width detection, servo control, and custom waveform generation.
| Application | Recommended Block | Why? |
|---|---|---|
| Measure Input Frequency | IC (Input Capture) | Hardware captures edge timing automatically |
| Measure Pulse Width | IC (Input Capture) | Captures rising and falling edges |
| Generate PWM | OC_HW (Output Compare) | Lightweight alternative to dedicated PWM module |
| Generate Complex Waveform | OC_SW (Software OC) | Flexible interrupt-driven control |
| Servo Control | OC_HW (Hardware OC) | Precise pulse generation with zero CPU overhead |
| Frequency Counter | IC (Input Capture) | Automatic edge counting and timing |
๐ข Zero CPU Overhead (Hardware-based, autonomous)
๐ก Interrupt-Driven (Flexible but with CPU overhead)
| Feature | Input Capture (IC) | Output Compare Hardware (OC_HW) | Output Compare Software (OC_SW) |
|---|---|---|---|
| Direction | Input (measure) | Output (generate) | Output (generate) |
| CPU Overhead | Minimal (interrupt per event) | None (autonomous) | High (interrupt per change) |
| Timing Accuracy | ยฑ1 timer tick | ยฑ1 timer tick | ยฑ1 timer tick + ISR latency |
| Flexibility | Fixed modes | Fixed modes | Full software control |
| Use Case | Frequency/pulse measurement | Simple PWM, servo control | Complex waveforms |
โ Cannot Share:
โ Can Share:
Example: dsPIC33CK @ 100 MIPS, Prescaler=1
Recommendation: For motor control PWM, use dedicated PWM blocks instead of OC for better performance and features.
Frequency Measurement:
Pulse Width Measurement:
Event Timing:
Simple Waveform Generation:
Timed Events:
Complex Waveforms:
| Block | dsPIC30F | dsPIC33F | dsPIC33E | dsPIC33C | dsPIC33A | PIC24 | PIC32 | SAM |
|---|---|---|---|---|---|---|---|---|
| IC (Input Capture) | โ | โ | โ | โ | โ | โ | โ | โ ๏ธ |
| OC_HW (Hardware) | โ | โ | โ | โ | โ | โ | โ | โ ๏ธ |
| OC_SW (Software) | โ | โ | โ | โ | โ | โ | โ | โ |
Legend: โ Full Support | โ ๏ธ Different Peripheral (TC/TCC capture/compare) | โ Not Available
Note: SAM ARM devices use different timer peripherals (TC/TCC blocks with capture/compare functionality, not dedicated IC/OC modules).
Related Block Categories:
Recommended Reading:
Example Projects:
๐ก Quick Selection Guide:
The MCHP_IC block captures hardware timer values when external events occur on input pins. It enables precise measurement of pulse widths, periods, โฆ
Read more โThe MCHP_OC_HW block provides hardware-based output generation using the Output Compare (OC) peripheral. It generates PWM signals, toggles outputs, โฆ
Read more โThe MCHP_OC_SW block provides interrupt-driven software output compare functionality. Unlike hardware OC which operates autonomously, this block uses โฆ
Read more โ