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/EK-TM4C1294XL: Added Visual Studio Code not working in Code Composer Studio ZNP_HOST_FRAMEWORK cmdLine Project

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: CC2538

Tool/software: Code Composer Studio

Hello!

I am using the ZNP-HOST_FRAMEWORK project "cmdLine" with the TM4C1294XL, CCEM Booster Pack and the CC2538. I am trying to add some code I previously wrote in Visual Studios (in C++) to this project. I have verified that my code works in Visual Studio. I'm not getting any errors or warnings about my new code in the Code Composer Studio project "cmdLine". However, my code isn't working properly in Code Composer Studio. Basically, the code I wrote performs trilateration using pre-defined values (NOT values obtained from the microcontroller. I want to make sure it works with theoretical values first before using real-time values from the microcontroller). My code uses variable types "double" and "int", and I noticed the Code Composer Studio Code uses mainly "uintX_t" and "intX_t", where X is 8, 16, 32, or 64.

I'm not sure why my code isn't working in Code Composer Studio, but I'm suspecting it may be because Code Composer Studio doesn't recognize the data type "double"? How is the double data interpreted? Do I need to convert the data to another format? I should mention that I'm using RSSI values, so there are negatives and decimal values that I need to keep--I cannot truncate or round the numbers. Could something else be the issue?

I've attached the modified file "cmdLine.cpp", which consists of all of my code. In this file I've made it clear as to what lines I've added by writing my name in the variable name and the comments.

Thank you!

- Tessa 

