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/AWR1843BOOST: Questions with the definition of the Struct type

Part Number: AWR1843BOOST

Tool/software: Code Composer Studio

Hi,

  In the DSP core, I have defined the Structure type as belows:

typedef struct MmwDemo_DSS_DataPathObj_t
{
 
       float invOneQFormat; 
      uint16_t minRange; 
      uint16_t maxRange;
      float velResolution;


      MmwDemo_detectedObjActual detObj2D[100];

     ...

}

The type MmwDemo_detectedObjActual is defined as follows:

typedef struct MmwDemo_detectedObjActual_t
{
    uint16_t   rangeIdx;            /*!< @brief Range index */
    uint16_t   dopplerIdx;          /*!< @brief Doppler index */
    uint16_t   range;               /*!< @brief Range (meters in oneQformat) */
    int16_t    speed;               /*!< @brief Doppler (m/s in oneQformat) */
    int16_t    sinAzim;             /*!< @brief wx  sin(Azim).  Q format provides the bitwidth. */
    uint16_t   peakVal;             /*!< @brief Peak value */

    uint16_t   rangeSNRdB;          /*!< @brief Range SNR (dB)  */
    uint16_t   dopplerSNRdB;        /*!< @brief Doppler SNR (dB) */
    uint16_t   sinAzimSNRLin;       /*!< @brief omega SNR (linear scale) */
    uint16_t   sinElevSNRLin;       /*!< @brief omega SNR (linear scale) */

    int16_t  x;             /*!< @brief x - coordinate in meters. Q format provides the bitwidth. */
    int16_t  y;             /*!< @brief y - coordinate in meters. Q format provides the bitwidth. */
    int16_t  z;             /*!< @brief z - coordinate in meters. Q format provides the bitwidth. */

}MmwDemo_detectedObjActual;

If I define the  type MmwDemo_DSS_DataPathObj_t as above, the value of the variable invOneQFormat will be changed in the program  excution,that is to say, if I set the value of invOneQFormat=0.005, when the proggram is  excuted for a while, the value of invOneQFormat  is channed into an very small value,.But if I defined the MmwDemo_DSS_DataPathObj_t as follwing:

typedef struct MmwDemo_DSS_DataPathObj_t
{
 
       float invOneQFormat; 
      uint16_t minRange; 
      uint16_t maxRange;

      MmwDemo_detectedObjActual detObj2D[100];
      float velResolution;

     ...

}

This problem will be solved.The value of the variable invOneQFormat will not be changed. What is the reason for that? The difference of this two definition is  the number of the bytes before the declaration MmwDemo_detectedObjActual detObj2D[100]; ,the first one is 12,and the second one  is 8.  I have tried that if the byte number is 4,  the variable invOneQFormat value will be unchanged too.Can  anyone tell me the reason for that?

Thanks,

Regards,

Rata

  • Hello Rata,

    Please check if there is any padding to struct variables to make it all aligned by the compiler.

     You may need to re-arrange the variables in the structure to make it 4 or 8 bytes aligned.

    Regards,

    Jitendra

  • Hi Jitendra,

       How should I check the padding to struct variable?You said 'You may need to re-arrange the variables in the structure to make it 4 or 8 bytes aligned.', why should I do that and how should I do that in the DSP core? Is there any reference for  making the structure  4 or 8 bytes aligned? Can you provide me any reference for that?

    Thanks,

    Regards,

    Rata

  • Hello Rata,

    Try to rebuild the CCS project with no-optimization to check if in that case also you see above behavior.

    Ideally in the code alignment can be achieved by below reference code

    /* radar cube data */
    #pragma DATA_SECTION(testRadarCube, ".l3ram");
    #pragma DATA_ALIGN(testRadarCube,DPC_OBJDET_RADAR_CUBE_DATABUF_BYTE_ALIGNMENT);
    cmplx16ImRe_t testRadarCube[TEST_MAX_RADAR_CUBE_SIZE]; //msb is real, lsb 16 is imag

    Regards,

    Jitendra

  • Nothing can be said from the information you have provided of what is the root-cause of the problem, which you will need to find out. There is nothing wrong per se in the definitions of the structures you have quoted.