5.3.1 Timer/Counter (TC)
The PIC16F, PIC18F and PIC32CM Timer/Counter peripherals are utilized for timing, waveform generation, input capture, and event handling. These MCUs support multiple timer types with varying features for precise timing and waveform control.
While PIC32CM has timer modules that offer most of these features, both PIC16F and PIC18F require additional peripherals for capture/compare (CCP/ECCP) and waveform generation (CCP/ECCP/PWM). Newer PIC18F devices also feature PWMs that do not require external timers. Table 5-11 provides a comparison of features between PIC16F, PIC18F and PIC32CM.
| Feature | PIC16F Timers | PIC18F Timers | PIC32CM Timers |
|---|---|---|---|
| Timer Variants |
Timer0 (8-bit) Timer1/3/5 (16-bit) Timer2/4/6/8/12 (8-bit) Signal Measurement Timer (SMT) |
Timer0 (8-bit) Timer1/3/5 (16-bit) Timer2/4/6/8/12 (8-bit) Signal Measurement Timer (SMT) Universal Timer (UTMR) | Timer/Counter (TC,
16/32-bit) Timer/Counter for Control (TCC) |
| Resolution | 8-bit, 16-bit, 24-bit (SMT), | 8-bit, 16-bit, 24-bit (SMT), 32-bit (cascaded UTMR) | 8-bit, 16-bit, or 32-bit (selectable) |
| Prescaler | Programmable | Programmable | Programmable |
| Capture/Compare Channels | CCP/ECCP | Up to seven (through CCP/ECCP) | Up to four |
| PWM Generation | Through (Enhanced) Capture/Compare/PWM - (E)CCP stand-alone PWMs | Through (Enhanced) Capture/Compare/PWM - (E)CCP stand-alone PWMs | Through TCx, TCC |
| PWM Modes | Standard Enhanced (Half/Full-Bridge) Steering | Standard Enhanced (Half/Full-Bridge) Steering | Single/Dual-Slope |
| Special Modes | SMT for relative timing | Hardware Limit Timer (HLT) for fault
detection SMT for relative timing UTMR chaining | Circular buffer, multiple output events |
| Signal Measurement | SMT | SMT and UTMR | Frequency Meter, advanced TC |
| Buffering | Double buffering for PWM duty cycle only | Double buffering for PWM duty cycle only | Double-buffered period/compare/capture |
| Fault Protection | Auto-shutdown/Restart | Auto-shutdown/Restart | Recoverable/non-recoverable fault sources |
| Event System | N/A | Inter-peripheral triggering through Signal Routing Port (SRPORT) for newer devices | Integrated for input/output events, synchronization |
| Direct Memory Access (DMA) | N/A | Supported | Supported |
| Interrupts |
Overflow Compare Match Input Capture Gate Event |
Overflow Compare match Input capture Gate Event |
Overflow Compare match Input capture Error Fault |
| Waveform Extensions | Through Complementary Output Generator (COG) | Through Complementary Waveform Generator (CWG) | Timer Counter for Control Applications (TCC) |
| RTC/ Calendar Timer | Using TMR1 | Using TMR1 or a dedicated RTCC module | Dedicated RTC module |
