Overview

Timer blocks provide precise timing and resource management capabilities essential for embedded applications. The MPLAB Blockset offers timer configuration for creating named timer resources that can be shared across peripherals, and profiling tools for measuring code execution performance.

Available Timer Blocks

Timer Config - Timer Configuration and Resource Management


Timer PIL Profiling - Processor-in-the-Loop Timing Profiler


Block Selection Guide

By Application

ApplicationRecommended BlockWhy?
Periodic Task ExecutionTIMER_ConfigCreates time base for multitasking scheduler
Measure Code Execution TimeTIMER_PIL_ProfilingHardware-accurate timing for PIL
Time Base for PeripheralsTIMER_ConfigShared resource for PWM, IC, OC, ADC
Performance OptimizationTIMER_PIL_ProfilingIdentify bottlenecks and validate deadlines

Timer Resource Management

Timer Types Available

Timer Resources:

  • Type A: 16-bit timers (TMR1-TMR9)
  • Type B: 32-bit timers (TMR2/3, TMR4/5 pairs)
  • Use TIMER_Config for automatic allocation

Best Practices

  1. Use TIMER_Config for Named Resources

    • Prevents conflicts by centralizing timer allocation
    • Automatically calculates prescalers
    • Documents timer usage in model
    • Allows multiple peripherals to share the same timer
  2. Check Device Timer Availability

    • Consult device datasheet for timer types
    • dsPIC33A/C: Type A and B/C/D/E timers
    • PIC32: Type A/B/C timers
  3. Resource Sharing Guidelines

    • Multiple peripherals can share the same timer if they use compatible configurations
    • TIMER_Config automatically manages shared resources
    • Check for conflicts when using manual timer configuration

Timing Accuracy Considerations

Timer Resolution

Resolution = (Prescaler × Timer Period) / Instruction Cycle

Example: dsPIC33CK @ 100 MIPS, Prescaler=8, 16-bit timer

  • Resolution = 8 / 100 MHz = 80 ns
  • Max measurable period = 80 ns × 65536 = 5.24 ms

Profiling Accuracy

The PIL Profiling block provides microsecond-level timing accuracy suitable for:

  • Validating real-time constraints
  • Measuring interrupt latency
  • Identifying performance bottlenecks
  • Optimizing critical code sections

Device Family Support Summary

Timer BlockdsPIC30FdsPIC33FdsPIC33EdsPIC33CdsPIC33APIC24PIC32SAM
TIMER_Config⚠️
TIMER_PIL_Profiling

Legend: ✅ Full Support | ⚠️ Different Peripheral (TC/TCC blocks)

Note: SAM ARM devices use different timer peripherals (TC/TCC blocks instead of Type A/B/C timers). TIMER_Config concepts apply but use SAM-specific peripheral blocks.


See Also

Related Block Categories:

Recommended Reading:

Example Projects:


💡 Quick Selection Guide:

  • Need timer resource for peripherals? → Timer Config
  • Need to measure code performance? → Timer PIL Profiling
  • Need to measure external signals? → See Input Capture blocks
  • Need to generate pulses? → See Output Compare blocks

TIMER Config - Timer Configuration Block

TIMER Config - Timer Configuration Block Timer Block Icon The MCHP_TIMER_Config block provides a high-level interface for configuring hardware timers …

Read more →

TIMER PIL Profiling - PIL Timing Profiler

TIMER PIL Profiling - PIL Timing Profiler Timer_PIL_Profiling Block Icon The MCHP_TIMER_PIL_Profiling block enables precise code execution timing …

Read more →