Hi Naifar,
I don't think we can print data to .cvs file via c code because there is NO "standard output" in embedded system. User has to implement their own "pseudo" prinf() function, i.e. to format the output in memory and then print out through SCI or CW console window.
however CW can Export Trace to CSV File. you can check it in help file:

can this help?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------