cmdLine.c

  • Hello Tessa,

    Tessa Herzberger said:
    However, my code isn't working properly in Code Composer Studio.

    Can you explain a bit more regarding this? It sounds like the code compiles fine but when you run your application, it does not execute as expected? 

    Thanks

    ki

  • Hello, Ki!

    It compiles and builds fine, but when I run the program, it doesn't execute as I expected. For example, I should be getting about 8.5, and I'm getting 1,000,000.

    - Tessa

  • Thank you for the clarification. This does not appear to be a tools question. I will move this thread to the device forum. The experts there may be able to provide some more suggestions.

    Thanks

    ki

  • Hello, Ki!

    That sounds good! I will wait for a reply from someone else.

    Thank you!

    - Tessa

  • Hi,

      I have no idea what the cmdLine.c is about? It is the first time I'm seeing this file. Not sure if I'm able to give any help. What is the target device you are running this code on? Is it the TM4C129 or the CC2538?

      First of all, if you are running the code on the TM4C129 then bear in mind that the M4F processor only support single-precision floating point. See below excerpt. 

    — 32-bit instructions for single-precision (C float) data-processing operations.
    — Combined Multiply and Accumulate instructions for increased precision (Fused MAC).
    — Hardware support for conversion, addition, subtraction, multiplication with optional accumulate,
    division, and square-root.
    — Hardware support for denormals and all IEEE rounding modes.
    — 32 dedicated 32-bit single-precision registers, also addressable as 16 double-word registers.
    — Decoupled three stage pipeline.

    Secondly, make sure you enable the hardware floating point unit.

  • Hello, Charles!

    I'm using the cmdLine.cpp file from the ZNP_HOST_FRAMEWORK ( https://www.ti.com/tool/TIDC-ZNP-HOST-SW3 )  Code Composer Studio project cmdLine. I'm currently running the code on an TM4C1294XL. I should mention I do have a booster pack connected to the TM4C1294 board with a CC2538.

    Precision to one decimal point is fine. It looks like my options are set up the same as yours. I've attached a picture just in case. I'm still not getting even close to the same results as I was getting in Visual Studio when I run this same code. Do you think this could be an issue with the double to int32_t or double to uint32_t conversions? I should mention that I'm implementing code with negative numbers. I'm not sure if negative numbers could change anything (like maybe it's using twos compliment or something? Or do you think this issue could be something else?

    Thank you!

    - Tessa 

  • Hi,

    For debugging this issue, instead of running the full fledged project (the one you've tested in VS), I would running a subset of that functionality.

    Tessa Herzberger said:
    I'm not sure why my code isn't working in Code Composer Studio, but I'm suspecting it may be because Code Composer Studio doesn't recognize the data type "double"? How is the double data interpreted?


    If you suspect that the data is being interpreted incorrectly on the TM4C, try to see which data is being interpreted incorrectly.
    For example, it may be helpful to print out various values of different types (uintx_t, double, float...) and see if there is a discrepancy between VS and TM4C.

    Regards,
    Toby

  • Hello, Toby!

    I accidentally hit the resolved button! Sorry! Please ignore that. I will let you know when my problem is resolved. I'm currently printing many outputs.

    As an example, on the TM4C1294XL board, I'm getting:

    unknown_node_locations[0]: 0x4020DB96
    unknown_node_locations[1]: 0x4021FDE7
    unknown_node_locations[2]: 0xBFE371F0

    In Visual Studios I'm getting the correct answers, which are:

    UNKNOWN NODE LOCATION = 8.42889, 8.99591, -0.607658

    Thank you!

    - Tessa

  • Hello again, Toby!

    I tried using different variables all with the value of 5.5 or -5.5 to see the results. I've attached a picture of the results. The Tessa_test_*variable type* values are using 5.5, and the Tessa_test_*variable type*_negative values are using -5.5 

    Thank you!

    - Tessa

  • Hi,

      Can you show your test code how you print out the above values? Please note that the floating values are stored in the computer memory using the IEEE-754 representation. Here is one online tool that converts the floating value to its IEEE-754 format stored in the memory.

    https://www.h-schmidt.net/FloatConverter/IEEE754.html

      You can also watch the variable in the CCS under the Expression Window. Here I create a float variable called f_SP_Temperature2 and I assign a value of -5.5 to it. In the Expression window I see 0xC0B00000 stored in the memory which is the same as the online tool. 

  • Hi,

      Can you show your test code how you print out the above values? Please note that the floating values are stored in the computer memory using the IEEE-754 representation. Here is one online tool that converts the floating value to its IEEE-754 format stored in the memory.

    https://www.h-schmidt.net/FloatConverter/IEEE754.html

      You can also watch the variable in the CCS under the Expression Window. Here I create a float variable called f_SP_Temperature2 and I assign a value of -5.5 to it. In the Expression window I see 0xC0B00000 stored in the memory which is the same as the online tool. 

  • Hello, Charles!

    Here's my code. For these variables, all I did was initialize them, then print them. I've attached a pdf file of my code and results. I've also attached my code (cmdLine.c). I looked at the floating point numbers. Using the converter you suggested, I get 2.515625 and -2.515625 for the float variables 8.5 and -8.5 values respectively, which still isn't right.

    Thanks!

    - Tessa

    8078.cmdLine.c

    Init_Printing_Results.pdf

  • Hello again, Charles!

    I should probably mention that I'm using the ZNP_HOST_FRAMEWORK ( https://www.ti.com/tool/TIDC-ZNP-HOST-SW3 ) example Code Composer Studio project "cmdLine", and that I am simply adding my own code to this project.

    Thanks!

    - Tessa

  • Hi,

      I use your code like below. When I compile I will see the below five warnings. You should see the same. There is incompatibility during format string conversion. Note I use printf.

    When I run the code, I can produce the same outputs as you. But when you compare to what is stored in the memory they are different. As explained, I think the reason is the format string conversion. If you look at the Expression windows for the variable tessa_test_float, it is correctly stored in the memory as 0x41080000 and this is matching the online converter tool while it is printed out as 0x40210000 on the console. Again, what is most important is if it is stored in the memory correctly. I'm not sure why you must print them with the hex format of %02X for a floating value which results in the format string conversion incompatibility. You might want to try typecasting. Again, this is beyond the scope of the MCU. Why don't you just print it with something like %02f in which case you will see 8.5 or -8.5. 

  • Hello, Charles!

    I don't really need to print it to the terminal, I just wanted a way to verify that the results I was getting is correct. Using the information you provided me, I confirmed that my tessa_test variables are producing the right values in the Expression Window, but the printing is still wrong (again, I don't really need to print). I did notice however that the variables tessa_unknown_node_location and tessa_lqi_array are still set to their initial values (which are zero), even though they are printing values that are not zero.

    Thank you!

    - Tessa

  • That is not what I see when I use what you have. 

    I just added 

    float tessa_unknown_node_location[3] = { 0, 0, 0 }; //ADDED BY TESSA
    int32_t tessa_test_int32_t = 8.5;
    uint32_t tessa_test_uint32_t = 8.5;
    float tessa_test_float = 8.5;
    double tessa_test_double = 8.5;

    int32_t tessa_test_int32_t_negative = -8.5;
    uint32_t tessa_test_uint32_t_negative = -8.5;
    float tessa_test_float_negative = -8.5;
    double tessa_test_double_negative = -8.5;

    int
    main(void)
    {
    //
    // Run from the PLL at 120 MHz.
    //

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);

    printf("\t Tessa unknown_node_location[0]: 0x%02X\n", tessa_unknown_node_location[0]);
    printf("\t Tessa unknown_node_location[1]: 0x%02X\n", tessa_unknown_node_location[1]);
    printf("\t Tessa unknown_node_location[2]: 0x%02X\n", tessa_unknown_node_location[2]);
    printf("\t Tessa test int32: 0x%02X\n", tessa_test_int32_t);
    printf("\t Tessa test uint32: 0x%02X\n", tessa_test_uint32_t);
    printf("\t Tessa test float: 0x%02X\n", tessa_test_float);
    printf("\t Tessa test double: 0x%02X\n", tessa_test_double);

    printf("\t Tessa test int32 negative: 0x%02X\n", tessa_test_int32_t_negative);
    printf("\t Tessa test uint32 negative: 0x%02X\n", tessa_test_uint32_t_negative);
    printf("\t Tessa test float negative: 0x%02X\n", tessa_test_float_negative);
    printf("\t Tessa test double negative: 0x%02X\n", tessa_test_double_negative);

    And I see below. Try for yourself. One thing I will recommend is run your test code in a small project and not embed it in a 4000 lines file. This way it is easier to debug. 

  • Hello, Charles!

    I moved my tessa_unknown_node_location array and corresponding function call (trilateration) to a different function (from function "mtZdoMgmtLqiRspCb" to function "startNetwork") and it seems to be working fine now. However I'm still not able to save the the correct value in my LQI variable, tessa_lqi_array. I need to obtain this value from the function "mtZdoMgmtLqiRspCb", and save it to a global value in my variable "tessa_lqi_array". I'm not sure how to do this, or why it's not working.

    Thank you!

    - Tessa

  • Hi,

      You declare the variable with a int64_t. The MCU processor is a 32-bit machine. 64bit not supported. 

    int64_t tessa_lqi_array[4] = { 0, 0, 0, 0 }; //ADDED BY TESSA

      

  • Hello, Charles!

    I'm able to successfully obtain the LQI value now! Thank you! I'm still having some troubles though. When I'm converting the LQI value ("tessa_lqi_array" variable) to the corresponding RSSI value ("tessa_test_RSSI_conversion" variable) using the function convert_LQI_to_RSSI. I should mention that I am converting the "tessa_lqi_array" from an int32_t to a float, and that "tessa_test_RSSI_conversion" is a float. I've attached my code.8176.cmdLine.c

    Thank you!

    - Tessa

  • Hello Again, Charles!

    I just realized I didn't mention exactly what's happening in my code! Sorry! When I'm converting the LQI value ("tessa_lqi_array" variable) to the corresponding RSSI value ("tessa_test_RSSI_conversion" variable) using the function convert_LQI_to_RSSI, I'm not seeing the variable "tessa_test_RSSI_conversion" change at all in the Expressions Window. It's staying the same throughout the whole routine, even though I'm modifying it in my code.

    Thanks!

    - Tessa 

  • Why don't you single step in the convert_LQI_to_RSSI function. Does the rssi contain the right value?

    float convert_LQI_to_RSSI(float lqi)
    {
    float rssi = 0;

    rssi = (lqi * (ED_RF_POWER_MAX_DBM - ED_RF_POWER_MIN_DBM) / 255) + ED_RF_POWER_MIN_DBM;

    return rssi;
    }