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.

Code composer - unsigned int value and unsigned char displayed incorrectly

Other Parts Discussed in Thread: MSP430F5438

 

Code composer incorrectly displays unsigned int and unsigned char.  When an unsigned int is > 0x7FFF the value displayed is negative and it should be positive.  Ditto for unsigned char.  When unsigned char is > 0x7F, the value displayed is negative and it should be positive.

Obviously, you can display the value as hex, however, your constantly using your calculator (maybe 10 to 20 times a day) to convert it to decimal if that's what you need to see.  Just not right when there is a giant calculator, a PC, in front of you.  The display of char and int is correct. Maybe also be the same for long and unsigned long.

TI, help please...

Also reported a problem with long. see.
http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/56096/206329.aspx

 

  • Hi Peter,

    which window (i.e. watch window) gives you the incorrect reading? Maybe you can post a screenshot of it.

    When right-clicking a variable (i.e. in Watch window) one can select the display format of it.

    Rgds
    aBUGSworstnightmare

  • Ok.  Here is an example.  Click on it for a full-screen view.  External to the code on the screen the following is also declared.
    typedef unsigned char       uchar;
    typedef unsigned short int  uint;

    And which right-click Format option displays the value correctly?  I don't know.

    TI, help please...

  • Hi Peter,

    did you make the screenshot after downloading and the stepping into you program or did you make it after a RESET?

    There are a few things which were looking stange indeed:

    1.) your declaring a variable i of type uint; from your typedef uint = unsigned short int --> so, pls tell me which (dezimal) range your expecting from this declaration. If you want to have an unsigned 32-bit value change it to unsigned long.

    2.) pls tell me the meaning of U in: i = 50000U;

    3.) Shouldn't State3 be zero (as with State2)?

    Rgds
    aBUGSworstnightmare

    P.S. Which MSP430 are you using? Do you use -v mspx silicon version (check Project properties-->compiler-->basic options)?

  • aBUGSworstnightmare said:
    2.) pls tell me the meaning of U in: i = 50000U;

    "50000" will be considered by the compiler as a signed long int value. The "U" tell the compiler to treat it as an unsigned short int. This makes a difference when resolving a formula. Without the U, the intermediate result will be expanded to long and the calculatiosn are done with long. While the result is usually the same (one can construct some cases where it won't, depending on shifts and sign extensions etc.), the generated code will be longer without the 'U' and slower.

  •  

    Wrote a test program using unsigned int and unsigned char instead of the using the typedef uchar and typedef uint.  It works fine.  So that's a simple workaround - major auto search and replace across 35k lines project.  It still should work using the typedef but don't care if the workaround is easy and good.  If that was the only prob i'd be happy as.

    Case closed.


  • Wrote a test program using unsigned int and unsigned char instead of the using the typedef uchar and typedef uint.  It works fine.  So that's a simple workaround - major auto search and replace across 35k lines project.  It still should work using the typedef and in time fixed but don't care if the workaround is easy and good.  If that was the only prob i'd be happy as.

    Another person explained the U suffix.  Using MSP430F5438 and yes using the mspx option.

    Case closed.

  • Cool.  Fixed in version 4.1.3

**Attention** This is a public forum