View previous topic :: View next topic |
Author |
Message |
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
How to use C codes converted from Matlab to PIC |
Posted: Fri Dec 30, 2016 2:08 pm |
|
|
Hello Friends,
I'm trying to understand to use C codes converted from Matlab.
Should the generated files be placed in the project folder? and then just #include<abc.h> is it ok? who know this? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Fri Dec 30, 2016 2:37 pm |
|
|
You can include files from wherever you want. Use
Or just put the full path in the include.
'<' is normally used for 'system' includes. Makes the compiler search the system include directories first. '"' instead says search in the 'default' directory (by default the current directory) first.
Remember you are going to have to do a lot of basic changes. Variable types in particular. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Fri Dec 30, 2016 3:08 pm |
|
|
I wonder you have ever worked on it before?
You say me I have to do some changing in these code like variable types .
my example is this
function [c] = coderand( a,b)
c=a*b;
end
Simple code to understand. When I build to generate C code, Matlab give me so much folder, these are Target Source Files:
coderand.c
coderand.h
coderand_initialize.c
coderand_initialize.h
coderand_terminate.c
coderand_terminate.h
coderand_types.h
rtwtypes.h
and also in MATLAB files in my example so much folder, variables are double and I added all Target Source Files (CCS C has problem with it) and I called my function (named coderand) of course doesn't work and also I tried with mikroC and I added all Target Source Files (it's ok) but when I called coderand(a,b,c); error:illegal pointer conversion.
I don't know what I should do, this's little complicated but I'm studying communication engineering, this is why I use mostly Matlab and I have to solve this. |
|
|
Zek_De
Joined: 13 Aug 2016 Posts: 100
|
|
Posted: Fri Dec 30, 2016 4:15 pm |
|
|
Thanks Ttelmah I solved, I didn't see in function const.
Code: | void coderand(const double a[6], const double b[3], double c[2]); |
This is why I was getting error. It's ok now. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Sat Dec 31, 2016 2:27 am |
|
|
If you used #DEVICE ANSI, or #DEVICE CONST=READ_ONLY, const would have the meaning that Matlab is assuming. |
|
|
|