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


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

Rapid Prototyping Tools or experimentation for Microchip PIC / dsPIC microcontroller



Microchip released a first version of a blockst in late 2008 (about november). The version 2 of the microchip blockset were released on June, 5th 2009. It seems that The Dev Team get inspired from an old version of my blockset (*). Anyway, with this blockset, you have to configure all registers of the peripheral. This it not really convenient. I also did not see efficient interrupt handling to make some peripheral works. A free evaluation version is available from their website. Please try it and report your impressions.

3 simple steps to remove the 30s pause from microchip free evaluation version :

  • Remove/Rename the file ./Microchip/MPLAB IDE/Tools/MATLAB/dsPIC_Matlab/dspic/serKeyVal.p (renamed in serKeyVal.old)
  • create a new m file in the same directory
function a = serKeyVal()
disp('Hello Word')
  • save as serKeyVal.m

(*) speicfic parts of code from my blockset can be found in microchip blockset (but that's not official !): In microchip dsPIC_mrmain.tlc file in directory dspicblks, you can find

   %if (CalculusTimeStepEN == 1)
          CalculusTimeStep = TMR1;
   %if (MasterBusyPort != -1)

Sames instructions in the original: In Lubin's blockset, dsPIC_mrmain.tlc file in directory blocks

   %if (CalculusTimeStepEN == 1)
       if (_T1IF) CalculusTimeStep = PR1;  /* Overload */
       else CalculusTimeStep = TMR1;     
   %if (MasterBusyPort != -1)

[ Review]

   (differences comes from the fact that I improved it, i.e. Microchip did not get inspired from my last version)

This code is a very specific function that can only be found in the "Lubin's blockset" (not accessible in the microchip blockset). This code remains in Microchip blockset, even in V2 published on 5th 2009. There are probably other similar part of code.

(I now scramble tlc files so as to avoid non-official collaboration. Thus, you will recognize variables name : CalculusTimeStepEN and CalculusTimeStep in my tlc file.)


product from SimuQuest companie sell a Matlab toolbox for Microchip PIC18Fx480/x580 (9000$ for a single licence including the UniPhi product)


Evidence Companie built a Scilab/Scicos Code Generator for the FLEX board which is based on a microchip microcontroller

Embedded Target for dsPIC

v3.7e - (10 sep 2012) - suporting 100 chips

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 33fJ256MC510 33fj128GP202 33fj128MC202
24fJ128GA008 32MX360F512L 30f2011 30f5013 33fJ128GP306 33fJ256MC710 33fj128GP204 33fj128MC204
24fJ128GA010 32MX460F256L 30f2012 30f5015 33fJ128GP310 33fJ64MC506 33fj128GP802 33fj128MC802
24fJ64GA006 32MX460F512L 30f3010 30f5016 33fJ128GP706 33fJ64MC508 33fj128GP804 33fj128MC804
24fJ64GA008 32MX775F256L 30f3011 30f6010 33fJ128GP708 33fJ64MC510 33fj32GP302 33fj32MC302
24fJ64GA010 32MX775F256L 30f3012 30f6011 33fJ128GP710 33fJ64MC706 33fj32GP304 33fj32MC304
24fJ96GA006 32MX795F512L 30f3013 30f6012 33fJ256GP506 33fJ64MC710 33fj64GP202 33fj64MC202
24fJ96GA008 32MX320 30f3014 30f6013 33fJ256GP510 33fJ128MC506 33fj64GP204 33fj64MC204
24fJ96GA010 32MX340 30f4011 30f6014 33fJ256GP710 33fJ128MC510 33fj64GP802 33fj64MC802
24fJ16GA002 30f4012 30f6015 33fJ64GP206 33fJ128MC706 33fj64GP804 33fj64MC804
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 Autonomous Unmanned Systems (USL)

This team at the University or South Florida works of Unmanned Aerial Vehicles (UAV). In a step by stem approach, they validate the simulink generated code by compiling it and connecting the "Autopilote PC-software" to a plane simulation software (X-Plane). Then, they compile the code to implement it into a PIC18f 4620. They deal with timing and PIC peripheral by integrating "hand coding functions" into the code generated by Matlab.

Two refferences:

D. Ernst, K. Valavanis, J. Craighead, “Unmanned Vehicle Controller Design, Evaluation and Implementation: From MATLAB to Printed Circuit Board”, Journal of Intelligent and Robotic Systems (In print)

D. Ernst, K. Valavanis, J. Craighead, Automated Process for Unmanned Systems Controller Implementation Using MATLAB, CD-ROM Proceedings, 14th Mediterranean Conference on Control and Automation, Ancona, Italy, June 2006.

<comments \>