5.3 Timing, Measurement, and Waveforms

Timer/Counter (TC)

The PIC16F, PIC18F and PIC32CM Timer/Counter peripherals are utilized for timing, waveform generation, input capture, and event handling. Both 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. The table below compares the features of the PIC16F, PIC18F, and PIC32CM MCUs.

Table 5-10. PIC16F, PIC18F, and PIC32CM Timer Features
FeaturePIC16F TimersPIC18F TimersPIC32CM Timers
Timer VariantsTimer0 (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)
PrescalerProgrammableProgrammableProgrammable
Capture/Compare ChannelsCCP/ECCPUp to 7 (through CCP/ECCP)Up to four
PWM GenerationThrough (Enhanced) Capture/Compare/PWM - (E)CCP Standalone PWMsThrough (Enhanced) Capture/Compare/PWM - (E)CCP Standalone PWMsThrough TCx, TCC
PWM ModesStandard Enhanced (Half/Full-Bridge) Steering Standard Enhanced (Half/Full-Bridge) Steering Single/Dual-Slope
Special ModesSMT for relative timingHardware Limit Timer (HLT) for fault detection

SMT for relative timing

UTMR chaining

Circular buffer, multiple output events
Signal MeasurementSMT SMT and UTMRFrequency Meter, advanced TC
BufferingDouble buffering for PWM duty cycle onlyDouble buffering for PWM duty cycle onlyDouble-buffered period/compare/capture
Fault ProtectionAuto-shutdown/RestartAuto-shutdown/RestartRecoverable/non-recoverable fault sources
Event System N/AInter-peripheral triggering through Signal Routing Port (SRPORT) for newer devicesIntegrated for input/output events, synchronization
Direct Memory Access (DMA)N/ASupportedSupported
InterruptsOverflow

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 TimerUsing TMR1Using TMR1 or a dedicated RTCC moduleDedicated RTC module

Advanced Waveform Generators

The PIC16F/PIC18F Complementary Output/Waveform Generator (COG and CWG) peripherals have similar features to the PIC32CM Waveform Extensions for precise and safe waveform control in advanced motor, power, LED control, and similar applications. COG and CWG provide reliable complementary PWM generation for PIC16F/PIC18F applications, with COG offering more advanced features in select PIC16F devices. PIC32CM WEX delivers a comprehensive, event-driven waveform generation system for modern, high-performance embedded designs.

The table below compares the features of PIC16F, PIC18F, and PIC32CM.

Table 5-11. PIC16F, PIC18F, and PIC32CM – COG, WEC, and WEX Features
FeaturePIC16F COGPIC16F/PIC18F CWG PIC32CM WEX
Peripheral TypeCOG (Complementary Output Generator)

CWG (Complementary Waveform Generator)

CWG (Complementary Waveform Generator)WEX (Waveform Extension)
Complementary OutputsSupportedSupportedSupported
Output DistributionSteering modes (Synchronous/Asynchronous)Steering modes (Synchronous/Asynchronous)Output Matrix (OTMX) with multiple routing modes
Dead-Time InsertionDual independent 6-bit rising and falling timers

Double-buffered

Dual independent 6-bit rising and falling timers

Double-buffered

Four DTI units Common register 8-bit resolution Double-buffered
Swap Functionality Handled through mode selection or direction change logicHandled through mode selection or direction change logicWaveform swap option with double buffer support
Pattern Generation Relies on steering mode for static levelsLimited to manual output overridesDouble-buffered Dithering support
Dithering N/AN/ASupported
Port Override/Disable PPS routingPPS routingN/A
Fault ProtectionAuto-shutdown

Auto-restart

Auto-shutdown

Auto-restart

Fault protection for safe and deterministic shutdown
PWM ResolutionModerate (typically 10-12 bits)Moderate (typically 10 bits)High (up to 16 bits or more)

Real-Time Counters (RTC)

The PIC16F and most PIC18F devices rely on TMR1 for basic RTC functionality, while some PIC18F and all PIC32CM families provide a dedicated, feature-rich RTC peripheral for modern embedded timekeeping needs. The table below compares the features of PIC16F, PIC18F, and PIC32CM.

Table 5-12. PIC16F, PIC18F, and PIC32CM RTC Features
FeaturePIC16F RTCC/TMR1PIC18F RTCC/TMR1PIC32CM RTC
RTC PeripheralRTCC

TMR1 with 32.768 kHz crystal

RTCC

TMR1 with 32.768 kHz crystal

RTC
Counter ResolutionBinary Coded Decimal (BCD) format for time/dateBinary Coded Decimal (BCD) format for time/date32-bit (or two 16-bit)
Prescaler 2-bit programmable (Timer1)2-bit programmable (Timer1)10-bit programmable
Compare Registers Alarm registers for Sec/Min/Hour/Day/Month/WDAlarm registers for Sec/Min/Hour/Day/Month/WD2 (32-bit) or 4 (16-bit mode)
Period RegisterN/AN/AOne
Maximum Timeout (32.768 kHz)More than 100 years (1s resolution)More than100 years (1s resolution)More than 136 years (1s resolution)
Clock/Calendar Mode Supported (time/date, leap year correction)Supported (time/date, leap year correction)Supported (time/date, leap year correction)
Clock Correction Periodic auto-adjustPeriodic auto-adjustDigital frequency (prescaler) correction/tuning
Periodic Interrupt Timer (PIT) Alarm repeat counter (up to 255 times)Alarm repeat counter (up to 255 times)Integrated periodic wake-up/event functionality
Interrupts/Events Alarm Match, Timer OverflowAlarm Match, Timer OverflowOverflow, alarm/compare, prescaler, periodic
Clear on MatchAvailable, resets counter to zero/initial date upon alarm matchAvailable, resets counter to zero/initial date upon alarm matchOptional on alarm/compare match
TimekeepingHardware clock and calendar or Software-implemented (TMR1-based)Hardware clock and calendar or Software-implemented (TMR1-based)Hardware clock and calendar, alarms, backup registers
Low-Power OperationTMR1 or RTCC can run in Sleep/Deep SleepTMR1 or RTCC can run in Sleep/Deep SleepRTC runs in Standby/Off
Alarm/Wake-up FunctionRTC alarm

TMR1 interrupt

RTC alarm

TMR1 interrupt

Multiple alarms, Event triggers
Backup Battery SupportSupportedSupportedSupported
Event System IntegrationN/AN/ASupported