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.

MCU-PLUS-SDK-AM243X: CCS shows misleading variable-values

Part Number: MCU-PLUS-SDK-AM243X

Hello,

after some hours of debugging I noticed CCS sometimes shows wrong values for a symbol. In my current case I have an uint8_t readStatus[2] = {0}; -array. This array always shows 0, even if it's in fact not since a check for [0] == 0x02 is done later on and that returns true. If I check the variable in CCS via hovering it just says "Debug Information" for every field.
I am using CCS 12.2 and LTS 2.1.3 as compiler. The Code part is a member-function of a C++-class.

Compiler-flags used are:

-Wno-gnu-variable-sized-type-not-at-end
-mcpu=cortex-r5
-mfloat-abi=hard
-mfpu=vfpv3-d16
-Wno-error=ti-macros
-Wno-unused-function
-Wno-invalid-command-line-argument
-fno-rtti
-ffunction-sections
-fdata-sections
-flto
-mno-unaligned-access
-Wall
-Wextra
-Og
-g

linker options:

-Wl,--reread_libs
-Wl,--ram_model
-Wl,--diag_suppress=10063
-Wl,-e_vectors

This is what CCS shows:

And the code in question:


You see a SUCCESS. This is only possible if the [0] field is 0x02 in our case.

Can this be fixed? Do I need to set other flags as well?

Best regards

Felix

  • Hi Felix,

    There are several reasons may cause the incorrect variable value display in CCS:

    1. The release build. It may be caused by the code optimization resulted by the release build. Use Debug build instead.

    2. The cache behavior. If the code/data/stack are in OCRAM, then the contents of variables may be still in cache, while the CCS displays the OCRAM contents. Put "volatile" before your variable declaration.

    Best regards,

    Ming

  • Hey Ming,

    it's a Debug-build. then it's probably the cache-behaviour. But it's misleading. The variable is available in a register it seems, at least to the assembly. I did not check further. At least some hint would be nice in CCS like "variable probably not correct due to caching" or smth like this.

    The volatile-option I also use often to debug or __attribute__((optnone)) for functions but mostly when the compiler starts to optimize variables out and they are not available (here CCS shows a good hint: "variable may be optimized out"). Since CCS did show the array I thought ok: it's not optimized out and the value is valid.

    It's a bit hard to debug if you cannot rely to the shown values of the variables.

    This is only a suggestion but it took me a bit to check that my array contains valid values ;)

    Best regards

    Felix

  • Hi Felix,

    I understood your frustration. I will forward this request to the CCS team for further help. 

    One thing you can try to avoid the issue caused by caching, you can change the MPU for OCRAM to "Non Cached":

    But you will need to change it back to "Cached" after you complete the debugging for performance purpose.

    Best regards,

    Ming