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.

Reading a dat file into c5515

Other Parts Discussed in Thread: TMS320C5515

Hi,

I'm attempting to read data from a .dat file. I am using TMS320C5515. The hex data is in the following format:

F4FF F3FF F4FF F1FF F3FF F2FF F2FF EEFF

F0FF EDFF F0FF EDFF F0FF EDFF EFFF EEFF

EEFF ECFF EFFF EBFF EEFF F7FF 0100 0300

0900 1F00 1C00 0900 0100 F8FF EFFF D8FF

The actual data is available in the following page: http://www.physionet.org/physiobank/database/apnea-ecg/a01.dat

I had first written code in eclipse 3.3 and it worked perfectly. I tried to use the same code in CCS4 and it does not read the data correctly. I have tried this with several different files. It reads correctly some values and and there is junk in the rest. In this case, the code reads correctly from the beginning until the value 0100 and then reads 0 for all other values. In other cases it fills in junk from the very first value. The data is read 1 byte at a time. Here's the code I am using:

 

int i,j;

    Int16 temp1, temp2; //Int16 is defined as short

    Int16 table[120];

    FILE *in;

    in = fopen ( "c:\\a01.dat", "r" );

    if ( in != NULL ) {

    for ( i = 0; i < 120; i++ ) {

       fscanf (in, "%c", &temp1); //Reading 1st byte

       temp1 = temp1 & 0xFF;

       fscanf (in, "%c", &temp2);

       temp2 = temp2 & 0xFF; //Reading 2nd byte

       temp2 = temp2 << 8; 

    table[i] = temp1|temp2; //Adjusting Endianess

                printf ( "%d %hx \n", i, table[i]);

 }

 }

 fclose ( in );

I observed temp1 and temp2 on a watch window and they are being filled in with junk. What could be the problem and how can I resolve this?

Thanks,

Nandan