Generating C code from a Matlab-Simulink model for DSP C6748 - c

I'm trying to generate C code from a Matlab-Simulink simple model (eg.: sine wave generator with a DAC at the output). This code must be executed with Code Composer Studio
for TMS320C6748 DSP (Texas Instrument C6748). Specifically, for the development board OMAP-L138 ZOOM ™EVM DEVELOPMENT KIT.
For this, I am using the following versions:
Simulink (Version 7.7 - R2011a)
Embedded Coder (Version 6.0 - R2011a)
Code Composer Studio v3.3
I tried several options (with generic modules in Simulink and programming the C6748 timers, configuring a module "Target Preferences" with "OMAP_L138/C6748 EVM"...) but it isn't working.
Is it possible to implement this idea? Is there an example working?
Thanks

Code generation for OMAP-L138 EVM / C6748EVM is supported in Simulink in R2011a. Before opening the Target Preferences block, import the processor definitions from DSP/BIOS. On the MATLAB command line, type the following:
getDspBiosFolder % This returns which DSP/BIOS MATLAB is seeing. If the value returned matches your installation of MATLAB, then you are OK. Otherwise, you need to use setDspBiosFolder to set the installation folder for DSP/BIOS (i.e. setDspbiosFolder('C:\CCStudio_v3.3\bios_5_33_06') on MATLAB command line).
importDspbiosConfig('proc', 'all')
importDspbiosConfig('board', 'all')
After these steps, you should be able to open the Target Preferences block and examine the settings. Before proceeding with code generation, run checkEnvSetup() utility to make sure that you installed all TI software required for code generation:
checkEnvSetup('ccs', 'omapl138evm', 'list')
The command above gives you a list of what you need to install. After making sure you have all of the software installed above with correct version numbers, execute the following:
checkEnvSetup('ccs', 'omapl138evm')
This sets all environment variables needed for code generation. MATLAB sees the location of the tools through environment variables created this way.
After these steps you should be able to generate code.

Code generation for OMAP-L138 EVM and C6748 EVM is not supported for older versions than Matlab 2011a.
For the release 2011a, the setup process is not trivial and it is not well documented. But Matlab has a patch for this version supports and works with certain specific requirements.
The release 2011b has improvements (hyperlinks required for products of thirds work with CCStudio v4 for this processor) and supports code generation for OMAP-L138 EVM and C6748 EVM.
For the release 2012a, Matlab has considered adding specific sections in the documentation for configuration and automatic code generation with these processors.

Related

Convert an existing code from STM32F0 to Atmel SAMD21 (both are arm-based cortex-M0)

The existing project is running well on STM32F0. The code should be converted to Atmel SAMD21.
The code is written in Visual Studio and using the IntelliSense configuration (ARM Paths). Both projects should use the I2C interface. The package which is used is ChibiOS for STM32.
Because I didn't write the code from scratch, Which part should I change in the code or read carefully? In other words, what is common and different in programming 2 different arms?
Do I need to do my own bootstrap (I mean the initialization part) and linker script? What else is needed?
Also, is there any configuration file for arm definition that I should change?
As I should change chibiOS and add the libraries for Atmel, Which library or package is better to use for Atmel SAMD?
Is there any idea or example that is helpful to compare between these
2 arms?
Much appreciated for any helpful suggestion, in advance.

Visual Studio 2012 with CUDA 5.5 - CUDA syntax & definitions not recognized

for a lab we're suppose to work on I need to set up Cuda with Visual Studio 2012 and run some tests. What I've done:
Install Cuda 5.5 + Edit build configurations.
Visual Studio 2012 is installed.
In the project, right click -> Build Configurations and choose Cuda 5.5
Project -> Properties -> VC++ directories: Set include/lib directories from Cuda directory.
Now, I was under the impression that after doing all this I should have no need to put "#include cudafiles" in my classes, they should be automatically imported, no?
I'm not getting the following as undefined:
cudaFree
cudaError
HANDLE_NULL
The following as 'device is not a type name'
__device__
And __global__ has no storage class or identifier.
I've spent hours and hours and hours trying to get this to work, following tutorials online, but I just can't get it to run properly. The code I'm using can be found here:
https://bitbucket.org/mrfright/cuda_by_example/src/bd759a6527ffa1b88420fc09acbc52f88c0587d2/appendix_a/?at=default
You can see in those files only 'lock.h' and 'book.h' are being included. I am including both of those.
Also, I am very new to C and VS so I may be leaving out a lot of important info.. please advice me to anything you may need to help assess this!! Thanks!
a few key points extracted from the discussion in the comments:
when installing CUDA on windows, make sure VS is installed first. The CUDA toolkit install modifies VS to make compiling CUDA code easier. If VS is not installed or you install/reinstall later, you won't get these modifications.
follow the instructions in the getting started guide including the running of sample projects followed by the building of sample projects. The first point at which you have trouble will be instructive as to what the actual problem is. If you just jump to the end (i.e. trying to create/build/run your own project), it won't be clear where the problem is.
You can build your own CUDA project either by opening an existing project and modifying it, or else creating a new project using the wizard. When just starting out, it may be easier for new users to try modifying an existing project first.
Be aware that various CUDA programs may require a specific compute capability. This means both that your device must support that compute capability, and that you are compiling correctly for that compute capability. You can determine the compute capability of your device by running the deviceQuery sample. You can change the compute capability that you are compiling for in the VS project CUDA settings.
when writing your own CUDA code, and definitely if you are having trouble, you should always do proper cuda error checking
Also be aware that asking questions about how to get drivers loaded, etc. and sorting out machine configuration issues, will very often be considered off-topic for stack overflow. Many questions like this get close votes for this reason.

