This page provides solutions to common issues encountered when using the MPLAB Device Blocks for Simulink. Issues are organized by category for quick reference.
Symptom: Build fails with error message: "Compiler not found" or "xc16-gcc is not recognized"
Solutions:
Verify compiler installation:
picInfo('check') to check detected compilersC:\Program Files\Microchip\xc16\C:\Program Files\Microchip\xc-dsc\C:\Program Files\Microchip\xc32\Refresh MATLAB compiler cache:
>> RTW.TargetRegistry.getInstance('reset')
>> rehash toolboxcache
Manual configuration: See Compiler Setup โ Manual Configuration
Reinstall compiler: Download from microchip.com/compilers
Symptom: Build fails with: "Device not supported" or "Cannot find device header file"
Solutions:
Install correct DFP:
Update DFP to latest version: Older DFPs may not support newer devices
Verify device name: Check Master block device selection matches exactly (case-sensitive)
Symptom: Build fails with: "undefined reference to 'functionName'" or "undefined symbol"
Common Causes:
Solutions:
Symptom: Build fails with: "section overflow", "program memory exceeds available space", or "data memory exceeds available space"
Solutions:
Enable optimization:
-O2 (free) or -O3 (PRO license)Reduce model size:
Select larger device: Consider microcontroller with more Flash/RAM
Check memory allocation:
Symptom: Simulink shows: "Cannot connect to target" or connection timeout after clicking “Connect to Target”
Solutions:
Check physical connection:
Verify COM port:
Verify UART configuration:
Check target is running:
Restart devices:
Symptom: Connection works initially but drops during operation or parameter tuning
Solutions:
Reduce logged signals: Too many signals saturate communication bandwidth
Increase baud rate:
Check electrical noise:
Disable USB power management:
Symptom: Garbled data, connection timeouts, random characters in Simulink
Solution:
Ensure these three settings match exactly:
Common baud rates: 115200, 230400, 460800
Symptom: Build succeeds but programming fails: "No tool connected" or "Programmer not found"
Solutions:
Check USB connection: Ensure programmer (ICD, PICkit, etc.) is plugged in
Verify programmer is powered: Some programmers have power LED
Install MPLAB X IDE: Required for programmer drivers
Update programmer firmware:
Run picInfo check:
>> picInfo('check')
Should list detected programmers
Symptom: Programming fails with: "Device ID mismatch", "Target device not detected", or "Device ID: 0x00000000"
Solutions:
Check target power: Ensure microcontroller is powered (3.3V or 5V depending on device)
Check programmer connections: Verify ICSP pins (PGC, PGD, MCLR, VDD, GND) are connected
Verify device selection: Ensure Master block device name matches physical chip
Check for damaged chip: Try programming with MPLAB X IDE to verify hardware
Check ICSP voltage: Some programmers provide power, some require external power
Symptom: Build fails immediately: "Model must contain MCHP_Master block"
Solution:
Add the MCHP Master Block to your model:
Symptom: Simulation or build fails with: "Sample time conflict" or "Inconsistent sample times"
Solutions:
Check all block sample times: Ensure blocks have compatible sample times
-1) where possibleReview model hierarchy: Subsystem sample times must be compatible with parent
Use multi-rate scheduler: If model has multiple sample times, enable multi-tasking (Scheduler Guide )
Symptom: Simulink code generation step fails before compiler is invoked
Solutions:
Check block parameters: Some blocks have parameter constraints (e.g., PWM frequency limits)
Verify license: Ensure Embedded Coder license is active:
>> license('test', 'RTW_Embedded_Coder')
Clear cache and rebuild:
>> bd close all
>> clear all
>> rehash toolboxcache
Then reopen model and rebuild
Check MATLAB version compatibility: See Installation Requirements
Symptom: Control loop frequency is lower than expected, or CPU utilization is near 100%
Solutions:
Enable optimization:
-O2 or -O3Profile execution time: Use PIL Testing to identify slow functions
Optimize algorithm:
Switch to multi-tasking scheduler: See Scheduler Guide
Check MCU load: Add MCU Load Block to monitor CPU utilization
Symptom: "MCU Overload" indicator triggers, or timing violations in PIL test
Solutions:
Increase sample period: Reduce execution frequency if possible
Enable multi-tasking: Allows preemption of slow tasks by fast tasks
Optimize code: Follow Performance Issues solutions above
Upgrade microcontroller: Consider faster device (e.g., dsPIC33C โ dsPIC33A)
Symptom: MCHP Blockset library appears empty or blocks are missing
Solutions:
Refresh toolbox cache:
>> rehash toolboxcache
>> sl_refresh_customizations
Verify installation:
>> picInfo
Reinstall blockset: Uninstall and reinstall from MATLAB Add-On Manager
Symptom: Clicking “Help” on a block shows “Page not found”
Solution:
Rebuild documentation search index:
>> builddocsearchdb(fullfile(fileparts(which('MCHP_dsPIC_stf.tlc')), '../', 'doc'))
Then restart MATLAB.
If your issue is not listed here or solutions don’t resolve the problem:
Run comprehensive diagnostics:
>> picInfo('check')
Microchip MATLAB Forum:
๐ forum.microchip.com - MATLAB Section
MathWorks File Exchange Discussion:
๐ MPLAB Device Blocks Discussion Panel
When reporting issues, include:
picInfo)picInfo('check'))| Command | Purpose |
|---|---|
picInfo | Show blockset version and installation path |
picInfo('check') | Check compilers, programmers, paths |
RTW.TargetRegistry.getInstance('reset') | Refresh compiler detection |
rehash toolboxcache | Refresh MATLAB toolbox cache |
sl_refresh_customizations | Refresh Simulink customizations |
bd close all | Close all models and clear memory |
builddocsearchdb(...) | Rebuild documentation index |