Can I integrate my own hand code with VisSim auto generated C code?
Altair Forum User
Altair Employee
Submitted by Joe on Tue, 04/23/2013 - 20:55
Hi, I've looked at your generated code and it looks really good. However I want to know if I can write my own hand C code and if so, how do I combine my code with the generated code?
Tagged:
0
Answers
-
Submitted by Anders89 on Tue, 04/23/2013 - 21:25.
Yes, you can. You can do it a number of ways.
- Use VisSim built-in C support. You can use C expressions in the C expression block, or as block parameters. I.e. a gain could be Kd*2*pi. This will simulated using the built-in C interpreter in addition to appearing in the generated code.
- Keep VisSim RTOS and build/debug environment but use externally written functions. You can write completely separate C code using Code Composer or another compiler and add the resulting .obj files to the first line of the file \vissim80\cg\DSP28xcl.bat . It currently has the line 'set USEROBJS=', you add the list of your .obj files to the right of the '='. To read and write external variables in your hand code insert VisSim externRead/externWrite blocks. To call functions in your hand code use the externFunction block. This block lets you set the data type of any return value, and have any number of function arguments. This method lets you stay in the VisSim environment for compiling and debugging.
- Keep VisSim RTOS but use CCS/Eclipse build environment. Generate C code from VisSim and use externRead/Write/Function blocks as in (2) above. You will have to set up search path and VisSim RTOS support libraries to the CCS project
- Use another RTOS and use the CCS/Eclipse build environment. Generate C code from VisSim and use externRead/Write/Function blocks as in (2) above, but choose Use Foreign RTOS during code generation. VisSim will create 2 function, a boot time init function and a periodic rate function that must be invoked at the designed rate for proper performance of time sensitive elements like discrete filters, PID controllers etc.
0