Matlab-Simulink device driver Blockset for Microchip dsPIC / PIC24 / PIC32 Microcontrollers.

Simulink - Embedded Target for PIC

From - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)

Jump to: navigation, search


Simulink Blockset Embedded Target microchip devices: Pic24 / Pic 30 / Pic 32 /Pic33

Link to blocks details .

Embedded Target for PIC / dsPIC is a blockset for Matlab® that adds to simulink® Blocks specific to dsPIC and PIC32 peripheral.

Watch the Screencast (April 2009) realized by Mariano Lizarraga for the SLUG team. Better quality movie is available here


The blockset generates C code from a Simulink model for a wide list of Microchip microcontrollers. The generated C code is compiled on the fly to obtain the executable binary file (.hex and .coff file) ready to download into the targeted microcontroller. The downloaded binary program behaves like the Simulink model.

This rapid prototyping tool for 16 bits PIC MCU allows to :

When programming a microcontroller, a lot of time is usually spent on peripheral configuration and on real time problems like sampling rate, multitasking... This blockset gives you the possibility to get ride of these tasks and to concentrate only on the math part (control, filter, logic ...) of the Simulink model. You can simulate the model that will be implemented into the microcontroller. You do not need much knowledge about PIC/dsPIC programming. The blockset support most peripheral present on the microcontroller and configure automatically selected peripherals (configure also timers and model time step).

Debugging and monitoring on chip program with Matlab

Debugging and monitoring variables is very easy through UART thanks to one simulink block and the Graphical User Interface associated:


It makes real time Monitoring and debugging very easy.

It also allows logging data into the matlab workspace. The logged data can be used to feed a Simulink model for simulation. Thus, real microcontroller input data recorded (from ADC, IC...) are used for the simulink simulation or .m script file allowing to test or improve the simulink model using real data logged (noise and characteristics are the real one). Once the simulated model is tune, you can just re-program the microcontroller with the new improved model. The simulation result will be very close to the real model running in the microcontroller since input data come from the same peripheral and the microcontroller's running model is equivalent to the PC simulation model.


The blocks added to the simulink® library allow to connect most of the PIC24, dsPIC30, dsPIC33, and PIC32 peripherals (PWM, ADC, IC, OC, SPI, I2C, CAN, UART ...) to any other Simulink blocks.

C code generated for these peripheral is merged with the C code generated by the Real Time Workshop Embedded Coder® toolbox.

Possible target is most of the dsPIC30f, dsPIC33, PIC24H and few PIC32. ( see details on the download page)

Supported Chip:

See Release Notes and known bug for details

PIC 24F ' PIC 32F** ' PIC 30F ' PIC 30F ' PIC 33FJ GP ' PIC 33FJ MC ' PIC 33FJ GP ' PIC 33FJ MC*
24fJ128GA006 32MX360F256L 30f2010 30f5011 33fJ128GP206 33fJ256MC51033fj128GP20233fj128MC202
24fJ128GA008 32MX360F512L 30f2011 30f5013 33fJ128GP306 33fJ256MC71033fj128GP20433fj128MC204
24fJ128GA010 32MX460F256L 30f2012 30f5015 33fJ128GP310 33fJ64MC50633fj128GP80233fj128MC802
24fJ64GA006 32MX460F512L 30f3010 30f5016 33fJ128GP706 33fJ64MC50833fj128GP80433fj128MC804
24fJ64GA008 32MX775F256L 30f3011 30f6010 33fJ128GP708 33fJ64MC51033fj32GP30233fj32MC302
24fJ64GA010 32MX775F256L 30f3012 30f6011 33fJ128GP710 33fJ64MC70633fj32GP30433fj32MC304
24fJ96GA006 32MX795F512L 30f3013 30f6012 33fJ256GP506 33fJ64MC71033fj64GP20233fj64MC202
24fJ96GA008 32MX320 30f3014 30f6013 33fJ256GP510 33fJ128MC50633fj64GP20433fj64MC204
24fJ96GA010 32MX340 30f4011 30f6014 33fJ256GP710 33fJ128MC51033fj64GP80233fj64MC802
24fJ16GA002 30f4012 30f6015 33fJ64GP206 33fJ128MC70633fj64GP80433fj64MC804
24fJ32GA002 30f4013 33fJ64GP306 33fJ128MC708
24fJ48GA002 33fJ64GP310 33fJ128MC710
24fJ64GA002 33fJ64GP706
24fJ16GA004 33fJ64GP708
24fJ32GA002 33fJ64GP710
Newly added chip 
64MC204, 128MC204, 128GP202, 32MC202, 32MC204, 16MC304 , 33FJ256GP710A
* PIC 32F
SPI function not suported yet;
* Compiler known and fixed bugs 
* Check your compiler installation and version 
at the matlab prompt ==> !pic30-gcc -v for pic30 and !pic32-gcc -v for pic32.
**Check pic32 compiler v 1.04 Workaround
**Check pic30 compiler PWM 2 Workaround from version v 3.12 to current version (3.25)...

The blockset for simulink works with the GCC compiler from Microchip®. MPLAB is not required but can be used for the programming the microcontroller (imports the .hex file and program the target).

Many MathWorks toolbox like "Stateflow®" and "Stateflow coder®" or "fixed point blockset" can be used with the blockset "Embedded Target for dsPIC".

See Examples for more details on the blockset capabilities.

Others Blockset for dsPIC


To provide feedback or add comment about curent page content, please click on "leave a message" at the bottom of most pages. You message will appears at the bottom of the page. Use forum for more general questions or if you need to upload a file (simulink model, image, or whatever).

Need help to make a better site

You are encouraged to crawl through pages and to grab as much information as you need. If you encounter incorrect information, please take time for update this website. Anyone can edit the wiki. You just need to Log in and an edit panel button will appears at the very top of the webpage.

Personal tools
Blocks (Root level)
Digital I/O
Peripheral I/O
Serial PORT
Numerical BUS
Lubin Kerhuel