Inputs: None (configuration block only)
Outputs: None (configuration block only)
This is a configuration block that sets up hardware timer resources. It does not have signal ports—other blocks (Input Capture, Output Compare, etc.) reference the timer by name.
| Family | Support Level | Available Timers | Prescaler Options |
|---|---|---|---|
| dsPIC30F/33F/33E/33C/33A | Full | Timer1-Timer9 (device dependent) | 1:1, 1:8, 1:64, 1:256 |
| PIC24F | Full | Timer1-Timer5 (device dependent) | 1:1, 1:8, 1:64, 1:256 |
| PIC32 (MIPS) | Full | Timer1-Timer5 | 1:1, 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:256 |
| PIC32A | Full | Timer1-Timer9 (device dependent) | 1:1, 1:8, 1:64, 1:256 |
| SAMx7 (ARM M7) | Full | TC0-TC11 (3 channels each) | 1:8, 1:32, 1:128 |
| SAMx2/x5 (ARM M0+/M4) | Full | TC0-TC7 | 1:1, 1:2, 1:4, 1:8, 1:16, 1:64, 1:256, 1:1024 |
| Parameter | Description | Options/Range | Default |
|---|---|---|---|
| TIMER_Name | Named timer resource identifier | TimerA-TimerF, Custom Name | TimerA |
| TIMER_CustomName | User-defined timer name (when Custom Name selected) | Valid MATLAB identifier | TimerG |
| Parameter | Description | Options |
|---|---|---|
| TIMER_Ressource | Hardware timer allocation constraint | No constraints [Preferred] |
| TIMER_Ressource_Custom | Custom timer list (e.g., [1 3 5]) | Array of timer indices |
| Parameter | Description | Notes |
|---|---|---|
| TIMER_Resolution | Timer tick resolution and maximum period | Dropdown shows: “Resol: X.XXµs - MaxPer: Y.YYms” for each prescaler option |
| TIMER_PeriodChk | Use maximum period (65535 ticks) | When ON: PR register = 65535 |
| TIMER_Period | Desired timer period (seconds) | Active when TIMER_PeriodChk is OFF. Can be MATLAB variable or numeric value |
| Parameter | Description | Options |
|---|---|---|
| TIMER_ShareChk | Enable timer sharing between blocks | ON = Shared, OFF = Exclusive use |
| TIMER_Use | Sharing permission level | Read only |
| DoNotSetupChk | Reserve timer for custom C code | When ON: No timer initialization, manual setup required |
The block configures the following timer registers based on device family:
The block manages timers using an internal type system:
| Type | Description | Use Case |
|---|---|---|
| 0 | Ticks only (no register access) | Time base reference only |
| 1 | Read with PR = 65535 | Maximum period, read-only |
| 2 | Read with fixed PR ≠ 65535 | Specific period, read-only |
| 3 | Read/Write with PR modification | Shared timer with PR updates |
| 4 | Full control (Read/Write/Start/Stop) | Exclusive timer ownership |
The block uses the MCHP_Fun.TimerConfig() function for intelligent timer assignment:
% Configure 1ms periodic timer
Timer Name: TimerA
Timer Resource: No constraints [Preferred]
Timer Period: 0.001 % 1ms
Use Maximum Period: OFF
Share Timer: OFF (exclusive use)
Result: Automatically selects optimal prescaler and timer peripheral for 1ms period, exclusive ownership.
% High-resolution timer shared between PWM and OC
Timer Name: TimerPWM
Timer Resource: Timer 2 % Force use of Timer2
Use Maximum Period: ON % PR = 65535
Share Timer: ON
Timer Use: Read only % Allow other blocks to read
Result: Timer2 configured at maximum resolution, other blocks can reference “TimerPWM” for synchronization.
% Reserve Timer3 for manual configuration
Timer Name: CustomTimer
Timer Resource: Timer 3
Do Not Setup This Timer: ON % Reserve only
Result: Timer3 reserved but not initialized. User can configure in custom C code using the reserved resource.
% MATLAB workspace variable control
samplingPeriod = 0.0001; % 100µs base period
Timer Name: TimerControl
Timer Period: samplingPeriod
Share Timer: ON
Timer Use: Read / Write / Start-Stop / Period update
Result: Timer configured for 100µs, can be modified at runtime by other blocks.
Timer resolution and maximum period are inversely related through the prescaler:
| Prescaler | Resolution @ 60MHz | Max Period (16-bit) |
|---|---|---|
| 1:1 | 16.67 ns | 1.09 ms |
| 1:8 | 133 ns | 8.74 ms |
| 1:64 | 1.07 µs | 69.9 ms |
| 1:256 | 4.27 µs | 280 ms |
Cause: Duplicate timer names in model.
Solution: Use unique names (TimerA, TimerB, etc.) or custom names. Block automatically suggests alternative names.
Cause: Requested period not achievable with integer PR value.
Solution:
Cause: Multiple peripherals requesting same timer with incompatible settings.
Solution:
Cause: All timers allocated to exclusive-use blocks.
Solution:
MPLAB Blockset for Simulink