Mplab Or Matlab RTW compilation ?

Create new topics, add your comment, remark, bugs...
Post Reply
barryforever
Posts: 11
Joined: Sun Feb 17, 2008 2:58 pm

Mplab Or Matlab RTW compilation ?

Post by barryforever » Mon Feb 18, 2008 4:19 pm

Hello ..
I have a simple model and i attached that model to this thread ..
I have got a sucessful compilation in matlab that is using RTW.
But when i compile using MPLab tool feature it shows the following error
I run a Matlab r2007b and mplab v8 and your toolbox (17.02.08)
it shows the following error in mplab

Code: Select all

Warning: Error evaluating 'LoadFcn' callback of
Master block (mask) 'Master'. Error using ==>
dsPIC_ConfigRTWOption at 34
The *System Target File must be defined to dsPIC
Real Time workshop (Simulation ==> Configuration
Parameters ==> Real Time workshop.
> In <a href="error:C:\Program Files\Microchip\MPLAB IDE\Tools\Matlab\MplabOpenModel.m,14,1">MplabOpenModel at 14</a>
Warning: In instantiating linked block
'deport/Master' : Invalid setting in Master block
(mask) 'Master' for parameter 'MCLR'.
> In <a href="error:C:\Program Files\Microchip\MPLAB IDE\Tools\Matlab\MplabOpenModel.m,14,1">MplabOpenModel at 14</a>
Which one should i use to program my dspic 6011 please tell me
Attachments
deport.mdl
(21.91 KiB) Downloaded 252 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Mplab Or Matlab RTW compilation ?

Post by LubinKerhuel » Mon Feb 18, 2008 8:45 pm

The MASTER block set the diagram for a 30f6012 dsPIC (not 6011).
RA2 do not exist on the dsPIC 30f6012, nor on the dsPIC 6011. I changed RA2 into RB3.

To import the C code generated, you must follow the procedure described here.

To get the .hex file from simulink in a "one click button procedure", you must uncheck "generate code only"
From Simulink ==> Configuration parameters ==> Real-Time Workshop.
uncheck_GenerateCodeOnly.png
I attached the modified model with the .hex file obtained.
deport.zip
(7.29 KiB) Downloaded 263 times
Note that if you want to import the C code to MPLAB, you should also uncheck "generate code only" in order to compile the required simulink library into an ".a" library binary file which is easier to import into MPLAB.

barryforever
Posts: 11
Joined: Sun Feb 17, 2008 2:58 pm

Re: Mplab Or Matlab RTW compilation ?

Post by barryforever » Tue Feb 19, 2008 1:51 am

i tried compiling in simulink as you said but i was stopped due to error...
I did your sinus PWM tutorial this is what i get

Code: Select all

> In C:\Documents and Settings\Zion\My Documents\MATLAB\blocks\dsPIC_Set_Dialog_PopUp_Param.p>dsPIC_Set_Dialog_PopUp_Param at 57
  In C:\Documents and Settings\Zion\My Documents\MATLAB\blocks\dsPIC_MASTER_callback_InitMask.p>dsPIC_MASTER_callback_InitMask at 225
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
### Starting Real-Time Workshop build procedure for model: mouline
### Generating code into build directory: C:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources
Number of I/O PINs used : 1
Number of I/O PINs used : 1
Number of I/O PINs used : 1
### Invoking Target Language Compiler on mouline.rtw
	tlc
	-r
	C:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources\mouline.rtw
	C:\Documents and Settings\Zion\My Documents\MATLAB\dspic\dspic.tlc
	-OC:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources
	-IC:\Documents and Settings\Zion\My Documents\MATLAB\dspic
	-IC:\Documents and Settings\Zion\My Documents\MATLAB\blocks
	-IC:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources\tlc
	-IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\mw
	-IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\lib
	-IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\blocks
	-IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\fixpt
	-IC:\Program Files\MATLAB\R2007b\stateflow\c\tlc
	-aEnforceIntegerDowncast=1
	-aFoldNonRolledExpr=1
	-aInlineInvariantSignals=0
	-aInlineParameters=0
	-aLocalBlockOutputs=1
	-aRollThreshold=5
	-aZeroInternalMemoryAtStartup=1
	-aZeroExternalMemoryAtStartup=1
	-aInitFltsAndDblsToZero=1
	-aGenerateReport=0
	-aGenCodeOnly=0
	-aRTWVerbose=1
	-aIncludeHyperlinkInReport=0
	-aLaunchReport=0
	-aGenerateTraceInfo=0
	-aForceParamTrailComments=0
	-aGenerateComments=1
	-aIgnoreCustomStorageClasses=0
	-aIncHierarchyInIds=0
	-aMaxRTWIdLen=31
	-aShowEliminatedStatements=0
	-aIncDataTypeInIds=0
	-aInsertBlockDesc=0
	-aSimulinkBlockComments=1
	-aInlinedPrmAccess="Literals"
	-aTargetFcnLib="ansi_tfl_table_tmw.mat"
	-aGenFloatMathFcnCalls="ANSI_C"
	-aIsPILTarget=0
	-aIncludeMdlTerminateFcn=0
	-aCombineOutputUpdateFcns=1
	-aSuppressErrorStatus=1
	-aERTCustomFileBanners=1
	-aLogVarNameModifier="rt_"
	-aGenerateFullHeader=1
	-aGenerateSampleERTMain=0
	-aMatFileLogging=0
	-aMultiInstanceERTCode=0
	-aPurelyIntegerCode=0
	-aPortableWordSizes=0
	-aGenerateErtSFunction=0
	-aGenerateASAP2=0
	-aExtMode=0
	-aExtModeStaticAlloc=0
	-aExtModeStaticAllocSize=1000000
	-aExtModeTransport=0
	-aExtModeTesting=0
	-aInlinedParameterPlacement="NonHierarchical"
	-aTargetOS="BareBoardExample"
	-aMultiInstanceErrorCode="Error"
	-aRateGroupingCode=1
	-aRTWCAPISignals=0
	-aRTWCAPIParams=0
	-aRootIOStructures=0
	-aERTCustomFileTemplate="dsPIC_main.tlc"
	-aGMAKE_PLACE="C:\PROGRA~1\MATLAB\R2007b\bin\win32\gmake"
	-aOPTIM_GCC="-mcpu=30F3012 -O3 -fschedule-insns -fschedule-insns2"
	-aLDFLAGS="-t --report-mem -Map ../untitled.map --heap 0  -cref"
	-aLDPICTYPE="-T C:\PROGRA~1\MICROC~1\MPLABC~2\support\gld\p30f3012.gld"
	-aLDLIBPIC="C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libpic30-coff.a  C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libp30F3012-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libc-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libm-coff.a"
	-aPIC_INCLUDES="-I C:\PROGRA~1\MICROC~1\MPLABC~2\include"
	-aPIC_REF="30f3012"
	-aGenerateTraceInfo=0
	-p10000


### Loading TLC function libraries

....
### Initial pass through model to cache user defined code
.
### Caching model source code
.............
### Writing main
.
### Writing header file mouline_types.h
### Writing header file mouline.h
### Writing source file mouline.c
.
### Writing header file mouline_private.h
### Writing source file mouline_data.c
.
### Writing header file autobuild.h
### Writing source file mouline_main.c
### TLC code generation complete.
### Evaluating PostCodeGenCommand specified in the model

Companie =

     ''



----------------------------------------------------
Embedded Coder for dsPIC V0.96b(13-Feb-2008) for Matlab R2007b.
Licence Accorded to Demonstration Version - 


informations available at  www.kerhuel.eu 

.
### Processing Template Makefile: C:\Documents and Settings\Zion\My Documents\MATLAB\dspic\dspic_pic30_gcc.tmf
### Wrapping unrecognized make command (angle brackets added)
###    <C:\PROGRA~1\MATLAB\R2007b\bin\win32\gmake>
### in default batch file
### Creating mouline.mk from C:\Documents and Settings\Zion\My Documents\MATLAB\dspic\dspic_pic30_gcc.tmf
### Building mouline: .\mouline.bat
 
C:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources>set MATLAB=C:\Program Files\MATLAB\R2007b  
 
C:\Documents and Settings\Zion\My Documents\MATLAB\mouline_dspic\sources>C:\PROGRA~1\MATLAB\R2007b\bin\win32\gmake -f mouline.mk  GENERATE_REPORT=0 MULTI_INSTANCE_CODE=0 PORTABLE_WORDSIZES=0 GENERATE_ASAP2=0 TMW_EXTMODE_TESTING=0  
pic30-gcc  -c -mcpu=30F3012 -O3 -fschedule-insns -fschedule-insns2	 -O   -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB\MOULIN~1\sources -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB\dsp -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc   -I C:\PROGRA~1\MICROC~1\MPLABC~2\include    dsPIC_OutputCompare_Interrupt.c 
process_begin: CreateProcess(NULL, pic30-gcc -c -mcpu=30F3012 -O3 -fschedule-insns -fschedule-insns2 -O -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB\MOULIN~1\sources -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB -IC:\DOCUME~1\Zion\MYDOCU~1\MATLAB\dsp -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc -I C:\PROGRA~1\MICROC~1\MPLABC~2\include dsPIC_OutputCompare_Interrupt.c, ...) failed. 
make (e=2): The system cannot find the file specified.  
gmake: *** [dsPIC_OutputCompare_Interrupt.o] Error 2 
### Real-Time Workshop build procedure for model: 'mouline' aborted due to an error.
There is a error in simulink

Code: Select all

Error building Real Time Workshop target for block diagram mouline Matlab errror Message :
Error using ==>genMakeFileandBuild at 1070
errors encountered in  while building model mouline
Attachments
mouline.mdl
(23.72 KiB) Downloaded 227 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Mplab Or Matlab RTW compilation ?

Post by LubinKerhuel » Tue Feb 19, 2008 9:15 am

Is the C30 compiler (from microchip) installed on your system ?

barryforever
Posts: 11
Joined: Sun Feb 17, 2008 2:58 pm

Re: Mplab Or Matlab RTW compilation ?

Post by barryforever » Tue Feb 19, 2008 1:19 pm

yes
i did install it before the usage of your toolbox

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Mplab Or Matlab RTW compilation ?

Post by LubinKerhuel » Tue Feb 19, 2008 1:26 pm

From the error message, it's not very clear if
- it does not find the compiler
- it does not find the file dsPIC_OutputCompare_Interrupt.c

could you type
>> !pic30-gcc -v
at the matlab prompt to see if it find the C30 compiler ?

you should get

Code: Select all

>> !pic30-gcc -v
Using built-in specs. 
Target: pic30-coff 
Configured with: /home/build/builds/build_20071109/src/gcc-4.0.2/gcc-4.0.2/configure --target=pic30-coff --host=i386-mingw32 --build=i386-pc-linux --program-prefix=pic30-coff- --enable-languages=c 
Thread model: single 
gcc version 4.0.3 (dsPIC30, Microchip v3_02) Build date: Nov  9 2007 
Microchip Language Tool Shell Version v3_02 (Build date: Nov  9 2007). 
Copyright (c) 2006 Microchip Technology Inc. All rights reserved 
>> 
Also, try tp double click on the "Configure model for dsPIC Target" block before compiling. (that set up the different path for your computer)

barryforever
Posts: 11
Joined: Sun Feb 17, 2008 2:58 pm

Re: Mplab Or Matlab RTW compilation ?

Post by barryforever » Wed Feb 20, 2008 1:38 pm

This is what i get

Code: Select all

Warning: Error evaluating 'LoadFcn' callback of Master block (mask) 'Master'. Error
using ==> dsPIC_ConfigRTWOption at 34
The *System Target File must be defined to dsPIC Real Time workshop (Simulation ==>
Configuration Parameters ==> Real Time workshop.
> In load_system at 52
  In libbrowse>i_LoadSys at 142
  In libbrowse>LoadLibrary at 121
  In libbrowse at 24
>> !pic30-gcc -v
'pic30-gcc' is not recognized as an internal or external command, 
operable program or batch file. 
>> 

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Mplab Or Matlab RTW compilation ?

Post by LubinKerhuel » Wed Feb 20, 2008 1:50 pm

the C30 compiler is not included into your environment path.

try to re-install the C30 compiler from microchip.

follow the procedure described on this page

Beware carrefull : The path must be included to the environment

Then, try again to type
>> !pic30-gcc -v
at the matlab prompt.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest