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/TMS320F28335: Writing float - continuously running data to file.

Part Number: TMS320F28335

Tool/software: Code Composer Studio

So i'm trying to write data from my ADC to a simple text file. 

I'm using breakpoints to write data to file, when i use this for an integer "a" while incrementing (a++),  when i finish running the program the data is displayed correctly (see at bottom of post).
However if i try to do the same using a float (multiplying with an incrementing integer with pi, it displays the same value twice). 
And if i try to sample values from the ADC it displays the same floating value at least 4 times - and skips some values that i would expect to be displayed (i would expect with a resolution of 4096 and a sampling frequency of 100 microseconds i would see all of the discrete values used while changing the voltage with a potentiometer).

As seen on the figure it is a quite significant leap within sample 3 to 18 from 1.65 to 2.25 volts. 



If i set the length to anything but 0x01 for a float (i've tried 0x02, 0x03 0x04) i get some totally arbitrary values, like i am  extracting wrong parts of the memory. 
  

int float with length x01  float with length x02 float with length x04 ADC measurements length x0 ADC discrete value
1 3.141592654 0 0 0.479003906 654
2 3.141592654 0 0 0.479003906 654
3 6.283185308 0 0.145825192 0.479003906 654
4 6.283185308 0 3.14592654 0.479003906 654
5 9.424777962 3.141592654 0 0.48046875 656
6 9.424777962 0 0 0.48046875 656
. . 3.141592654 0.145825192 0.48046875 656
. . 0 3.14592654 0.48046875 656
. . 6.283185308 3.14592654 0.48046875 656

So the questions are:
1. What am i doing wrong?
2. Is there a better way to extract the full data set from the DSP?
3. Why is the float displaying same value twice, and from the ADC multiple times? 

Bonusinfo: i'm using PWM to start AD conversion, code composer studio v. 6.1.3 ..

  • Hello Anders,
    Could you share your application (or a code sample)?

    Thanks
    ki
  • int x=0;

    float pi = 3.1415926535897932384;

    float bh = 0;

    interrupt void cpu_timer_isr(){

    CpuTimer0.InterruptCount++;

    x++;

    bh=x*pi;

    }

    When i use breakpoints to write data i get the following results for x++ and for bh=x*pi:

    0 0.0
    1 0.0
    2 0.0
    3 3.14159274
    4 3.14159274
    5 3.14159274
    6 6.28318548
    7 6.28318548
    8 6.28318548
    9 9.42477798
    10 9.42477798
    11 9.42477798
    12 12.566371
    13 12.566371
    14 12.566371
    15 15.7079639
    16 15.7079639
    17 15.7079639
    18 18.849556
    19 18.849556
    20 18.849556
    21 21.9911499
    22 21.9911499
    23 21.9911499
    24 25.1327419
    25 25.1327419
    26 25.1327419
    27 28.274334
    28 28.274334
    29 28.274334

    The only difference in breakpoint properties is which address i write, and for format i choose x to write as integer and bh as float.
    As stated in the post, if i change the length to anything else than 0x01, i get some weird results..