Timer PIL Profiling Block Icon
TIMER PIL Profiling - PIL Timing Profiler Timer_PIL_Profiling Block Icon The MCHP_TIMER_PIL_Profiling block enables precise code execution timing measurement during Processor-in-the-Loop (PIL) simulations. It uses hardware timers to measure actual execution time of Simulink subsystems or blocks on target hardware. This block is essential for performance profiling, real-time constraint verification, and optimization of embedded code. It provides microsecond-level timing accuracy using the target’s hardware timer peripheral.

TIMER PIL Profiling - PIL Timing Profiler

Timer_PIL_Profiling Block Icon The MCHP_TIMER_PIL_Profiling block enables precise code execution timing measurement during Processor-in-the-Loop (PIL) simulations. It uses hardware timers to measure actual execution time of Simulink subsystems or blocks on target hardware.

This block is essential for performance profiling, real-time constraint verification, and optimization of embedded code. It provides microsecond-level timing accuracy using the target’s hardware timer peripheral.

Supported Device Families

FamilyTimer UsedResolution
dsPIC30/33F/33E/33C/33ATimer1 (typically)Instruction cycle
PIC24FTimer1Instruction cycle
PIC32Core Timer (CP0)CPU cycle
SAMx (ARM)SysTick or TCCPU cycle

Configuration Parameters

ParameterDescriptionDefault
ProfileModeTiming measurement mode: Start/Stop markers or continuousStart/Stop
TimerSourceHardware timer selection for profilingAutomatic
OutputUnitsTime output format (seconds, milliseconds, microseconds, ticks)microseconds

Block Inputs/Outputs

Inputs: None (profiling markers inserted automatically)

Outputs:

  • ExecutionTime - Measured execution time in selected units
  • OverflowFlag - Indicates timer overflow (measurement invalid)

Implementation Details

Profiling Mechanism

  • Start Marker: Captures timer value before code execution
  • Code Execution: Target code runs normally
  • Stop Marker: Captures timer value after execution
  • Calculation: Elapsed time = (Stop - Start) / Timer Frequency

Timer Resolution by Family

  • dsPIC @ 60MHz Fcy: 16.67ns per tick (1:1 prescaler)
  • PIC32 @ 200MHz: 5ns per CPU cycle
  • SAMx7 @ 300MHz: 3.33ns per CPU cycle

Usage Examples

Example 1: Measure Subsystem Execution Time

1. Place MCHP_TIMER_PIL_Profiling block in model
2. Configure for Start/Stop mode
3. Build and run PIL simulation
4. Monitor ExecutionTime output signal

Example 2: Verify Real-Time Constraints

% MATLAB verification script
maxAllowedTime = 100; % microseconds
if ExecutionTime > maxAllowedTime
    warning('Real-time constraint violated!');
end
  • [MCHP_TIMER_Config] - Timer resource configuration
  • PIL Testing - PIL testing workflow
  • External Mode - External mode debugging