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.

CCS/AM5708: DSP fopen CCS

Part Number: AM5708

Tool/software: Code Composer Studio

Hi,

I encounter a problem about using "fopen" funtion to read the file by CCS.

the ccs_project is attached , could you please help me to modifiy the code of CCS_project so that it can achieve the below function:

1. read the data from a file.

2.handle the data on DSP(simply such as tmp++)

3.print the reult in CCS.

test_file.gz

  • C66x_file.zipHi,

    This is not related to DSP, just how to read numbers from text file using C language. Search for such topic on the Internet, you can find some examples and discussion what problem met and fixed.

    Below is my modified C code and the CCS project attached.

    #include <stdio.h>

    #include <string.h>

    void main(void)

    {

       FILE *fp;

       unsigned int i, tmp;

       fp = fopen("text.txt", "r");

       if (NULL == fp)

       {

           printf("\n fopen() Error!!!\n");

           return;

       }

       printf("\n File opened successfully through fopen()\n");

       for (i = 0; i < 10; i++)

       {

           fscanf(fp, "%d", &tmp);

           printf("Read in %d\n", tmp);

       }

       fclose(fp);

    }

    Results:

    File opened successfully through fopen()
    Read in 1
    Read in 2
    Read in 3
    Read in 4
    Read in 5
    Read in 6
    Read in 7
    Read in 8
    Read in 9
    Read in 0

    Regards, Eric

  • Thanks very much . it help me .