1. open simulink section and goto "user defined function "block. choose "Embedded Matlab function".make a new model and drag Embedded Matlab function in it. 2. open this block and copy-paste ur own matlab code i.e. m file into that one. 3. give proper input and output in your model to check whether ur m file is working correctly or not. 4.Save ur model and Simulate it.u will get ur results. 5.Go to "simulation" part of ur model and choose "configuration parameters"then open it. 6.go to "solver" first and select simulation time whatever u want or just leave it. choose solver option type as "fixed"(it will generate more efficient code). 7.go 2 "data import/export" option and deselect 'time' and 'output' option,leave all the things as it is. 8.u can choose ur processor in hardware implementation block also. 9.now go to "real time workshop" option and choose ur target board.remember that data types u have chosen in hardware implementation should not conflict with target board. 10.go to 'documentation' and select all reports,choose "comment" whatever u want. in comment section, also go to "debug" and select "verbose mode" in RTW process. 11.apply and goto "real time workshop" ,again apply and build it. 12.The matlab path what u given ,it will store the 'c' code at that place. also it will be displayed code generation HTML report to u immediately.The main 'c' file is boss and all header files and some supporting files are just slaves but all r important to make ur project on CCS IDE. The "C" code is highly optimized and hard nut to crack but good becoz of it's speed. for better result, try to initialize all variabels in ur m file.