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/TMS320F28379D: CCS/TMS320F28379D

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CCSTUDIO

Tool/software: Code Composer Studio

Hello,

I am unable to do printf with floating numbers read from a text file  while integer value is working.

My original work is to read floating values  into an array. The  code i have written is below

#include <stdio.h>
int main(void)
{

float c; // To store a character read from file

int i,ff,ecgArray[1200];
FILE *fp;
fp = fopen("E:\\processor\\ecgData.txt", "r");
char buff[255];
float j;

for(i=0;i<10;i++)
{
fgets(buff, 255, (FILE*)fp);
printf("%d:",i+1);
printf("%d: %s\n",i+1,buff);
sscanf (buff," %f", &j);
ff = j*1000;
// ecgArray[i]=ff;
//ecgArray[i] = ecgArray[i]/1000;
printf(" j val= %d\n", ff );

}

fclose(fp);

return 0;
}

I tried changing the heap size and stack size to 0x400. I am new towards working with CCStudio. Kindly help.

0.02
0.025
0.05
0.075
0.0875
0.125
0.15
0.1625
0.175
0.2
0.225
0.2375
0.25
0.2625
0.2625
0.2875
0.2875
0.2875
0.2875
0.2875
0.2875
0.2875
0.275
0.2625
0.2625
0.25
0.25
0.225
0.225
0.2
0.2
0.175
0.175
0.15
0.15
0.1375
0.1375
0.15
0.1625
0.1875
0.225
0.2625
0.3
0.325
0.35
0.3625
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3875
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3375
0.3375
0.35
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.3625
0.35
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.3375
0.325
0.3375
0.7625
1.225
1.525
1.6125
1.1
0.5375
0.0625
0.0375
0.05
0
0.025
0.05
0.075
0.0875
0.125
0.15

  • Hello,

    Gopika P said:

    I am unable to do printf with floating numbers read from a text file  while integer value is working.

    My original work is to read floating values  into an array. The  code i have written is below

    Your code looks ok

    Gopika P said:
    I tried changing the heap size and stack size to 0x400.

    If you did indeed set the stack and heap size to 0x400, that should be enough:

    There is no output at all in the console?

    Thanks

    ki

  • Hello Ki,

    The console is showing values upto 4. But the loop is given upto 10.

    Sometimes it is showing upto 6 values. never it showed 10 values.

    My real situation is to take upto 1200 values.

  • I get 10 values every time. Regardless of whether I run or source step through the code.

    If you single step through the loop, do you get 10 values?
  • Hello Ki,

    Yes when I did Step Over I got the values till ten.If debug is not done the console is not printing full.

    My real problem is to check weather all values are assigned into an array if it is a float value. When I am printing the float value this is my console.

    The code is shown below.

    ecgArray[i]=j;
    printf(" j val= %f\n", ecgArray[i] );

  • Ok i am using a scaled version of the input to avoid floating point error.

  • Gopika P said:
    Yes when I did Step Over I got the values till ten.If debug is not done the console is not printing full.

    I get all ten, regardless of if I step or just run. The code example you sent me, is that the whole code that you are testing with? Or just a snippet/example? Can you provide your executable?

    Thanks

    ki

  • Hello Ki,

    #include <stdio.h>
    int main(void)
    {

    float c,ecgArray[1200]; // To store a character read from file

    int i,ff;
    FILE *fp;
    fp = fopen("E:\\processor\\ecgData.txt", "r");
    char buff[255];
    float j;

    for(i=0;i<10;i++)
    {
    fgets(buff, 255, (FILE*)fp);
    printf("%d:",i+1);
    printf("%d: %s\n",i+1,buff);
    sscanf (buff," %f", &j);

    ff = j*1000;

    ecgArray[i]=j;

    printf(" j val= %f\n", ecgArray[i] );

    }

    fclose(fp);

    return 0;
    }


  • Thanks. But I am still unable to reproduce the issue. All the printf statements appear in the console. Please provide the full project - something that I can import into my CCS workspace. Also provide the source files, built *.out file and your ecgData.txt file.

    Thanks
    ki
  • Hi Ki,

    I am attaching the text file used in the program.The main file is the same code i have send above.No changes are made.

    0.2
    0.25
    0.5
    0.75
    0.875
    0.125
    0.15
    0.1625
    0.175
    0.2
    0.225
    0.2375
    0.25
    0.2625
    0.2625
    0.2875
    0.2875
    0.2875
    0.2875
    0.2875
    0.2875
    0.2875
    0.275
    0.2625
    0.2625
    0.25
    0.25
    0.225
    0.225
    0.2
    0.2
    0.175
    0.175
    0.15
    0.15
    0.1375
    0.1375
    0.15
    0.1625
    0.1875
    0.225
    0.2625
    0.3
    0.325
    0.35
    0.3625
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3875
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3375
    0.3375
    0.35
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.3625
    0.35
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.3375
    0.325
    0.3375
    0.7625
    1.225
    1.525
    1.6125
    1.1
    0.5375
    0.0625
    0.0375
    0.05
    0
    0.025
    0.05
    0.075
    0.0875
    0.125
    0.15
    

  • I need the project meta files and the outfile you built also. I would like to see the build options used and also try to reproduce with your executable.
  • Hello,
    I haven’t heard back from you, hence this issue is being closed. If you wish to continue the discussion, please post a reply with an update below (or create a new thread).

    Thanks,
    ki
  • Got the problem solved. Changed all the variables to global variables.