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.

uint64_t variable shifts received value by 32 bits

Part Number: LP-EM-CC1354P10
Other Parts Discussed in Thread: CC1354P10, SYSBIOS

Tool/software:

Hi,

I have on my code a typedef struct as follows:

/* Typedef Struct definition */
typedef struct {
    uint32_t timestamp;
    uint64_t status;
    float data[32];
    uint32_t packet_id;
    int8_t  rssi;
} dataPoint_t;

I assign a value to the status variable, for example:

dataPoint_t dataPoint;
dataPoint.status = 15;

Then the variable show to be receiving the value shifted 32 bits to the left, when I print it it shows 64424509440 instead.

Why does this happen, and how can I get the correct value?

Thank in advance,
Eduardo.

  • For the source file that contains the code where ...

    I assign a value to the status variable

    ... please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • Hi George,

    I tried to follow the instructions from the article but I'm using CCS 20.0.2 and could not find the option to only compile the .c file. Could you please provide instructions on how to perform it?

    Thank you.

    Regards,
    Eduardo.

  • I apologize.  The article is not updated to work with CCSv20.  

    Right click on the name of the problem source file.  Choose Properties.  Changing the preprocessor settings is close to the same.  It is not possible to build just one file. Instead, build the whole project.  Because the .o file produced for the problem source file is not an object file, the link fails.  Ignore that failure.  To undo these changes, right click on the problem source file and choose Revert Overridden Build-Settings.  

    Thanks and regards,

    -George

  • Hi George,

    I changed the preprocessor settings by selecting the "Pre-process source file, keep comments (-C)" option, there is no option "Continue compilation after using -pp" so I did no check anything else. But then the compilation fails with message "tiarmclang: error: invalid argument '-C' only allowed with '-E'".

    If I compile the code with both -C and -E options, this is the output:

    I don't see any generated file to submit, what do I need to do?

    Thank you.

    Regards,
    Eduardo.

  • With a clang based compiler like tiarmclang, the correct preprocessing options are -E -C.  This changes the automatically created .o file from an object file to a text file that contains the preprocessing output.  That's why the link fails.  This .o file is the one to submit to TI.  The rest of the directions in How to Submit a Compiler Test Case are correct, even for CCSv20.

    Thanks and regards,

    -George

  • Hi  George,

    I enabled the -E and -C options. After compiling the project, I went to "Release" path and here is the .o from the corresponding source file that has the error:

    payload-manager.o.txt

    Compiler version: cgt_tiarmclang_3.2.2.LTS

    Build options:
    [51]Building file: "../application/oee_tasks/payload-manager/payload-manager.c"
    [52]Invoking: Arm Compiler
    [53]"/home/oee_dev-002/ti/ti_cgt_tiarmclang_3.2.2.LTS/bin/tiarmclang" -c @"/home/oee_dev-002/workspace_gen2_wisun/OEE_minimal_device_coap_oad_offchip_src_LP_EM_CC1354P10_1_tirtos7_ticlang/application/defines/router.opts"  -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -mlittle-endian -Oz -flto -I"/home/oee_dev-002/workspace_gen2_wisun/OEE_minimal_device_coap_oad_offchip_src_LP_EM_CC1354P10_1_tirtos7_ticlang" -I"/home/oee_dev-002/workspace_gen2_wisun/OEE_minimal_device_coap_oad_offchip_src_LP_EM_CC1354P10_1_tirtos7_ticlang/Release" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/common/cc26xx/flash_interface" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/low_level/cc13xx/combo" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/ti-rf-driver/ti-rf-driver" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/apps/udp_nanostack_mesh_tirf" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/apps/coap_oad_nanostack_tirf" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/apps/common/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/common/nv" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_config/ws_router" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/ti-rf-driver/source" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/mbednanostack2tirtos" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/mbednanostack2tirtos/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/mbedtls2tirtos" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/mbedtls2tirtos/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/mbed_port/mbedtls2tirtos/mbedtls/mbed-crypto" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/nanostack-libservice/mbed-client-libservice" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/nanostack-libservice" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/nanostack-libservice/mbed-client-libservice/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-client-randlib/mbed-client-randlib/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-client-randlib/mbed-client-randlib" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-client-randlib" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-trace" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-coap" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/frameworks/mbed-coap/source/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/nanostack" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns/fnet" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns/fnet/fnet_stack" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns/fnet/fnet_stack/stack" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns/fnet/fnet_stack/services/serial" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Core/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/6LoWPAN" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack-eventloop" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack-eventloop/nanostack-event-loop" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack-eventloop/nanostack-event-loop/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/nanostack-hal-mbed-cmsis-rtos" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/mbed-mesh-api/source/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/mbed-mesh-api/mbed-mesh-api" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/mbed-mesh-api" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/coap-service/coap-service" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/coap-service/source/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/ti_wisunfan/mbedtls" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/ti_wisunfan/mbedtls/platform/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/ti_wisunfan/mbedtls/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/ti_wisunfan/mbedtls/platform/COMPONENT_PSA_SRV_IMPL/COMPONENT_NSPE" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/shell" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/config" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/uip" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/uip/conf" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/uip/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/uip/pltfrm/sysbios" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/uip/net" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/services" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/hal/assert" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/hal/appasrt" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/hal/crypto" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/hal/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/hal/rf" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/high_level" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/low_level" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/osal_port" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/boards" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/util" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/stack/src" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/stack/tirtos/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/common/heapmgr" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/services/saddr" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/services/sdata" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/fh" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/rom" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/inc/cc13xx" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/low_level/cc13xx" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/wisunfan_mac/tracer" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/mbed-mesh-api/source" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/6LoWPAN/Thread" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Security/PANA" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/mdns/fnet/fnet_stack/services/mdns" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/fnv_hash" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/hmac" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/load_balance" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/libNET/src" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack-eventloop/source" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/ti_wisunfan/mbedtls/platform/COMPONENT_PSA_SRV_IMPL" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/whiteboard" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/6LoWPAN/ws" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/DHCPv6_client" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/libDHCPv6" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/utils" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Service_Libs/pan_blacklist" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/third_party/mbed/nanostack/sal-stack-nanostack/source/Common_Protocols" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/posix/ticlang" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/config" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/include" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/src" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/src/core" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/src/core/utils" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/examples/platforms" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/examples/ncp_ftd" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/examples/ncp_ftd/platform" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/src/core/thread" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/src/ncp" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/ti_wisunfan/ncp_interface/examples/ncp_ftd/platform/nv" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/devices/cc13x4_cc26x4" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/devices/cc13x4_cc26x4/driverlib" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source/ti/devices/cc13x4_cc26x4/inc" -I"/home/oee_dev-002/ti/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/kernel/tirtos7/packages" -DCOAP_SERVICE_ENABLE -DxCOAP_PANID_LIST -DCOAP_OAD_ENABLE -DEXCLUDE_TRACE -DxSWITCH_NCP_TO_TRACE -DTLS_SEC_PROT_LIB_USE_MBEDTLS_PLATFORM_MEMORY -DxWISUN_AUTO_START -DTI_WISUN_FAN_DEBUG -DDeviceFamily_CC13X4 -gdwarf-3 -C -E -fdiagnostics-show-option -fshort-enums -munaligned-access -funsigned-char -fcommon -ffunction-sections -fno-strict-aliasing -include mbed_config.h -I"/home/oee_dev-002/workspace_gen2_wisun/OEE_minimal_device_coap_oad_offchip_src_LP_EM_CC1354P10_1_tirtos7_ticlang/Release/syscfg"  @"syscfg/ti_utils_build_compiler.opt"  -o"application/oee_tasks/payload-manager/payload-manager.o" "../application/oee_tasks/payload-manager/payload-manager.c"
    [54]Finished building: "../application/oee_tasks/payload-manager/payload-manager.c"

    Please let me know if you need any other informations. Thank you.

    Regards,
    Eduardo.

  • Thank you for the test case.  I used it to build the test case down to assembly source.  Here is a small part of that assembly.

    	ldr	r7, .LCPI4_1
    	ldr.w	r8, .LCPI4_2
    	ldr	r5, .LCPI4_3		@ r5 = &dataPoint
    	ldr	r6, .LCPI4_4
    	mov.w	r9, #0			@ r9:r10 = 15
    	mov.w	r10, #15
    	movs	r4, #19
    .Ltmp44:
    .LBB4_4:
    	ldrb	r0, [r7]
    .Ltmp45:
    	cbz	r0, .LBB4_6
    .Ltmp46:
    	bl	get_send_interval
    .Ltmp47:
    	bl	get_seconds2wait
    .Ltmp48:
    	bl	sleep
    .Ltmp49:
    	mov	r0, r8
    	bl	oeeDebug
    .Ltmp50:
    	bl	get_current_timestamp
    .Ltmp51:
    	str	r0, [r5]
    	ldr.w	r0, [r5, #144]
    	strd	r10, r9, [r5, #8]	@ dataPoint.status = 15
    

    This roughly corresponds to this part of the C code ...

                sleep(get_seconds2wait(get_send_interval()));
                // sleep(10); //debug
    
                oeeDebug("Creating dataPoint");
                /* Create dataPoint */
                dataPoint.timestamp = get_current_timestamp();
                dataPoint.status = /*lib_status_get_curr_value()*/ (uint64_t)15;

    In the assembly, I added the @ comments.  Notice how the register pair r9:r10 is loaded with the constant 15.  This pair is stored to [r5, #8] by the last instruction.  Notice how several functions are called (the bl instructions) in between those instructions.  This works because the tiarmclang register conventions require those functions, and all the functions they call, to preserve those registers.  Is it possible that one of those functions, or one function they call, is implemented in assembly, and that assembly fails to preserve both r9 and r10?

    Thanks and regards,

    -George

  • Hi George,

    Sorry for the late reply.

    The functions get_seconds2wait(), get_send_interval() and oeeDebug() are not implemented in assembly. The sleep() function is from the TI's SimpleLink SDK 8.30.01.01.

    The get_current_timestamp() function is no implemented in assembly either, here is its implementation:

    uint32_t get_current_timestamp() {
    Timestamp_get64(&ts);
    uint64_t ticks = ((uint64_t)ts.hi << 32) | ts.lo;
    time_t current_time_ms = (time_t)((ticks * 1000ULL) / freq.lo);
    return (min_device_data.boot_timestamp + (current_time_ms / 1000));
    }

    Timestamp_get64 function is used from TI's labrary too.

    I hope this can be useful. Please let me know if you need more information.

    Best regards,
    Eduardo.

  • Hi George,

    By any chance could it be an optimization from the compiler? This is the configuration:

    I'm using as base the WI-SUN CoAP node as example and modified it to my project, in case it helps.

    Best regards,
    Eduardo.

  • Hi Eduardo,

    thank you for all the debug effort.
    I will follow up with the team and update this thread as soon as we have some more insight.

    Kind regards,
    Theo

  • Hi Theo,

    Do you get the correct rssi value if you instead set its type value to be int32_t, in the dataPoint_t structure?

    Regards,

    Arthur

  • Hi Arthur,

    I changed the rssi type from int8_t to int32_t and then I did dataPoint.rssi = 50 and yes, I do get the correct value.

    Regards,
    Eduardo.

  • Hi Eduardo,

    great to hear that this solved your issue.

    Kind regards,
    Theo

  • Hi Theo,

    Actually this did not solve my issue. The problem here is related to uint64_t type, in this case dataPoint.status variable.

    I thought Arthur was just asking me to test something for him.

    Regards,
    Eduardo.

  • Hi Eduardo,

    So, is the problem still occuring with status when replacing rssi with the uint32_t type? I want to check if the memory alignement could be causing the issue.

    Regards,

    Arthur 

  • Hi Arthur,

    Yes, the problem still persists even when replacing rssi to int32_t. I can get the rssi value correctly, but the status value is shifted 32 bits, e.g.: setting dataPoint.status = (uint64_t)50 the value reported when I read it is 214748364800.

    Best regards,
    Eduardo.

  • Hi,

    I did a few more tests that I'd like to share with you.

    I implemented a stack to share data between two different tasks. These are the payload-manager header and source files that I use to collect and save data:

    /* payload-manager.h */ 
    
    #ifndef PAYLOAD_MANAGER_H
    #define PAYLOAD_MANAGER_H
    
    /* Define declaration */
    #include "hal_types.h"
    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    #include <ti/drivers/dpl/SemaphoreP.h>
    
    // #include "network-interface.h"
    // #include "nvs-datapoint.h"
    
    #define PAYLOAD_MANAGER_TASK_PRIORITY  5
    #define PAYLOAD_MANAGER_STACK_SIZE     2048
    #define STACK_CAPACITY 3
    
    /* Typedef Struct definition */
    typedef struct {
        uint32_t timestamp;
        uint64_t status;
        float data[32];
        uint32_t packet_id;
        uint16_t battery;
        int32_t rssi;
    } dataPoint_t;
    
    typedef struct {
        dataPoint_t buffer[STACK_CAPACITY];
        int top;     // próximo slot livre
        int count;   // quantos elementos estão salvos
        // Mutex de proteção de acesso
        SemaphoreP_Struct mutex;
        SemaphoreP_Handle mutexHandle;
        // Semáforo de contagem para controle de dados disponíveis
        SemaphoreP_Struct countSem;
        SemaphoreP_Handle countSemHandle;
    } dataStack_t;
    
    void *payloadManagerThread(void *arg0);
    
    /* 
     * Functions prototypes
     */
    /* Queue Data Stack */
    bool dataStack_pop(dataPoint_t *outData);
    void dataStack_push(dataPoint_t *newData);
    
    extern dataStack_t dataStack;
    
    #endif /* PAYLOAD_MANAGER_H */

  • payload-manager.c:

    /* payload-manager.c */
    #include "payload-manager.h"
    /* Extern variables used to CoAP communication with border router */
    extern volatile bool connectedFlg;
    extern uint8_t max_rssi_in;
    /* Local variables */
    char thing_alias[12];
    dataPoint_t dataPoint = {.packet_id = 0};
    dataStack_t dataStack;
    
    void dataStack_init(void) {
        SemaphoreP_Params semParams;
        SemaphoreP_Params_init(&semParams);
        semParams.mode = SemaphoreP_Mode_BINARY;
        dataStack.mutexHandle = SemaphoreP_construct(&dataStack.mutex, 1, &semParams);
        SemaphoreP_Params_init(&semParams);
        semParams.mode = SemaphoreP_Mode_COUNTING;
        dataStack.countSemHandle = SemaphoreP_construct(&dataStack.countSem, 0, &semParams);
        dataStack.top = 0;
        dataStack.count = 0;
    }
    void dataStack_push(dataPoint_t *newData) {
        SemaphoreP_pend(dataStack.mutexHandle, SemaphoreP_WAIT_FOREVER);
        if (dataStack.count == STACK_CAPACITY) {
            memmove(&dataStack.buffer[0], &dataStack.buffer[1], sizeof(dataPoint_t) * (STACK_CAPACITY - 1));
            dataStack.top = STACK_CAPACITY - 1;
            dataStack.count = STACK_CAPACITY - 1;
        }
        oeeDebug("DEBUG PUSH 0: %lld", newData->status);
        memcpy(&dataStack.buffer[dataStack.top], newData, sizeof(dataPoint_t));
        oeeDebug("DEBUG PUSH 1: %lld", dataStack.buffer[dataStack.top].status);
        dataStack.top++;
        dataStack.count++;
        SemaphoreP_post(dataStack.mutexHandle);
        SemaphoreP_post(dataStack.countSemHandle);
    }
    bool dataStack_pop(dataPoint_t *outData) {
        SemaphoreP_pend(dataStack.countSemHandle, SemaphoreP_WAIT_FOREVER);
        SemaphoreP_pend(dataStack.mutexHandle, SemaphoreP_WAIT_FOREVER);
        if (dataStack.count == 0) {
            SemaphoreP_post(dataStack.mutexHandle);
            return false;
        }
        dataStack.top--;
        dataStack.count--;
        oeeDebug("DEBUG POP 0: %lld", dataStack.buffer[dataStack.top].status);
        memcpy(outData, &dataStack.buffer[dataStack.top], sizeof(dataPoint_t));
        SemaphoreP_post(dataStack.mutexHandle);
        return true;
    }
    
    void *payloadManagerThread(void *arg0) {
        dataStack_init();
        while (1) {
            if(connectedFlg) {
                sleep(10);
                oeeDebug("Creating dataPoint");
                dataPoint.status = /*lib_status_get_curr_value()*/51;
                if (connectedFlg) {
                    dataStack_push(&dataPoint);
                }
            }
        }
        return NULL;
    }

    I needed to remove some lines to be able to paste the code here but everything related to the issue was maintained.

  • This is the comm-manager.c code that uses the pop function defined that I expect to receive the correct status variable:

    /* comm-manager.c */
    void *commManagerThread(void *arg0) {
        dataPoint_t data;
    // some code runs here before...
                if (dataStack_pop(&data)) {
                    oeeDebug("Status read at comm-manager: %lld", data.status);
                    //do something
                }
    // code continues...
    }

    The "oeeDebug(...)" function is simply a print to UART function that I can use to output data and debug.

    With this code running, this is what I get as result:

    Creating dataPoint
    DEBUG PUSH 0: 51
    DEBUG PUSH 1: 51
    DEBUG POP 0: 223338299391

    As you can see the dataStack_push function seems to be working fine, be when I try to read the exact same value with dataStack_pop it prints the value shifted 32 bits to the left.

    I have noticed something else: if I use dataStack_pop inside payload-manager.c, the value is correctly read. So for some reason I'm facing this issue when I try to read the value from another .c code, but I don't know exactly why.

    I hope this information can provide any idea on how to solve this issue, I don't know what's going on here.

    Thank you in advance.
    Best regards,
    Eduardo.

  • Hi,

    I noticed that if I create a dataPoint_t variable inside comm-manager.c file the problem also occurs, so it does not seem to be a problem with the push/pop functions.

    Inside commManagerThread, I created:

    dataPoint_t test_data;
    test_data.status = 66;

    And I can see same behavior , as printed data is shown with value 283467841536.

    Regards,
    Eduardo.