File Exchange

image thumbnail

MPLAB Device Blocks for Simulink :dsPIC, PIC32 and SAM mcu

version 3.46.063 (9.25 MB) by Lubin Kerhuel
Microchip support package for Embedded Coder


Updated 28 Aug 2020

GitHub view license on GitHub

MPLAB Device Blocks for Simulink enables Embedded Coder for automated build and execution of real-time executable for any board equipped with a dsPIC (r), PIC32 (r) or SAMx7 from a Simulink model.


1. [download]( and unzip the package
2. execute the .p installer script . Within Matlab, right click on file install.p and select run.


Built-in scheduler including single-tasking and multi-tasking option for multi-rate models.

Advanced configuration of ADC / PWM peripheral enable PMSM motor algorithm where ADC sample time is triggered precisely within a PWM duty-cycle. The time step might also be triggered by end of ADC conversion minimizing delays.

A custom protocol allows visualizing and recording data through the UART. The custom picgui interface allows plotting using your own matlab script incoming data in real-time. Data log enable further analysis or offline identification and allow to feed a simulation with real data.

The custom "C function" block allows including your own code if required.

The blockset also support MathWorks features like:
- Hardware in the loop (HIL)
- External mode features.
- Code replacement to benefit from DSP architecture of dsPIC

This version embed a third part tool adding blocks for UAVs projects (GPS, MAVLink, Receiver S.BUS, S.Port and F.Port blocks for dsPIC). Type picInfo to find out how to install the UxV blocks.

Cite As

(Microchip Technology) MPLAB-Device-Blocks-for-Simulink

Comments and Ratings (12)

Lubin Kerhuel

dual-core (dsPIC 33CH family): Create two models. One target the Main core (select 33CH512MP508 in master block), the other target the secondary (33CH512MP508S1).
Add within the master model the block "SLAVE core”; open and pick the slave Simulink model name.
When the Master is compiled, the slave will also get compiled and the. s generated added to the Master binary.
Use the MSI block to send/receive data between the two cores.


how to generate code for dual-core processors like dsPIC33CH128MP508?

David White

Great tools, however I'd also be very keen to see the reinstatement of the CAN bus blocks, even if they only supported a subset of the ECAN interface. Many thanks. David

Phan Liem

Sylvain Thomazo

Sur votre ancien site "" on peut voir apparaître dans votre librairie "Simulink Blockset Embedded Target microchip" des blocks pour le BUS CAN.
Or sur la dernière version 3.46.03 ces blocks ne sont plus disponibles. Est-il prévu dans une prochaine realease que ces blocks soient de nouveau disponibles?
Merci d'avance,

Lubin Kerhuel

HI Dikko,

You might copy examples in the current working folder typing picInfo at matlab prompt then click on links provided.
Some examples deal with I2C.

Another source of information might be the Microchip forum ; this thread is related to I2C:


Could someone be kind enough to post an example of using the I2C block; please, why is there no help file for these block as provided for others?

Julio Walter

Ryan Roy

Thanks for this information. It useful

Phillip Maser

How does this MPlab Block Set Work? How does one obtain this embedded coder or is it needed. The fact that we need all these tools. Can we use other toolboxes with this MPlab. I would like to use fmincon and other toolboxs with this design.


Lubin Kerhuel

Hi Deepak,

The blockset is compatible with Windows platform. It has never been tested with MAC OS and all functions related to programming, also compiling might not work properly on MAC.


Deepak Deepak

Hello! Thank you for sharing MPLAB blockset.

I was trying to install it in Matlab 2018a (Mac OS 10.14.4). I am getting the following error:
Microchip Blockset 3.45 installed. See info and examples.
Save path
Update start-up matlabrc.m script
no setup for programming API required with this blockset version.
Error: MCHP Java API: cannot locate the SystemRoot folder
Tool MPLAB X not found using the registry.
Tool MPLAB X not found searching in program file folder.
Refresh cache
Register Compilers
Microchip Blockset 3.45 installed. See info and examples.

Blockset Installation done.


Start Script to clean old MPLAB X java API wrapper to program chip directly from Matlab : >>MCHP_API_Flash('remove')
Tool MDB not found using the registry.
Tool MDB not found searching in program file folder.
Tool IPE not found using the registry.
Tool IPE not found searching in program file folder.


Could you please suggest how to troubleshoot this ?

Thank you for your time :)




- Support for SAMx5 familly
- Fixed search issue for recent XC compilers
- Support external CMSIS and DFP packages
- Renamed scripts pad and padr to picgui.pad/padr (Conflict with MathWorks scripts on recent versions)


PIC32: extend option for peripheral output pin (Peripheral Pin mapping)
Model reference: Fixed compilation error when creating a library for model reference


- Updated PIC32MZ SPI DMA implementation
- Some setup had issues related to system java version; fixed.


- Programmer interface (Java might not be found)
- SAMx7 chip issues with doc block ; MPLAB X project
- Installer script propose old installation method (might fix add-ons issues related to user permissions in classroom/lab setup)


Support added for dsPIC CH dual core DSCs


- fixed QEI typo in generated code (PIC32)
- fixed SPI typo on slave implementation (PIC32)


- PIL and Ext-Mode GUI issue UART
- PIC32 Compiler block issue with heap size
- PIC32 code for Timer might not compile

- Improved MPLAB X project creation
- Added Ext-Mode example for PIC32MZ


- Extended supported chip
- Added programming interface user choice (MDB vs IPE)
- Improved support for SNAP and PICKIT 4 programmers
- Fixed some compatibility issue with older Matlab release
Other minor improvements, see file


Updated installer. Compatible from R2010a to R2019a

MATLAB Release Compatibility
Created with R2010a
Compatible with R2010a to any release
Platform Compatibility
Windows macOS Linux