This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

open data file failed

I want to read a .dat file and store the data to the DDR3 on EVM6678L. Firstly, I use the following code to open a file.

FILE *fp;

if((fp = fopen("data.dat","r"))!=NULL)

{

printf("Open succeed!\n");

}

But the return value of function fopen always is NULL. Never open file succeed.

I want to know how to open the file succeed.?

Best regards

  • Hi Rui Guo,
    I guess its not able to open because its not able to locate where the file is exactly.
    Where exactly are you placing the file "data.dat" in your workspace ? If your file is placed in the workspace and not in any other folder inside the workspace, then try using this:

    if((fp = fopen("../data.dat","r"))!=NULL)

    If inside a folder name, then use:
    if((fp = fopen("../<folder_name/path>/data.dat","r"))!=NULL) 

    Its important to specify the exact path of the file for it to open.

    One more thing. Is loading the dumps in the .dat file into the DDR3 memory your prime reason you using fopen, fread() ?? If so, you can directly load the contents of .dat file  into the required memory using "Load Memory" option in the Memory Browser.

    Regards

    Sud

  • Thanks for your reply.
    follow your advice specifying the exact path of the file I have open a file successfully.
    And I try to load the contents of a file into the required memory using "Load Memory"option
    in the Memory Browser. It's effective for some .bin file ,but for some .dat file following error
    occurred. Whether it is valid only for some file with specific header information ?
    how can I load my .dat file successfully ?

    Best regards

  • Hi Rui Guo,

    Where exactly did the .dat file was created from? Maybe the .dat file is not in its format(header information) for the CCS to detect the type of the .dat file.
    May be you can find more details in the below thread. Please revert back here after finding the solution to the issue.

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/168292.aspx

    Regards

    Sud