Problem of configuring a dspic with Simulink Blockset
Problem of configuring a dspic with Simulink Blockset
Hi,
I have programmed a dsPIC named 33FJ32MC202 with the palteform of simulink and I can get 04 PWM from 06.
PWM 1H,L and PWM 2H,L are activated. although I have activated all of my PWM in the programme.
The code generated by the simulink blockset is attached.
Thank you for helping me.
I have programmed a dsPIC named 33FJ32MC202 with the palteform of simulink and I can get 04 PWM from 06.
PWM 1H,L and PWM 2H,L are activated. although I have activated all of my PWM in the programme.
The code generated by the simulink blockset is attached.
Thank you for helping me.
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Problem of configuring a dspic with Simulink Blockset
Hi,
could you also post the simulink model file ? Here are onlymplab projects file
could you also post the simulink model file ? Here are onlymplab projects file
Re: Problem of configuring a dspic with Simulink Blockset
Hi,
You find the SIMULINK project attahched. I have written a code in c. All PWM pins work. But with the interface I have only 04 PWM that are working.
Thank you.
You find the SIMULINK project attahched. I have written a code in c. All PWM pins work. But with the interface I have only 04 PWM that are working.
Thank you.
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Problem of configuring a dspic with Simulink Blockset
Hi,
You are using Microchip blockset.
Please give a try using this one:
http://www.kerhuel.eu/wiki/Download
Lubin
You are using Microchip blockset.
Please give a try using this one:
http://www.kerhuel.eu/wiki/Download
Lubin
Re: Problem of configuring a dspic with Simulink Blockset
Hi,
I am using the simulink blockset which you advise me. I can get A c code but I am not able to get the .hex code.
So the programme is attached.
The error that I have is:
### Processing Template Makefile: C:\DSPIC\dspic\dspic_pic30_gcc.tmf
-- Bypassing matlab internal LCC configuration --
### test.mk which is generated from C:\DSPIC\dspic\dspic_pic30_gcc.tmf is up to date
### Building test: "C:\PROGRA~1\MATLAB1\R2007b\bin\win32\gmake" -f test.mk GENERATE_REPORT=0 MULTI_INSTANCE_CODE=0 PORTABLE_WORDSIZES=0 GENERATE_ASAP2=0 TMW_EXTMODE_TESTING=0
''pic30-gcc -c -mcpu=33fj32MC302 -O3 -fschedule-insns -fschedule-insns2 -O -I. -I..\.. -IC:\PROGRA~1\MATLAB1\R2007b/simulink/include -IC:\PROGRA~1\MATLAB1\R2007b/extern/include -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/src/ext_mode/common -IC:\Projet_DMA\test_dspic\sources -IC:\Projet_DMA -IC:\PROGRA~1\MATLAB1\R2007b\rtw\c\libsrc -I C:\PROGRA~1\MICROC~1\MPLABC~2\include test_main.c
test_main.c:35: error: syntax error before '&' token
test_main.c:36: error: syntax error before 'int'
gmake: *** [test_main.o] Error 255
### Real-Time Workshop build procedure for model: 'test' aborted due to an error.
C30 Compiler found
C30 Compiler found
Thank you.
I am using the simulink blockset which you advise me. I can get A c code but I am not able to get the .hex code.
So the programme is attached.
The error that I have is:
### Processing Template Makefile: C:\DSPIC\dspic\dspic_pic30_gcc.tmf
-- Bypassing matlab internal LCC configuration --
### test.mk which is generated from C:\DSPIC\dspic\dspic_pic30_gcc.tmf is up to date
### Building test: "C:\PROGRA~1\MATLAB1\R2007b\bin\win32\gmake" -f test.mk GENERATE_REPORT=0 MULTI_INSTANCE_CODE=0 PORTABLE_WORDSIZES=0 GENERATE_ASAP2=0 TMW_EXTMODE_TESTING=0
''pic30-gcc -c -mcpu=33fj32MC302 -O3 -fschedule-insns -fschedule-insns2 -O -I. -I..\.. -IC:\PROGRA~1\MATLAB1\R2007b/simulink/include -IC:\PROGRA~1\MATLAB1\R2007b/extern/include -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB1\R2007b/rtw/c/src/ext_mode/common -IC:\Projet_DMA\test_dspic\sources -IC:\Projet_DMA -IC:\PROGRA~1\MATLAB1\R2007b\rtw\c\libsrc -I C:\PROGRA~1\MICROC~1\MPLABC~2\include test_main.c
test_main.c:35: error: syntax error before '&' token
test_main.c:36: error: syntax error before 'int'
gmake: *** [test_main.o] Error 255
### Real-Time Workshop build procedure for model: 'test' aborted due to an error.
C30 Compiler found
C30 Compiler found
Thank you.
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Problem of configuring a dspic with Simulink Blockset
You're not very lucky, you find a bug in my toolbox also 
Thus, here is the generated code for the file with the error :
I could not see obvious error here. If you got any ideas it would be helpfull !
Lubin

