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.

TMS320F28035: Global Static variable not coming in the Map File.

Part Number: TMS320F28035


Tool/software:

I am not able to print the Static Global Variable in the Map file. I am using linker option in the CSS IDE "--mapfile_contents=sym_defs" but still it is not adding the variables. I tried modifying the linker cmd file to add the section like .ebss > RAM and .bss > RAM but not luck. Please suggest me some linker option how to add variables in the Map file.

  • For the source file that defines one static variable which does not appear in the map file, please follow the directions in the article How to Submit a Compiler Test Case.  

    In addition, please rebuild the entire project. From the build log, capture the text of the linker command, and all the system response.  Do not use a screenshot.  Ignore the Problems view.  Paste that text into your next post.

    Thanks and regards,

    -George

  • Building target: "AmcFirmware.out"
    Invoking: C2000 Linker
    "C:/ti/ccs920/ccs/tools/compiler/ti-cgt-c2000_18.12.3.LTS/bin/cl2000" -v28 -ml -mt -O0 --opt_for_speed=5 --fp_mode=relaxed --fp_reassoc=off --define=BUILDCONFIG_DISABLE_WATCHDOG=1 --define=BUILDCONF_ENABLE_DEBUG_OUTPUTS=0 -g --c99 --diag_wrap=off --display_error_number --abi=coffabi --asm_define=GLOBAL_Q=16 -z -m"AmcFirmware.map" --stack_size=0x400 --warn_sections --reread_libs --disable_auto_rts --diag_wrap=off --display_error_number --mapfile_contents=sym_defs --xml_link_info="AmcFirmware_linkInfo.xml" --symbol_map=main=new_main --rom_model -o "AmcFirmware.out" "./Sources/AmcMain.obj"  "./Sources/System/Utilities.obj" "./Sources/System/Watchdog.obj" "../Target/Amc_F28035_lnk.cmd" "../Target/DSP2803x_Headers_nonBIOS.cmd"
    <Linking>
    Finished building target: "AmcFirmware.out"

  • /* Includes --------------------------------------------------------------------------------------------------- */
    /**
     * @file    TypeDefines.h
     *
     * @brief   Global data type definition
     *
     * Copyright &copy; 2020, maxon motor ag
     * All rights reserved.
     *
     */
    
    
    /* Includes --------------------------------------------------------------------------------------------------- */
    /*****************************************************************************/
    /* STDINT.H                                                                  */
    /*                                                                           */
    /* Copyright (c) 2002 Texas Instruments Incorporated                         */
    /* http://www.ti.com/                                                        */
    /*                                                                           */
    /*  Redistribution and  use in source  and binary forms, with  or without    */
    /*  modification,  are permitted provided  that the  following conditions    */
    /*  are met:                                                                 */
    /*                                                                           */
    /*     Redistributions  of source  code must  retain the  above copyright    */
    /*     notice, this list of conditions and the following disclaimer.         */
    /*                                                                           */
    /*     Redistributions in binary form  must reproduce the above copyright    */
    /*     notice, this  list of conditions  and the following  disclaimer in    */
    /*     the  documentation  and/or   other  materials  provided  with  the    */
    /*     distribution.                                                         */
    /*                                                                           */
    /*     Neither the  name of Texas Instruments Incorporated  nor the names    */
    /*     of its  contributors may  be used to  endorse or  promote products    */
    /*     derived  from   this  software  without   specific  prior  written    */
    /*     permission.                                                           */
    /*                                                                           */
    /*  THIS SOFTWARE  IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS    */
    /*  "AS IS"  AND ANY  EXPRESS OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT    */
    /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    */
    /*  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT    */
    /*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
    /*  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES  (INCLUDING, BUT  NOT    */
    /*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    */
    /*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    */
    /*  THEORY OF  LIABILITY, WHETHER IN CONTRACT, STRICT  LIABILITY, OR TORT    */
    /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    */
    /*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
    /*                                                                           */
    /*****************************************************************************/
    
    /*****************************************************************************/
    /* _STDINT40.H                                                               */
    /*                                                                           */
    /* Copyright (c) 2018 Texas Instruments Incorporated                         */
    /* http://www.ti.com/                                                        */
    /*                                                                           */
    /*  Redistribution and  use in source  and binary forms, with  or without    */
    /*  modification,  are permitted provided  that the  following conditions    */
    /*  are met:                                                                 */
    /*                                                                           */
    /*     Redistributions  of source  code must  retain the  above copyright    */
    /*     notice, this list of conditions and the following disclaimer.         */
    /*                                                                           */
    /*     Redistributions in binary form  must reproduce the above copyright    */
    /*     notice, this  list of conditions  and the following  disclaimer in    */
    /*     the  documentation  and/or   other  materials  provided  with  the    */
    /*     distribution.                                                         */
    /*                                                                           */
    /*     Neither the  name of Texas Instruments Incorporated  nor the names    */
    /*     of its  contributors may  be used to  endorse or  promote products    */
    /*     derived  from   this  software  without   specific  prior  written    */
    /*     permission.                                                           */
    /*                                                                           */
    /*  THIS SOFTWARE  IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS    */
    /*  "AS IS"  AND ANY  EXPRESS OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT    */
    /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    */
    /*  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT    */
    /*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
    /*  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES  (INCLUDING, BUT  NOT    */
    /*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    */
    /*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    */
    /*  THEORY OF  LIABILITY, WHETHER IN CONTRACT, STRICT  LIABILITY, OR TORT    */
    /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    */
    /*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
    /*                                                                           */
    /*****************************************************************************/
    
    
    /* 
       According to footnotes in the 1999 C standard, "C++ implementations
       should define these macros only when __STDC_LIMIT_MACROS is defined
       before <stdint.h> is included." 
    */
    
    
    /* 7.18.1.1 Exact-width integer types */
    
        typedef          int    int16_t;
        typedef unsigned int   uint16_t;
        typedef          long   int32_t;
        typedef unsigned long  uint32_t;
    
        typedef          long long  int64_t;
        typedef unsigned long long uint64_t;
    
    /* 7.18.1.2 Minimum-width integer types */
    
        typedef  int16_t  int_least8_t;
        typedef uint16_t uint_least8_t;
    
        typedef  int16_t  int_least16_t;
        typedef uint16_t uint_least16_t;
        typedef  int32_t  int_least32_t;
        typedef uint32_t uint_least32_t;
    
        typedef  int64_t  int_least64_t;
        typedef uint64_t uint_least64_t;
    
    /* 7.18.1.3 Fastest minimum-width integer types */
    
        typedef  int16_t  int_fast8_t;
        typedef uint16_t uint_fast8_t;
        typedef  int16_t  int_fast16_t;
        typedef uint16_t uint_fast16_t;
    
        typedef  int32_t  int_fast32_t;
        typedef uint32_t uint_fast32_t;
    
        typedef  int64_t  int_fast64_t;
        typedef uint64_t uint_fast64_t;
    
    /* 7.18.1.4 Integer types capable of holding object pointers */
        typedef          long intptr_t;
        typedef unsigned long uintptr_t;
    
    /* 7.18.1.5 Greatest-width integer types */
        typedef          long long intmax_t;
        typedef unsigned long long uintmax_t;
    
    /* 
       According to footnotes in the 1999 C standard, "C++ implementations
       should define these macros only when __STDC_LIMIT_MACROS is defined
       before <stdint.h> is included." 
    */
    
    /* 7.18.2 Limits of specified width integer types */
    
    
    
    
    
    
    
    
    
    
    
    
    
    /* 7.18.3 Limits of other integer types */
    
    
    
    
    
    
    
    /* 7.18.4.1 Macros for minimum-width integer constants */
    
    /*
       There is a defect report filed against the C99 standard concerning how 
       the (U)INTN_C macros should be implemented.  Please refer to --
       http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_209.htm 
       for more information.  These macros are implemented according to the
       suggestion given at this web site.
    */
    
    
    
    /* 7.18.4.2 Macros for greatest-width integer constants */
    
    
    /*****************************************************************************/
    /* stddef.h                                                                  */
    /*                                                                           */
    /* Copyright (c) 1993 Texas Instruments Incorporated                         */
    /* http://www.ti.com/                                                        */
    /*                                                                           */
    /*  Redistribution and  use in source  and binary forms, with  or without    */
    /*  modification,  are permitted provided  that the  following conditions    */
    /*  are met:                                                                 */
    /*                                                                           */
    /*     Redistributions  of source  code must  retain the  above copyright    */
    /*     notice, this list of conditions and the following disclaimer.         */
    /*                                                                           */
    /*     Redistributions in binary form  must reproduce the above copyright    */
    /*     notice, this  list of conditions  and the following  disclaimer in    */
    /*     the  documentation  and/or   other  materials  provided  with  the    */
    /*     distribution.                                                         */
    /*                                                                           */
    /*     Neither the  name of Texas Instruments Incorporated  nor the names    */
    /*     of its  contributors may  be used to  endorse or  promote products    */
    /*     derived  from   this  software  without   specific  prior  written    */
    /*     permission.                                                           */
    /*                                                                           */
    /*  THIS SOFTWARE  IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS    */
    /*  "AS IS"  AND ANY  EXPRESS OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT    */
    /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    */
    /*  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT    */
    /*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
    /*  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES  (INCLUDING, BUT  NOT    */
    /*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    */
    /*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    */
    /*  THEORY OF  LIABILITY, WHETHER IN CONTRACT, STRICT  LIABILITY, OR TORT    */
    /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    */
    /*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
    /*                                                                           */
    /*****************************************************************************/
    
    
    /*****************************************************************************/
    /* _ti_config.h                                                              */
    /*                                                                           */
    /* Copyright (c) 2017 Texas Instruments Incorporated                         */
    /* http://www.ti.com/                                                        */
    /*                                                                           */
    /*  Redistribution and  use in source  and binary forms, with  or without    */
    /*  modification,  are permitted provided  that the  following conditions    */
    /*  are met:                                                                 */
    /*                                                                           */
    /*     Redistributions  of source  code must  retain the  above copyright    */
    /*     notice, this list of conditions and the following disclaimer.         */
    /*                                                                           */
    /*     Redistributions in binary form  must reproduce the above copyright    */
    /*     notice, this  list of conditions  and the following  disclaimer in    */
    /*     the  documentation  and/or   other  materials  provided  with  the    */
    /*     distribution.                                                         */
    /*                                                                           */
    /*     Neither the  name of Texas Instruments Incorporated  nor the names    */
    /*     of its  contributors may  be used to  endorse or  promote products    */
    /*     derived  from   this  software  without   specific  prior  written    */
    /*     permission.                                                           */
    /*                                                                           */
    /*  THIS SOFTWARE  IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS    */
    /*  "AS IS"  AND ANY  EXPRESS OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT    */
    /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    */
    /*  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT    */
    /*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
    /*  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES  (INCLUDING, BUT  NOT    */
    /*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    */
    /*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    */
    /*  THEORY OF  LIABILITY, WHETHER IN CONTRACT, STRICT  LIABILITY, OR TORT    */
    /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    */
    /*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
    /*                                                                           */
    /*****************************************************************************/
    
    
    #pragma diag_push
    #pragma CHECK_MISRA("-19.4")
    #pragma CHECK_MISRA("-19.1")
    
    /* Common definitions */
    
    /* C */
     /* C89/C99 */
    
    
    
    
    
    /* _TI_NOEXCEPT_CPP14 is defined to noexcept only when compiling for C++14. It
       is intended to be used for functions like abort and atexit that are supposed
       to be declared noexcept only in C++14 mode. */
    
    /* Target-specific definitions */
    /*****************************************************************************/
    /* linkage.h                                                                  */
    /*                                                                           */
    /* Copyright (c) 1998 Texas Instruments Incorporated                         */
    /* http://www.ti.com/                                                        */
    /*                                                                           */
    /*  Redistribution and  use in source  and binary forms, with  or without    */
    /*  modification,  are permitted provided  that the  following conditions    */
    /*  are met:                                                                 */
    /*                                                                           */
    /*     Redistributions  of source  code must  retain the  above copyright    */
    /*     notice, this list of conditions and the following disclaimer.         */
    /*                                                                           */
    /*     Redistributions in binary form  must reproduce the above copyright    */
    /*     notice, this  list of conditions  and the following  disclaimer in    */
    /*     the  documentation  and/or   other  materials  provided  with  the    */
    /*     distribution.                                                         */
    /*                                                                           */
    /*     Neither the  name of Texas Instruments Incorporated  nor the names    */
    /*     of its  contributors may  be used to  endorse or  promote products    */
    /*     derived  from   this  software  without   specific  prior  written    */
    /*     permission.                                                           */
    /*                                                                           */
    /*  THIS SOFTWARE  IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS    */
    /*  "AS IS"  AND ANY  EXPRESS OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT    */
    /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    */
    /*  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT    */
    /*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
    /*  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES  (INCLUDING, BUT  NOT    */
    /*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    */
    /*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    */
    /*  THEORY OF  LIABILITY, WHETHER IN CONTRACT, STRICT  LIABILITY, OR TORT    */
    /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    */
    /*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     */
    /*                                                                           */
    /*****************************************************************************/
    
    
    #pragma diag_push
    #pragma CHECK_MISRA("-19.4") /* macros required for implementation */
    
    /* No modifiers needed to access code */
    
    
    /*--------------------------------------------------------------------------*/
    /* Define _DATA_ACCESS ==> how to access RTS global or static data          */
    /*--------------------------------------------------------------------------*/
    
    /*--------------------------------------------------------------------------*/
    /* Define _OPTIMIZE_FOR_SPACE ==> Always optimize for space.                */
    /*--------------------------------------------------------------------------*/
    
    /*--------------------------------------------------------------------------*/
    /* Define _IDECL ==> how inline functions are declared                      */
    /*--------------------------------------------------------------------------*/
    
    #pragma diag_pop
    
    
    #pragma diag_pop
    
    
    #pragma diag_push
    #pragma CHECK_MISRA("-19.7") /* macros required for implementation */
    #pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
    #pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
    
    
    
    typedef long ptrdiff_t;
    
    
    typedef unsigned long size_t;
    
    
    typedef unsigned int wchar_t;
    
    
    /*----------------------------------------------------------------------------*/
    /* C++11 and C11 required max_align_t to be defined. The libc++ cstddef       */
    /* header expects the macro __DEFINED_max_align_t to be defined if it is to   */
    /* use the definintion of max_align_t from stddef.h. Only define it if        */
    /* compiling for C11 or we're in non strict ansi mode.                        */
    /*----------------------------------------------------------------------------*/
    typedef long double max_align_t;
    
    #pragma diag_push
    #pragma CHECK_MISRA("-19.10") /* need types as macro arguments */
    
    
    #pragma diag_pop
    
    
    #pragma diag_pop
    
    /*
     * Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
     * All rights reserved.
     *
     * Copyright (c) 2014-2014 Texas Instruments Incorporated
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     * SUCH DAMAGE.
     *
     * $FreeBSD: release/10.0.0/include/stdbool.h 228878 2011-12-25 20:15:41Z ed $
     */
    
    
    
    
    
    
    /* Exported defines & macros ---------------------------------------------------------------------------------- */
    
    /* Exported types --------------------------------------------------------------------------------------------- */
    typedef _Bool   bool_t;
    typedef long    fixed16_t;
    typedef fixed16_t triple_fixed16_t[3U];
    typedef uint16_t  triple_uint16_t[3U];
    
    typedef struct
    {
        uint32_t a:8;
        uint32_t b:8;
        uint32_t c:8;
    } triple_8_bit_field_t;
    
    typedef union
    {
        uint32_t dword;
        triple_8_bit_field_t fields;
    } triplicated_8_bit_field_t;
    
    typedef struct
    {
        fixed16_t d;
        fixed16_t q;
    } vector_dq_t;
    
    typedef struct
    {
        fixed16_t alpha;
        fixed16_t beta;
    } vector_albe_t;
    
    typedef struct
    {
        fixed16_t a;
        fixed16_t b;
        fixed16_t c;
    } vector_abc_t;
    
    typedef struct
    {
        fixed16_t cosx;
        fixed16_t sinx;
    } vector_sincos_t;
    
    typedef struct
    {
        uint16_t phase_a;
        uint16_t phase_b;
        uint16_t phase_c;
    } vector_pwm_t;
    
    //lint -esym(9018,*can_message_frame_t*) suppress 'declaration of symbol X with union base type X'
    //Justification: we accept the usage of selected unions as portability is not required
    typedef union
    {
        uint32_t dword[2];
        uint64_t qword;
    } can_message_frame_t;
    
    typedef enum
    {
        OBJECT_READ,
        OBJECT_WRITE
    } object_access_t;
    
    typedef struct
    {
        fixed16_t lower;
        fixed16_t upper;
    } object_limits_fixed16_t;
    
    /**
     * Fault bits.
     * Make sure to keep the order as specified in DIRS as the order in the bitfield will be used to generate the fault code!
     */
    typedef struct
    {
        //lint --e{46} suppress 'field type should be _Bool, unsigned int or signed int'
        //Justification: we accept the usage of uint32_t bitfields as they are proven to work with the given compiler and portability is not required
        uint32_t driver:1;                              /**< Bit  0: DRIVER_FLT */
        uint32_t exception_flt:1;                       /**< Bit  1: EXCEPTION_FLT */
        uint32_t valve_sensor_unreal_pos_step_flt:1;    /**< Bit  2: VAL_POS_SENS_UNREAL_POS_STEP_FLT */
        uint32_t critical_internal_sw_flt:1;            /**< Bit  3: CRITICAL_INTERNAL_SW_FLT */
        uint32_t valve_sensor_out_of_range_flt:1;       /**< Bit  4: VAL_POS_OOR_FLT */
        uint32_t valve_sensor_data_invalid:1;           /**< Bit  5: POS_SENS_DATA_INVALID_FLT */
        uint32_t motor_unresponsive:1;                  /**< Bit  6: UNRESPON_MTR_FLT */
        uint32_t can_bus_off_error:1;                   /**< Bit  7: CAN_BUS_OFF_FLT */
        uint32_t can_passive_error:1;                   /**< Bit  8: CAN_PASSIVE_ERROR_FLT */
        uint32_t motor_uncommanded:1;                   /**< Bit  9: UNCOMM_MTR_FLT */
        uint32_t motor_misdirection:1;                  /**< Bit 10: MTR_MISDIR_FLT */
        uint32_t motor_sensor_data_invalid:1;           /**< Bit 11: MTR_POS_ILLEGAL_ENC_FB_FLT */
        uint32_t motor_sensor_under_voltage:1;          /**< Bit 12: MTR_POS_LOSS_ENC_EXC_VOLT_FLT */
        uint32_t ram_flt:1;                             /**< Bit 13: RAM_FLT */
        uint32_t motor_power_flt:1;                     /**< Bit 14: MTR_PWR_FLT */
        uint32_t pos_sens_health_flt:1;                 /**< Bit 15: POS_SENS_HEALTH_FLT */
        uint32_t over_current_flt:1;                    /**< Bit 16: OVER_CURRENT_FLT */
        uint32_t vpower_over_voltage:1;                 /**< Bit 17: PS_28V_OVER_VOLT_FLT */
        uint32_t vpower_under_voltage:1;                /**< Bit 18: PS_28V_UNDER_VOLT_FLT */
        uint32_t power_valid_flt:1;                     /**< Bit 19: PWR_FLT */
        uint32_t vdd_power_supply:1;                    /**< Bit 20: PS_5V_FLT */
        uint32_t overrun_flt:1;                         /**< Bit 21: OVERRUN_BIT_FLT */
        uint32_t prgm_checksum_bit_flt:1;               /**< Bit 22: PRGM_CHECKSUM_BIT_FLT */
        uint32_t mtr_over_current_flt:1;                /**< Bit 23: MTR_OVER_CURRENT_FLT */
        uint32_t watchdog_flt:1;                        /**< Bit 24: WD_FAULT */
        uint32_t critical:1;                            /**< Bit 25: AMC_CRITICAL_FAULT */
        uint32_t non_critical:1;                        /**< Bit 26: AMC_NON_CRITICAL_FAULT */
        uint32_t cpu:1;                                 /**< Bit 27: CPU_FAULT */
        uint32_t critical_or_cpu:1;                     /**< Bit 28: AMC_FAULT */
        uint32_t watchdog_reset:1;                      /**< Bit 29: WD_RESET_FAULT */
        uint32_t padding:2;                             /**< Bit 30 & 31: unused bits*/                   //lint -esym(768, fault_bits_t::padding) suppress 'local struct member '____' not referenced, Justification: padding are only used for padding'
    } fault_bits_t;
    
    typedef enum
    {
        AMC1 = 1,
        AMC2 = 2
    } valve_location_t;
    
    typedef enum
    {
        WATCHDOG_PWR_BOOT     = 0x0U,             /* default pattern, will not be written*/
        WATCHDOG_PRE_TRIGGER  = 0x8BADF00DU,      /* pattern to detect premature triggering */
        WATCHDOG_TEST_TRIP    = 0xDEADBEEFU,      /* pattern to detect correct self test trip */
        WATCHDOG_EVENT_TRIP   = 0xDABBAD00U       /* pattern to detect real watchdog trip event */
    } watchdog_trip_reason_t;
    
    typedef enum
    {
        WATCHDOG_NOT_FORCED       = 0x0U,
        WATCHDOG_STACK_OVERFLOW   = 0x8BADF00DU,
        WATCHDOG_ILLEGAL_INSTR    = 0xDEADBEEFU,
        WATCHDOG_DIV_BY_ZERO      = 0xDABBAD00U,
        WATCHDOG_DIV_NEG_OVERFLOW = 0xFACEFEEDU,
        WATCHDOG_DIV_POS_OVERFLOW = 0xFEEDC0DEU,
        WATCHDOG_CAN_INIT_FAULT   = 0xDEADBABEU,
        WATCHDOG_PLL_FAULT        = 0xDEAFBABAU,
        WATCHDOG_SEU              = 0xD0D0CACAU,
        WATCHDOG_OVERRUN          = 0xABAD1DEAU
    } watchdog_force_reason_t;
    
    /* Exported variables ----------------------------------------------------------------------------------------- */
    
    
    /* Exported functions prototypes ------------------------------------------------------------------------------ */
    
    
    /**
     * @file    CyclicChecks.h
     *
     * @brief   Cyclic checks module interface
     *
     * Copyright &copy; 2020, maxon motor ag
     * All rights reserved.
     *
     */
    
    
    /* Includes --------------------------------------------------------------------------------------------------- */
    /* Exported defines & macros ---------------------------------------------------------------------------------- */
    /* Exported types --------------------------------------------------------------------------------------------- */
    /* Exported variables ----------------------------------------------------------------------------------------- */
    /* Exported functions prototypes ------------------------------------------------------------------------------ */
    void cyclic_checks_init_module(void);
    void cyclic_checks_motion_control(void);
    void cyclic_checks_commutation(void);
    void cyclic_checks_background(void);
    
    
    
    /* Internal variables ----------------------------------------------------------------------------------------- */
    static const fixed16_t  cyclic_checks_current_threshold                       =   262144L;  /* The value represents 4[A²] which corresponds to the square of the threshold of 2[A] * 2^16,  2[A] is equivalent to 1638 counts */
    static const fixed16_t  cyclic_checks_current_peak_threshold                  =  1048576L;  /* The value represents 16[A²] which corresponds to the square of the threshold of 4[A] * 2^16, 4[A] is equivalent to 1229 counts */
    static const fixed16_t  cyclic_checks_phase_current_lower_threshold           =  -536084L;  /* -536084 = -8.18[A] * 2^16, -8.18[A] is equivalent to 3723 counts */
    static const fixed16_t  cyclic_checks_phase_current_upper_threshold           =   536084L;  /*  536084 =  8.18[A] * 2^16,  8.18[A] is equivalent to 373 counts */
    static const uint16_t   cyclic_checks_vdd_lower_threshold                     =     2792U;  /* The value of 2792 is equal to 4.5V */
    static const fixed16_t  cyclic_checks_vdd_ext_lower_threshold                 =   294912L;  /* 4.5V * 2^16 */
    static const fixed16_t  cyclic_checks_misdirection_dem_speed_lower_threshold  =  -2237000L;  /*   -2'237'000 [inc/Ts] => -500 [rpm]*/
    static const fixed16_t  cyclic_checks_misdirection_dem_speed_upper_threshold  =   2237000L;  /*   +2'237'000 [inc/Ts] => +500 [rpm]*/
    static const fixed16_t  cyclic_checks_misdirection_act_speed_threshold        =        0L;  /*          0 [inc/Ts] =>    0 [rpm] */
    static const fixed16_t  cyclic_checks_unresponsive_velocity                   = 13422000L;  /* 13'422'000 [inc/Ts] => 3000 [rpm]  */
    static const fixed16_t  cyclic_checks_unresponsive_threshold                  =   447400L;  /*    447'400 [inc/Ts] =>  100 [rpm] */
    static const fixed16_t  cyclic_checks_undervoltage_limit                      =   917504L;  /* Undervoltage limit for driver current fault suppression 14V * 2^16 = 917504 */
    
    static const uint16_t cyclic_checks_motor_current_threshold = 500U;
    static const uint16_t cyclic_checks_motor_peak_current_threshold = 10U;
    static const uint16_t cyclic_checks_motor_power_threshold = 200U;
    static const uint16_t cyclic_checks_can_passive_filter_threshold = 250U;
    static const uint16_t cyclic_checks_vdd_power_supply_filter_threshold = 500U;
    static const uint16_t cyclic_checks_valve_sensor_data_invalid_threshold = 50U;
    static const uint16_t cyclic_checks_valve_sensor_out_of_range_threshold = 100U;
    static const uint16_t cyclic_checks_power_valid_state_filter_threshold = 500U;
    static const uint16_t cyclic_checks_vdd_ext_filter_threshold = 250U;
    static const uint16_t cyclic_checks_motor_unresponsive_filter_threshold = 10U;
    static const uint16_t cyclic_checks_speed_misdirection_filter_threshold = 10U;
    static const uint16_t cyclic_checks_motor_sensor_healthy_filter_threshold = 250U;
    */
    
    static bool_t cyclic_checks_drv_fault_reminder = 0;
    
    static volatile fault_handler_recoverable_faults_t cyclic_check_recoverable_faults_report[3U];
    static volatile fault_handler_bgnd_faults_t        cyclic_checks_background_faults_report[3U];
    
    
     /* Initializes module
     */
    void cyclic_checks_init_module(void)
    {
        /* Nothing to do here, but function required to meet design pattern. */
        return
    }
    

  • Thank you for the test case.  It defines several static variables that are never referenced in that file.  Because they are static, it is impossible for another file to reference these variables.  These variables are optimized away before linking.  The linker never sees them.  

    Consider this small example.

    C:\examples>type example.c
    const static int not_used = 10;
    
    C:\examples>cl2000 --keep_asm example.c
    "example.c", line 1: warning: variable "not_used" was declared but never referenced
    
    C:\examples>findstr not_used example.asm
    <no system response>

    The first command shows the source file.  The second command builds it.  The option --keep_asm says to keep the compiler generated assembly file.  The third command searches the assembly file for the variable name not_used.  It isn't there, because it was optimized away.

    The same thing happens with your static variables.

    Thanks and regards,

    -George

  • Hi George, I have deleted most of the function calls from the Preprocessed file. Those static variables are referenced within in the file. I just wanted to ask what are the ways to make those static variable come in the map file. 

  • Because the static variables are const qualified similar to ...

    const static int static_variable = 100;

    ... the compiler optimizes them out.  As a build only experiment, pick one of these variables, remove const, and add code that updates the variable in a non-trivial way.  Does it show up the map file?

    Thanks and regards,

    -George

  • Hi, there is no issue for the variable declared with const keyword. Issue happens only if variable declared as static. I tried removing static by keeping constant. It does shows in the map file. Once again if I put back the static keyword it is removing the map file.

  • Suppose you write something similar to ...

    /* not const */ static int static_variable = 100;

    and there is code in the file which reads and writes static_variable in a non-trivial way.  In such case, the compiler does not optimize static_variable away.  Therefore, static_variable appears in the map file.  Please confirm this is your experience.

    Thanks and regards,

    -George

  • Hi George, can we connect over call once.? Let me know the possible way to connect with you.

    I am ok with Teams, Google Meet, Zoom. 

  • Answering to your question I am trying these options while compiling and printing map file.

    Original Variable declared in code file is "static const fixed16_t  cyclic_checks_current_threshold = 262144L;"

    Option #1

    I removed static keyword from the variable and compiled. It shows this variable in map file.

    const fixed16_t  cyclic_checks_current_threshold = 262144L;

    Option # 2

    I removed both static and const keyword from the variable and compiled. It shows this variable in map file.

    fixed16_t  cyclic_checks_current_threshold = 262144L;

    Option # 3

    I put back the static keyword to the variable and compiled. It does not show up in map file.

    static fixed16_t  cyclic_checks_current_threshold = 262144L;

     

    I am using below compiler options in the build process. Please suggest if anything I need to remove from compiler option and need to add in compiler option that will not optimize the global static variable to come in the map file.

    Building file: "../Sources/BuiltInTest/CyclicChecks.c"
    Invoking: C2000 Compiler
    "C:/ti/ccs920/ccs/tools/compiler/ti-cgt-c2000_18.12.3.LTS/bin/cl2000" -v28 -ml -mt -O0 --opt_for_speed=5 --fp_mode=relaxed --fp_reassoc=off --include_path="C:/Users/H307052/4GD_CPCS/4GD_CPCS_NC/Code" --define=BUILDCONFIG_DISABLE_WATCHDOG=1 --define=BUILDCONF_ENABLE_DEBUG_OUTPUTS=0 -g --c99 --diag_wrap=off --display_error_number --abi=coffabi --asm_define=GLOBAL_Q=16 --preproc_with_compile --preproc_dependency="Sources/BuiltInTest/CyclicChecks.d_raw" --obj_directory="Sources/BuiltInTest" "../Sources/BuiltInTest/CyclicChecks.c"
    Finished building: "../Sources/BuiltInTest/CyclicChecks.c"

  • I strongly suspect, for each case, the reason the static variable does not appear in the map file is that it is optimized away.  Here is a way to verify my guess.  Go back to my second post in this thread.  Notice how I use the compiler option --keep_asm, and then search the assembly code for the name of the variable of interest.  Please perform that analysis for every case where the static variable is not in the map file.  

    Please understand that this optimization related to static variables occurs early in compiler processing.  There is no way to disable it.

    Thanks and regards,

    -George