OpenCV 2.4.4 and GPU support for face detection

I am using GPU for faster face detection. I have found an acceptable tutorial here. I am using VC10 compiler along with CUDA 4.2. The device is well installed and devicequery passes the tests. I also have written programs in CUDA which leaves me no choice but to say that OpenCV has problems with GPU. The real problem is an access violation when I try to get an instance of CascadeClassifier_GPU. Also, getCudaEnabledDeviceCount returns zero. I have compiled OpenCV with CUDA flag on and there was no serious problem during the compilation only a python interface failed which is absolutely non-relevant to GPU. Is there anyone out there who actually succeeded in running a face detection code with haar features on a GPU with OpenCV? Can you give me a hint about what I am missing?
The problem was with OpenCV CMake. The output directory is assumed to be the /build directory however once you check it, you see that all files in the /build are old. You should gather new dll and lib files from /bin and /lib. This is a major flaw in my opinion since many people will use the old files and think their compile was unsuccessful. Please also note that the CUDA version must be 4.2.9 both SDK and Toolkit once you are building the project. Now GPU module works just fine for me.

Multiple Precision for Visual Studio 2010

Can anyone suggest a multiple precision library that comes with pre-built windows binaries. I need to use it use with an existing Visual Studio 2010 project (or where I can get pre-built binaries for win7 64bit for GMP).
I have tried and failed to compile GMP and MPIR and other projects none of them work with various frustrating and ambiguous errors. Unfortunately time pressures are getting to me and what I need to implement is simple if I can get the library built/downloaded.
I need floating point support so a bigint library is not enough.
Thanks,
http://www.cs.nyu.edu/exact/core/gmp/ has the following package with dlls:
dynamic GMP library and header file for Visual C++: gmp-dynamic-vc-4.1.2.zip
They also have the source project files if you want to try recompiling with a different version at some point.
Your best bet is MPIR. I've built MPIR and MPFR using VS 2010 so it is possible. My Windows system is down at the moment but here are some notes I made.
Download MPIR, unpack, and rename directory to just be "mpir" - remove any version numbers.
Find and follow the readme file that documents installing VSYASM.
Run "mpir_config.py" with Python 3.x to create the project files.
Change the number of parallel builds to 1.
Select a particular target (say "lib_mpir_k8") and it should build.
MPIR also includes a couple of batch files so you can do a command line build using configure.bat and make.bat. I find it is easier than the GUI builds.
IIRC, to build MPFR, I had to modify some of the Include directories but my notes are a little too cryptic.
The MPIR mailing list is quite helpful, too.

can't build CUDA project in visual studio 2008

I'm a first year student Computer Science major at the University of Belgrade.My Soft Computing project is to compare a performance of CUDA implementations of different population based algorithms, such as Genetic algorithms, Ant Colony Optimization, Bee Colony, Firefly and PSO. It is not expected from me to write all these codes, since I am a first year student.My assignment is just to try to find codes, run them and measure the performance difference between CPU and GPU implementations.
A few good people sent me a CUDA implementation of Genetic Algorithm that was developed under Linux. Since I am not very familiar with Linux, I am having trouble to build and run CUDA project in visual studio on windows.
Make file is included in project but I think that it is not complete. Make file includes another make file which I do not have. I tried to run it under win 7, but it was unsuccessful, so I installed win xp, visual studio 2008, CUDA SDK 2.3 and matching drivers. Whatever I try, I am always having same problems.
First, I got u_int32_t is undefined (u_int32_t is custom defined type), so I replace it with __int32, and that solves the problem.
After that I get the following errors: rint is not defined and log2 is not defined. I don't know why I get these errors since math_functions.h is included indirectly in project via common_functions.h. Then I put two lines with these function under comments, and give some fixed values to that variables.
And after that I get linker errors. For example:
Error 3 error LNK2019: unresolved external symbol _h_fit referenced in function "public: __thiscallGa::Ga(int *,char * *)
Is there anything that I can do? In addition, I would be very thankful if anyone is willing to send me CUDA implementation of Genetic Algorithm that works. My e-mail address is in my profile.
EDIT:
I set include pats to all h files, link pats to lib files. I also set CUDA build rule. I can build and run other CUDA projects just fine.
Install NSight 1.51. This will get the build rules etc all set up for you.
May sure that the Include Directories property in the projects Configuration Properties | VC++ Directories tab include a path to the SDK's includes. Something like:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include
Make sure that the Linker | Input tab has cudart.lib as one of the Additional Dependencies
The linker error looks like it can't find methods like Ga(int *,char * *) which I'm assuming is part of your GA algorithm. Are you trying to link a CUDA project to another VS project to use the CUDA GA library? If so you need to make sure that the class that exploses the GA library to other code is marked as
class __declspec(dllexport) {classname}
So that the DLL exports the class and the other VS project needs to include a dependency to the CUDA project. Without seeing how your solution is configured it's hard to say more.
Here are two tutorials on getting started with CUDA and Visual C++ 2010, most of this applies to VS 2008:
http://blog.cuvilib.com/2011/02/24/how-to-run-cuda-in-visual-studio-2010/
http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/
There's also a post on the NVIDIA forum:
http://forums.nvidia.com/index.php?showtopic=184539
Make sure you have set include path to h files,
link path to lib files,
build event to copy dlls.
(All to correct paths in Toolkit and SDK.)
And also use CUDA's rule file to set up build tool
for cu files.

Resources