Thus, here is the generated code for the file with the error :
Code: Select all
File: C:\Mes_doccuments_Maison\prog\Matlab2\RTWdsPIC\Developpements\Forum\New Folder\test_dspic\sources\test_main.c
1 /*
2 * File: test_main.c
3 *
4 * Real-Time Workshop code generated for Simulink model test.
5 *
26
27 #include "test.h"
28 #include "test_private.h"
29
30 /* trick : Microchip renames ICS_NONE in ICS_PGD (February 2010) ! */
31 #ifndef ICS_NONE
32 #define ICS_NONE ICS_PGD
33 #endif
34
35 _FSS( RSS_NO_RAM & SSS_NO_FLASH & SWRP_WRPROTECT_OFF )
36 _FGS( GCP_OFF & GSS_OFF & GWRP_OFF )
37 _FOSCSEL( FNOSC_PRIPLL & IESO_OFF & 0xFFFF )
38 _FOSC( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_HS)
39 _FPOR( FPWRT_PWR1 )
40 _FWDT( FWDTEN_OFF )
41 _FICD( JTAGEN_OFF & ICS_NONE )
42 void rt_OneStep()
43 {
44 /* Disable interrupts here */
45
46 /* Save FPU context here (if necessary) */
47 /* Re-enable timer or interrupt here */
48 test_step();
49
50 /* Get model outputs here */
51
52 /* Disable interrupts here */
53 /* Restore FPU context here (if necessary) */
54 /* Enable interrupts here */
55 }
56
57 int main(void)
58 {
59 PLLFBD = 38; /* configure clock speed */
60 CLKDIV = 3;
61
62 /* Initialize model */
63 test_initialize(1);
64 for (;;) {
65 /* Associate rt_OneStep() with a timer that executes at the base rate of the model */
66 while (!_T1IF) ;
67 _T1IF = 0;
68 rt_OneStep();
69 }
70 }
71
72 /* File trailer for Real-Time Workshop generated code.
73 *
74 * [EOF]
75 */
76
Lubin
Re: Problem of configuring a dspic with Simulink Blockset
hello,
I have bump into a similar problem when I worked with dspic30.
i have build a simple model that power a brushless motor using i2c. here is the model: The HEX file couldn't been created by the matlab, but it succeed to generate the code.
when i opened the mplab project and try to build it from there i have noticed that the problem is connected with the following line in the main file:
_FOSC(CSW_FSCM_OFF & CSW_FSCM_OFF)
_FWDT(WDT_OFF)
_FBORPOR(PBOR_OFF & PWRT_OFF & MCLR_EN)
_FGS(CODE_PROT_OFF)
_FICD( ICS_PGD1 )
so i deleted those lines and set the "bit configuration" manually to the following values: after that, it have build successful.
Since then, i did those step to any model that i made for the dspic30.
I hope that it can give you a clue about the nature of the problem
Alpert.
I have bump into a similar problem when I worked with dspic30.
i have build a simple model that power a brushless motor using i2c. here is the model: The HEX file couldn't been created by the matlab, but it succeed to generate the code.
when i opened the mplab project and try to build it from there i have noticed that the problem is connected with the following line in the main file:
_FOSC(CSW_FSCM_OFF & CSW_FSCM_OFF)
_FWDT(WDT_OFF)
_FBORPOR(PBOR_OFF & PWRT_OFF & MCLR_EN)
_FGS(CODE_PROT_OFF)
_FICD( ICS_PGD1 )
so i deleted those lines and set the "bit configuration" manually to the following values: after that, it have build successful.
Since then, i did those step to any model that i made for the dspic30.
I hope that it can give you a clue about the nature of the problem
Alpert.
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Problem of configuring a dspic with Simulink Blockset
Alpert,
This look like a problem with few compilers version as the FICD register were renamed as ICD.
Some blockset version used FICD or ICD as register to comply with the latest compiler.
please download the latest C30 (v3.31) compiler version and the latest blockset (v3.7c)
Everything should works fine now.
Lubin
This look like a problem with few compilers version as the FICD register were renamed as ICD.
Some blockset version used FICD or ICD as register to comply with the latest compiler.
please download the latest C30 (v3.31) compiler version and the latest blockset (v3.7c)
Everything should works fine now.
Lubin
Who is online
Users browsing this forum: No registered users and 16 guests