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.

[C6747] Problems with COS function in CCS

Other Parts Discussed in Thread: OMAP-L137, CCSTUDIO

I am having a hard time figuring out why my program is kicking back odd numbers.  I found the cos function is not returning values that make sense.  Below is a small test program I stepped through with the results ... any ideas on why ...

/****************************************************************************/

#define PI      3.14159

temp = cos(0);          //  1             1
temp = cos(PI/2);      // -1            0
temp = cos(PI);         //  1            -1
temp = cos(3*PI/2);  //  0              0
temp = cos(2*PI);     //  1              1

/****************************************************************************/

the second column of numbers is the results I should see ... the first column is the actual results.

I also stepped through the following code:

/****************************************************************************/

 double temp = 0;
 float i;

 for (i = 0; i < 2*PI; i+=0.1)
  temp = cos(i);

/****************************************************************************/

                RESULTS:

i                                      temp

0                                     1.0

0.1                                 -1.0

0.2 up to 1.6                  -1.0

1.7                                   1.0

 

I DON'T UNDERSTAND THESE RESULTS ............  PLEASE HELP

  • Scott,

    I just tried in my computer and got the correct results.

    What processor are you using?

     

  • Scott,

    I've helped a couple customers in the past resolve issues related to getting inaccurate results from various RTS trig functions.  Note that pretty much all of these functions rely upon some kind of "seed table" for calculating the value.  If that seed table gets messed up then you will get inaccurate results.  In the case of one customer the table was being corrupted by a stray pointer.  Another customer had incorrectly allocated the .far section to be in flash, so when the cinit routine tried to initialize that table it was unable to write the appropriate values into flash.

    Just to give you a further idea of what I'm talking about, here are some more specifics from a case regarding one of my customers who was using 6713 and having issues with the asin function.  First, looking in asin.c of the rts source code I found this table:

    asin.c said:
            static _DATA_ACCESS  REAL asin_consts[12] = /* max of 55 mantissa bits*/
              {KNST( 3.20113401984953224E-02),
               KNST(-1.63844362782365558E-02),
               KNST( 1.96423966100052853E-02),
               KNST( 6.48085538386000953E-03),
               KNST( 1.21816790811969532E-02),
               KNST( 1.38830278305348564E-02),
               KNST( 1.73599699654365820E-02),
               KNST( 2.23717366032023795E-02),
               KNST( 3.03819602714948831E-02),
               KNST( 4.46428567912157295E-02),
               KNST( 7.50000000040485847E-02),
               KNST( 1.66666666666648389E-01)};
     

    Since the table consists of 12 double-precision numbers that corresponds to 96 bytes of data (0x60 bytes).  In that customer's map file I found the following entry:

    map file said:
    .far       0    9001d080    000001bc     UNINITIALIZED
                      9001d080    000000c2     dither2.obj (.far)
                      9001d144    0000008c     rts6700.lib : exit.obj (.far)
                      9001d1d0    00000060                 : asin.obj (.far)
                      9001d230    00000008                 : _lock.obj (.far)
                      9001d238    00000004                 : errno.obj (.far)

    As you can see above the 0x60 bytes of data from asin.obj was being assigned to address 0x9001d1d0 which was clearly not writeable.  I would open a watch window to the corresponding address to see that the table is intact after you get the inaccurate results.

    One other possibility that might make a difference is to make sure you are including the appropriate math.h header file.  I've seen a couple cases due to implicitly declared functions where things have gotten screwed up.

    Brad

     

     

  • I just thought of one other possibility.  You didn't mention what device you're using, but if you're using C6747 or OMAP-L137 you should be aware that there was a codegen bug that affected the RTS library.  That bug was fixed beginning in 6.1.8.

    Brad

  • I am using the C6747 ... actually using the OMAP-L137 but only coding the C6747 right now.  I am very new to this environment so could you please give me a fairly detailed approach to fixing this.

    Oh btw, I re-ran my program this morning and I am getting numbers out that seem right ... so I am somewhat hesitant to make any changes ... but I guess if it needs to be fixed ... it needs it.

    Thanks for the reply.

    S

  • What version of the code generation tools are you running?  You can check your codegen version by going to Help -> About.

  • Code Gen Version: v6.1.5

  • Brad ...

    Thanks for your help ... I am dropping this message just because I am still trying to find the update for the CGTool.  When I click on the "Check for Updates" it takes me to a page that asks me if I want to register my product (which I have already done ... and if I click on it the questions come up with my responses already in it).  Below the register icon it says "Your configuration is up-to-date".  Which we both know it is not.

    The registered product on this page is "CCStudio V3.3-based Driverless Image"

    I'll continue to look for the update on the TI website.

    S

  • I recommend submitting a ticket to our DSP support group to clear up your licensing issue:

    http://www-k.ext.ti.com/sc/technical-support/email-tech-support.asp?DSP

     

  • Scott,

    Do you have the Code Composer Studio That comes with the Starter kit or do you have the full version?

  • Mariana said:

    Scott,

    Do you have the Code Composer Studio That comes with the Starter kit or do you have the full version?

    Is it possible to upgrade to CG Tools 6.1.8 without the full version?  I am having similar problems and am also running CG Tools 6.1.5 with the OMAP137 EVM using the version of CCS that comes with the EVM.

     

  • I'm not positive, but i dont think you can update your codegen with that version.  Now might be a good time to switch to CCS4:

    http://tiexpressdsp.com/index.php?title=Category:Code_Composer_Studio_v4

    It ships with 6.1.9 and is fully updateable.

  • Ryan,

    It is possible to update if you could get to update advisor to get the package. But without the full version you can not get to the update advisor. The next software package for OMAP-L137 will have the CGT 6.1.9. You will be able to update (the DSK version of CCS) when it comes out without needing to get to the update advisor.

  • Mariana said:

    Ryan,

    It is possible to update if you could get to update advisor to get the package. But without the full version you can not get to the update advisor. The next software package for OMAP-L137 will have the CGT 6.1.9. You will be able to update (the DSK version of CCS) when it comes out without needing to get to the update advisor.

    Thank you for the quick replies.

    Could you provide any estimate on when the next software package for the OMAP-L137 will be released? 

    Also, in a previous reply, Brad suggested that switching to CCS4 would also be a viable option.  I'm assuming that switching to CCS4 requires purchasing a full version of CCS rather than being able to upgrade our EVM version to CCS4, correct?

  • I'm not sure when the GA will be ready, but it should not take long (not more than 2 weeks I guess - probably less than that).

    CCSv4 is in Beta release and can be downloaded at:

    http://tiexpressdsp.com/index.php?title=Category:Code_Composer_Studio_v4

    for CCSv4 questions, please use the CCS forum:

    http://community.ti.com/forums/138.aspx

     

  • Mariana said:
    I'm not sure when the GA will be ready, but it should not take long (not more than 2 weeks I guess - probably less than that).

    It looks like GA was released to the web today. Visit http://www.ti.com/myregisteredsoftware

  • Just wanted to give an update on this, the software was already released with 6.1.9 for a while, but now you can get the latest CGT at the link:

    https://www-a.ti.com/downloads/sds_support/TICodegenerationTools/download.htm

    Even if you just have the EVM version of CCS. You just need a ti.com ID.