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.
When to use:
When NOT to use:

Inputs: None (profiling markers inserted automatically)
Outputs:
ExecutionTime - Measured execution time in selected unitsOverflowFlag - Indicates timer overflow (measurement invalid)| Parameter | Variable | Description | Options |
|---|---|---|---|
| Timer Ressources | TIMER_Ressource | Hardware timer allocation constraint | No constraints Preferred, Timer 1-9, Pick one from user list |
| Timer List | TIMER_Ressource_Custom | Custom timer list (when using custom selection) | Array, e.g., [1 2 3] |
| Parameter | Variable | Description | Display Format |
|---|---|---|---|
| Resolution and max period | TIMER_Resolution | Timer prescaler selection for profiling accuracy | “Resol: X(ยตs) - MaxPer: Y(s)” |
Note: The timer resolution dropdown shows available prescaler options with their corresponding resolution and maximum measurement period. Lower resolution provides longer maximum periods but less precise measurements.
| Parameter | Variable | Description |
|---|---|---|
| Timer info | Info | Read-only display showing allocated hardware timer |
| Family | Timer Used | Resolution |
|---|---|---|
| dsPIC30/33F/33E/33C/33A | Timer1 (typically) | Instruction cycle |
| PIC24F | Timer1 | Instruction cycle |
| PIC32 | Core Timer (CP0) | CPU cycle |
| SAMx (ARM) | SysTick or TC | CPU cycle |
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
% MATLAB verification script
maxAllowedTime = 100; % microseconds
if ExecutionTime > maxAllowedTime
warning('Real-time constraint violated!');
end