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.

AWRL1432BOOST: Add CAN bus function issue to Kick_to_Open examples code

Part Number: AWRL1432BOOST

Tool/software:

We refer to the examples code radar_toolbox_2_10_00_04-Kick_to_Open

Added MMWAVE_L_SDK_05_05_00_02 - drivers\mcan\mcan_external_read_write

But it seems that the performance is insufficient and it cannot work properly! Do you have any other suggestions or references?

  • Johnny,

    Can you please share details on what performance issues you are seeing? Are you getting any error messages you can share with us?

    I am looping in our CAN expert. 

    Thanks,

    Angie

  • This is an extension of the following discussion!

    https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/1376054/awrl6432boost-mcan-function-is-affected/5362589?tisearch=e2e-sitesearch&keymatch=%2525252520user%252525253A601140#5362589

    Currently using AWRL1432 and using the Kick_to_Open project, add Can bus function, and use polling method to send and receive Can bus, but we found that the processing time is too long and affects kick detection.

    The following is a code snippet :

    ===== gesture_recognition.c =====

    /*
    * Copyright (C) 2024 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    * Limited License.  
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, 
    * non-exclusive license under copyrights and patents it now or hereafter 
    * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
    * this software subject to the terms herein.  With respect to the foregoing patent 
    * license, such license is granted  solely to the extent that any such patent is necessary 
    * to Utilize the software alone.  The patent license shall not apply to any combinations which 
    * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license (including the 
    * above copyright notice and the disclaimer and (if applicable) source code license limitations below) 
    * in the documentation and/or other materials provided with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided that the following
    * conditions are met:
    *
    *	* No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any 
    *     software provided in binary form.
    *	* any redistribution and use are licensed by TI for use only with TI Devices.
    *	* Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the source code are permitted 
    * provided that the following conditions are met:
    *
    *   * any redistribution and use of the source code, including any resulting derivative works, are licensed by 
    *     TI for use only with TI Devices.
    *   * any redistribution and use of any object code compiled from the source code and any resulting derivative 
    *     works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or 
    * promote products derived from this software without specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "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 TI AND TI'S LICENSORS 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.
    */
    
    /**************************************************************************
     *************************** Include Files ********************************
     **************************************************************************/
    
    /* Standard Include Files. */
    #include <stdint.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <string.h>
    #include <stdio.h>
    #include <math.h>
    #include <assert.h>
    
    /* MCU Plus Include Files. */
    #include <kernel/dpl/SemaphoreP.h>
    #include <kernel/dpl/CacheP.h>
    #include <kernel/dpl/ClockP.h>
    #include <kernel/dpl/DebugP.h>
    #include <kernel/dpl/HwiP.h>
    #include <kernel/dpl/AddrTranslateP.h>
    #include <kernel/dpl/HeapP.h>
    
    #include "FreeRTOS.h"
    #include "task.h"
    
    /* mmwave SDK files */
    #include <datapath/dpedma/v0/dpedmahwa.h>
    #include <datapath/dpedma/v0/dpedma.h>
    #include <datapath/dpu/rangeproc/v0/rangeprochwa.h>
    #include <datapath/dpu/rangeproc/v0/rangeprochwa_internal.h>
    #include <datapath/dpu/dopplerproc/v0/dopplerprochwa.h>
    #include <datapath/dpu/aoaproc/v0/aoaprochwa.h>
    
    #include <control/mmwave/mmwave.h>
    #include <drivers/edma.h>
    #include <drivers/uart.h>
    #include <drivers/i2c.h>
    #include <drivers/soc.h>
    
    #include <utils/mathutils/mathutils.h>
    #include "mmw_cli.h"
    
    #include "mmw_res.h"
    #include "gesture_recognition.h"
    #include "mmw_flash.h"
    
    
    #include "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    
    // RPMF
    #include <FreeRTOS.h>
    #include <task.h>
    #include <semphr.h>
    #include "drivers/power.h"
    #include <mmwavelink/include/rl_device.h>
    #include <mmwavelink/include/rl_sensor.h>
    #include <drivers/prcm.h>
    #include <drivers/hw_include/cslr_soc.h>
    #include <board/ina.h>
    
    #include <drivers/hw_include/cslr.h>
    #include <drivers/hw_include/hw_types.h>
    
    #include "classifier_prepost_proc.h"
    
    extern int32_t CLI_readLine(UART_Handle uartHandle, char *lineBuf, uint32_t bufSize);
    extern void classifier_pre_proc();
    extern void classifier_post_proc();
    
    FILE *detMatData;
    FILE *featExtractOutput;
    FILE *probOutput;
    #define SAVE_BIN_FILES 0
    
    #define MMWDEMO_RFPARSER_SPEED_OF_LIGHT_IN_METERS_PER_SEC (3e8)
    #define EDMA_TEST_EVT_QUEUE_NO      (0U)
    #define MAX_NUM_TX_ANTENNA          (2U)
    #define MAX_NUM_RX_ANTENNA          (3U)
    #define MAX_NUM_RANGEBIN            (64U)
    #define MAX_NUM_ADCSAMPLE_PERCHIRP  (128U)
    #define MAX_NUM_CHIRPS_PERFRAME     (128U)
    #define DPC_OBJDET_DPIF_RADARCUBE_FORMAT_6 6
    #define DPC_DPU_DPIF_DETMATRIX_FORMAT_1 1
    #define DPC_OBJDET_HWA_RANGE_WINDOW_RAM_OFFSET 0
    #define DPC_OBJDET_HWA_DOPPLER_WINDOW_RAM_OFFSET 128
    #define DPC_OBJDET_HWA_VECTOR_RAM_OFFSET 0
    #define DPC_DPU_RANGEPROC_FFT_WINDOW_TYPE MATHUTILS_WIN_HANNING
    #define DPC_DPU_DOPPLERPROC_FFT_WINDOW_TYPE MATHUTILS_WIN_HANNING
    #define DPC_OBJDET_QFORMAT_RANGE_FFT 17
    #define DPC_OBJDET_QFORMAT_DOPPLER_FFT 17
    #define MMW_DEMO_TEST_ADC_BUFF_SIZE 1024  //maximum 128 real samples (int16_t), 3 Rx channels
    #define READ_LINE_BUFSIZE   256
    
    #define NUM_ELEVATION_ELEMENTS 2
    #define NUM_AZIMUTH_ELEMENTS 3
    
    #define FRAME_REF_TIMER_CLOCK_MHZ  40
    
    #define RF_SYNTH_TRIM_VALID          (1U)
    
    #define MAX_NUM_POINTS_MAJOR_MOTION 10 // We have to keep it to the right numbers for hand gesture which uses 35ms frame periodicity
    #define MAX_NUM_POINTS_MINOR_MOTION 4 // We have to keep it to the right numbers for hand gesture which uses 35ms frame periodicity
    
    /* Calibration Data Save/Restore defines */
    #define MMWDEMO_CALIB_STORE_MAGIC            (0x7CB28DF9U)
    
    /* Flags to make sure the switch happens properly between minor/major */
    volatile bool flagMinorToMajorDopp=0;
    volatile bool flagMinorToMajorAoA=0;
    volatile bool flagMajorToMinorDopp=0;
    volatile bool flagMajorToMinorAoA=0;
    
    uint8_t gATECalibDataStorage[(ATE_CALIB_DATA_LENGTH + 4)] __attribute__((aligned(8))) = {0};
    MmwDemo_calibData gFactoryCalibDataStorage __attribute__((aligned(8))) = {0};
    
    /* Variable to hold Silicon version (PG)*/
    uint8_t                 pgVersion;
    uint8_t                 rxData[16];
    uint8_t                 txData[16];
    I2C_Transaction         i2cTransaction;
    
    
    MmwDemo_MSS_MCB gMmwMssMCB = {0};
    
    /* Handle to be used for feature extraction */
    void *featExtractHandle;
    
    /* Handle to be used for ANN classifier */
    void *algClassifierHandle;
    
    /*! @brief     EDMA interrupt objects for DPUs */
    Edma_IntrObject     intrObj_rangeProc[2], intrObj_aoaProc, intrObj_dopplerProc, intrObj_cfarProc;
    
    HwiP_Object gHwiChirpAvailableHwiObject;
    HwiP_Object gHwiFrameStartHwiObject;
    //Interrupt object for Sensor Stop
    HwiP_Object gHwiSensorStopHwiObject;
    
    volatile uint32_t gMmwDemoChirpCnt = 0;
    volatile uint32_t gMmwDemoFrameCnt = 0;
    volatile uint32_t gMmwDemoFrameCntGesture = 1;
    volatile uint32_t gMmwDemoFrameCntPresence = 0;
    
    volatile uint8_t flagPresenceDetect = 0;
    volatile uint8_t flagGestureDetect = 0;
    volatile uint8_t sumFramesPresenceDetect = 1;
    volatile uint16_t gestureToPresenceSwitchCntr = 1;
    
    volatile uint8_t flagG2PEnable = 0;
    volatile uint8_t flagPEnable = 1;
    extern volatile uint8_t flagConditionalSwitch;
    extern volatile uint16_t framesToSwitch;
    
    extern SemaphoreP_Object       hwaParamDoneHandlemaxDetmatrix;
    extern SemaphoreP_Object       hwaDoneHandlemaxDetmatrix;
    
    extern SemaphoreP_Object       hwaDoneMinorMotCalc;
    
    volatile uint8_t DEBUG_ENABLE = 0;
    
    /*! L3 RAM buffer for object detection DPC */
    uint8_t gMmwL3[0x50000]  __attribute((section(".l3")));
    
    /*! Local RAM buffer for object detection DPC */
    #define MMWDEMO_OBJDET_CORE_LOCAL_MEM_SIZE (50U * 1024U) //Modified here for storing detection matrix and intermediate variables
    uint8_t gMmwCoreLocMem[MMWDEMO_OBJDET_CORE_LOCAL_MEM_SIZE] = {0};
    
    #define MMWDEMO_OBJDET_CORE_LOCAL_MEM2_SIZE  (3*1024u)
    static uint8_t gMmwCoreLocMem2[MMWDEMO_OBJDET_CORE_LOCAL_MEM2_SIZE] __attribute__((aligned(HeapP_BYTE_ALIGNMENT)));
    
    HWA_Handle hwaHandle;
    
    DPU_RangeProcHWA_Config rangeProcDpuCfg;
    DPU_DopplerProcHWA_Config dopplerProcDpuCfg;
    DPU_AoAProcHWA_Config aoaProcDpuCfg;
    DPU_CFARProcHWA_Config cfarProcDpuCfg;
    
    typedef struct rangeProcTestConfig_t_ {
        uint32_t numTxAntennas;
        uint32_t numRxAntennas;
        uint32_t numVirtualAntennas;
        uint32_t numAdcSamples;
        uint32_t numRangeBins;
        uint32_t numChirpsPerFrame;
        uint32_t numChirpsPerFrameRef;
        uint32_t numFrames;
    } rangeProcTestConfig_t;
    
    extern TaskHandle_t gCliTask;
    
    extern float gSocClk;
    
    MMWave_temperatureStats  tempStats;
    
    extern volatile double frameIdleTime;
    
    extern void Mmwave_populateDefaultCalibrationCfg (MMWave_CalibrationCfg* ptrCalibrationCfg);
    
    extern void MMWave_getTemperatureReport (MMWave_temperatureStats* ptrTempStats);
    
    int32_t mmwDemo_registerFrameStartInterrupt(void);
    
    int32_t mmwDemo_mmWaveInit(bool iswarmstrt);
    
    extern void maxOfDetectionMatrix_copyDataOut();
    
    extern int32_t maxOfDetectionMatrix_config();
    
    extern int32_t maxOfDetectionMatrix_HWACommonConfig();
    
    extern int32_t minorMotionRangeDopp_config();
    
    extern int32_t minorMotionRangeDopp_HWACommonConfig();
    
    extern void rangeDoppMinorCalc_forAoA(uint8_t numPointsDetected);
    
    // RPMF
    // Priority of Power task
    #define POWER_TASK_PRI  (2u)
    // Stack for Power task
    #define POWER_TASK_SIZE (256u)
    #define LOW_PWR_MODE_DISABLE (0)
    #define LOW_PWR_MODE_ENABLE (1)
    #define LOW_PWR_TEST_MODE (2)
    StackType_t gPowerTaskStack[POWER_TASK_SIZE] __attribute__((aligned(32)));
    // Power task objects
    StaticTask_t gPowerTaskObj;
    TaskHandle_t gPowerTask;
    //Power task function
    void powerManagementTask(void *args);
    // Power task semaphore objects
    StaticSemaphore_t gPowerSemObj;
    SemaphoreHandle_t gPowerSem;
    // Status of DFP Re-init
    volatile int mmwReinitStatus = 0;
    Power_SleepState demoLowPwrStateTaken = POWER_NONE;
    
    volatile unsigned long long test;
    //For Sensor Stop
    uint32_t sensorStop = 0;
    extern int8_t isSensorStarted;
    
    // For freeing the channels after Sensor Stop
    static void mmwDemo_freeDmaChannels(EDMA_Handle edmaHandle);
    
    // LED config
    uint32_t gpioBaseAddrLed, pinNumLed;
    extern void App_mcanInit();
    extern void App_mcanTxRx();
    
    extern volatile unsigned long long demoStartTime;
    volatile unsigned long long demoEndTime, slpTimeus,lpdsLatency;
    extern TaskHandle_t gDpcTask;
    extern TaskHandle_t gTlvTask;
    extern TaskHandle_t gAdcFileTask;
    extern TaskHandle_t gCliTask;
    extern int32_t CLI_MMWStart(void);
    double demoTimeus,frmPrdus;
    
    extern uint8_t uKickDetect;         //Kickdown status (0x00 : inactive ; 0x01 : active)
    
    // Re-init Function Declarations
    void PowerClock_init();
    void Pinmux_init();
    void QSPI_init();
    void EDMA_init();
    void HWA_init();
    void Drivers_uartInit();
    
    int power_idleresumehook(uint_fast16_t eventType, uintptr_t eventArg, uintptr_t clientArg);
    
    /**
    *  @b Description
    *  @n
    *    Function which calculates the chirp parameters to be given to FECSS based on chirp params received via CLI
    */
    void fecss_calc_config()
    {   
        uint8_t i;
        float scale, rfBandwidth, rampDownTime;
        /* Calculation of channel configuration: 1 1 0 */
        if((gMmwMssMCB.channelCfg.h_RxChCtrlBitMask & 2) == 2)
        {
            gMmwMssMCB.angleDimension = 2;
        }
        else
        {
            gMmwMssMCB.angleDimension = 1;
        }
    
        gMmwMssMCB.numRxAntennas = 0;
        gMmwMssMCB.numTxAntennas = 0;
        for (i=0; i<16; i++)
        {
            if((gMmwMssMCB.channelCfg.h_TxChCtrlBitMask >> i) & 0x1)
            {
                gMmwMssMCB.numTxAntennas++;
            }
            if((gMmwMssMCB.channelCfg.h_RxChCtrlBitMask >> i) & 0x1)
            {
                gMmwMssMCB.numRxAntennas++;
            }
        }
    
        /* Calculation of Chirp Common configuration: 21 0 0 128 1 34 0 */
        gMmwMssMCB.adcSamplingRate = 100.0/gMmwMssMCB.profileComCfg.c_DigOutputSampRate; //Range 1MHz to 12.5MHz
        gMmwMssMCB.numRangeBins = mathUtils_pow2roundup(gMmwMssMCB.profileComCfg.h_NumOfAdcSamples)/2; //Real only sampling
    
        if (gMmwMssMCB.profileComCfg.c_ChirpTxMimoPatSel == 1)
        {
            /* TDM-MIMO*/
            gMmwMssMCB.isBpmEnabled = 0;
        }
        else if (gMmwMssMCB.profileComCfg.c_ChirpTxMimoPatSel == 4)
        {
            /* BPM-MIMO*/
            gMmwMssMCB.isBpmEnabled = 1;
        }
    
        /* Calculate the Chirp Timing configuration: 8 30 0 102.98 59 */
        #ifdef SOC_XWRL64XX
            gMmwMssMCB.profileTimeCfg.xh_ChirpRfFreqSlope  = (gMmwMssMCB.chirpSlope * 1048576.0)/(3* 100 * 100);
            gMmwMssMCB.profileTimeCfg.w_ChirpRfFreqStart   = (gMmwMssMCB.startFreq * 1000.0 * 256.0)/(300);
        #else
            gMmwMssMCB.profileTimeCfg.xh_ChirpRfFreqSlope  = (gMmwMssMCB.chirpSlope * 1048576.0)/(4* 100 * 100);
            gMmwMssMCB.profileTimeCfg.w_ChirpRfFreqStart   = (gMmwMssMCB.startFreq * 1000.0 * 256.0)/(400);
        #endif
    
        /* Calculate the frame configuration: 2 0 200 128 70 0 */
        gMmwMssMCB.frameCfg.w_BurstPeriodicity        = 10.0 * gMmwMssMCB.burstPeriod;
    
        /* Miscellaneous calculation */
        #ifdef SOC_XWRL64XX
                scale = 65536./(3*100*100);
        #else
                scale = 65536./(4*100*100);
        #endif
        rfBandwidth = (gMmwMssMCB.profileComCfg.h_ChirpRampEndTime*0.1) * gMmwMssMCB.chirpSlope; //In MHz/usec
        rampDownTime = MIN((gMmwMssMCB.profileTimeCfg.h_ChirpIdleTime*0.1-1.0), 6.0); //In usec
        gMmwMssMCB.profileComCfg.h_CrdNSlopeMag = (uint16_t)  (scale * rfBandwidth / rampDownTime + 0.5);
        gMmwMssMCB.profileTimeCfg.h_ChirpTxEnSel       = gMmwMssMCB.channelCfg.h_TxChCtrlBitMask;
        gMmwMssMCB.profileTimeCfg.h_ChirpTxBpmEnSel    = 0U;
    }
    
    /**
    *  @b Description
    *  @n
    *    Function which sets the chirp parameters first and stores the gesture chirp parameters for the 1st time when presence detection is enabled
    */
    void presenceDetectChirpParams()
    {   
        /* Copy the gesture chirp params to the gesture chirp struct */
        gMmwMssMCB.gestDetectParams.burstPeriod = gMmwMssMCB.burstPeriod;
        gMmwMssMCB.gestDetectParams.chirpSlope = gMmwMssMCB.chirpSlope;
        gMmwMssMCB.gestDetectParams.startFreq = gMmwMssMCB.startFreq;
        gMmwMssMCB.gestDetectParams.channelCfg = gMmwMssMCB.channelCfg;
        gMmwMssMCB.gestDetectParams.frameCfg = gMmwMssMCB.frameCfg;
        gMmwMssMCB.gestDetectParams.profileComCfg = gMmwMssMCB.profileComCfg;
        gMmwMssMCB.gestDetectParams.profileTimeCfg = gMmwMssMCB.profileTimeCfg;
        gMmwMssMCB.gestDetectParams.sigProcChainCfg = gMmwMssMCB.sigProcChainCfg;
        gMmwMssMCB.gestDetectParams.factoryCalCfg = gMmwMssMCB.factoryCalCfg;
        gMmwMssMCB.gestDetectParams.adcLogging = gMmwMssMCB.adcLogging;
        gMmwMssMCB.gestDetectParams.adcDataSourceCfg = gMmwMssMCB.adcDataSourceCfg;
        gMmwMssMCB.gestDetectParams.sensorStart = gMmwMssMCB.sensorStart;
        gMmwMssMCB.gestDetectParams.lowPowerMode = gMmwMssMCB.lowPowerMode;
    
        /* Populate the channel configuration: 7 3 0 */
        gMmwMssMCB.presDetectParams.channelCfg.h_RxChCtrlBitMask  = 1;
        gMmwMssMCB.presDetectParams.channelCfg.h_TxChCtrlBitMask  = 1;
        gMmwMssMCB.presDetectParams.channelCfg.c_MiscCtrl         = 0;
    
    
    
        /* Populate the Chirp Common configuration: 21 0 0 128 1 34 0 */
        gMmwMssMCB.presDetectParams.profileComCfg.c_DigOutputSampRate  = 21; //Range 8 to 100
        gMmwMssMCB.presDetectParams.profileComCfg.c_DigOutputBitsSel   = 0;
        gMmwMssMCB.presDetectParams.profileComCfg.c_DfeFirSel          = 0;
        gMmwMssMCB.presDetectParams.profileComCfg.h_NumOfAdcSamples    = 128;
        gMmwMssMCB.presDetectParams.profileComCfg.c_ChirpTxMimoPatSel  = 0;
        /* Chirp Common Config: MiscSettings and HPFFastInit Duration */
        gMmwMssMCB.presDetectParams.profileComCfg.c_MiscSettings       = 0U;
        gMmwMssMCB.presDetectParams.profileComCfg.c_HpfFastInitDuration= 15U; // 15uSec
        gMmwMssMCB.presDetectParams.profileComCfg.h_ChirpRampEndTime   = 10.0 * 34;
        gMmwMssMCB.presDetectParams.profileComCfg.c_ChirpRxHpfSel      = 0;
    
    
    
        /* Populate the Chirp Timing configuration: 8 30 0 102.98 59 */
        gMmwMssMCB.presDetectParams.profileTimeCfg.h_ChirpIdleTime      = 10.0 * 8;
        gMmwMssMCB.presDetectParams.profileTimeCfg.h_ChirpAdcStartTime  = 20 << 10; //num of skip samples
        /* Front End Firmware expects the ChirpTxStartTime in resolution of 20ns, hence multiply by 50 */
        gMmwMssMCB.presDetectParams.profileTimeCfg.xh_ChirpTxStartTime  = 50.0 * 0;
        gMmwMssMCB.presDetectParams.chirpSlope                          = 102.98; //MHz/us
        #ifdef SOC_XWRL64XX
            gMmwMssMCB.presDetectParams.startFreq                           = 59; //GHz
        #elif SOC_XWRL14XX
            gMmwMssMCB.presDetectParams.startFreq                           = 76; //GHz
        #endif
    
    
    
        /* Populate the frame configuration: 1 0 1000 2 250 0 */
        gMmwMssMCB.presDetectParams.frameCfg.h_NumOfChirpsInBurst      = 1;
        gMmwMssMCB.presDetectParams.frameCfg.c_NumOfChirpsAccum        = 0;
        gMmwMssMCB.presDetectParams.burstPeriod                        = gMmwMssMCB.presenceDetectCfg.burst_period; //us
        gMmwMssMCB.presDetectParams.frameCfg.h_NumOfBurstsInFrame      = 2;
        gMmwMssMCB.presDetectParams.frameCfg.w_FramePeriodicity        = ((500) * gSocClk)/1000; // x crystal_clk_MHz x 1000
        gMmwMssMCB.presDetectParams.frameCfg.h_NumOfFrames             = 0;
    
        
        
        gMmwMssMCB.channelCfg = gMmwMssMCB.presDetectParams.channelCfg;
        gMmwMssMCB.frameCfg = gMmwMssMCB.presDetectParams.frameCfg;
        gMmwMssMCB.profileComCfg = gMmwMssMCB.presDetectParams.profileComCfg;
        gMmwMssMCB.profileTimeCfg = gMmwMssMCB.presDetectParams.profileTimeCfg;
        gMmwMssMCB.chirpSlope = gMmwMssMCB.presDetectParams.chirpSlope;
        gMmwMssMCB.startFreq = gMmwMssMCB.presDetectParams.startFreq;
        gMmwMssMCB.burstPeriod = gMmwMssMCB.presDetectParams.burstPeriod;
    
        fecss_calc_config();   
    }
    
    /**
    *  @b Description
    *  @n
    *    Function which does the chirp parameters switch from presence to gesture mode based on state machine conditions
    */
    void presenceToGestureSwitch()
    {
        gMmwMssMCB.channelCfg = gMmwMssMCB.gestDetectParams.channelCfg;
        gMmwMssMCB.frameCfg = gMmwMssMCB.gestDetectParams.frameCfg;
        gMmwMssMCB.profileComCfg = gMmwMssMCB.gestDetectParams.profileComCfg;
        gMmwMssMCB.profileTimeCfg = gMmwMssMCB.gestDetectParams.profileTimeCfg;
    
        gMmwMssMCB.sigProcChainCfg = gMmwMssMCB.gestDetectParams.sigProcChainCfg;
        gMmwMssMCB.factoryCalCfg = gMmwMssMCB.gestDetectParams.factoryCalCfg;
        gMmwMssMCB.adcLogging = gMmwMssMCB.gestDetectParams.adcLogging;
        gMmwMssMCB.adcDataSourceCfg = gMmwMssMCB.gestDetectParams.adcDataSourceCfg;
        gMmwMssMCB.sensorStart = gMmwMssMCB.gestDetectParams.sensorStart;
        gMmwMssMCB.lowPowerMode = gMmwMssMCB.gestDetectParams.lowPowerMode;
    
        gMmwMssMCB.chirpSlope = gMmwMssMCB.gestDetectParams.chirpSlope;
        gMmwMssMCB.startFreq = gMmwMssMCB.gestDetectParams.startFreq;
        gMmwMssMCB.burstPeriod = gMmwMssMCB.gestDetectParams.burstPeriod;
    
        fecss_calc_config();
    }
    
    /**
    *  @b Description
    *  @n
    *    Function which does the chirp parameters switch from gesture to presence mode based on state machine conditions
    */
    void gestureToPresenceSwitch()
    {
        gMmwMssMCB.channelCfg = gMmwMssMCB.presDetectParams.channelCfg;
        gMmwMssMCB.frameCfg = gMmwMssMCB.presDetectParams.frameCfg;
        gMmwMssMCB.profileComCfg = gMmwMssMCB.presDetectParams.profileComCfg;
        gMmwMssMCB.profileTimeCfg = gMmwMssMCB.presDetectParams.profileTimeCfg;
        gMmwMssMCB.chirpSlope = gMmwMssMCB.presDetectParams.chirpSlope;
        gMmwMssMCB.startFreq = gMmwMssMCB.presDetectParams.startFreq;
        gMmwMssMCB.burstPeriod = gMmwMssMCB.presDetectParams.burstPeriod;
    
        gMmwMssMCB.sigProcChainCfg = gMmwMssMCB.gestDetectParams.sigProcChainCfg;
        gMmwMssMCB.factoryCalCfg = gMmwMssMCB.gestDetectParams.factoryCalCfg;
        gMmwMssMCB.adcLogging = gMmwMssMCB.gestDetectParams.adcLogging;
        gMmwMssMCB.adcDataSourceCfg = gMmwMssMCB.gestDetectParams.adcDataSourceCfg;
        gMmwMssMCB.sensorStart = gMmwMssMCB.gestDetectParams.sensorStart;
        gMmwMssMCB.lowPowerMode = gMmwMssMCB.gestDetectParams.lowPowerMode;
    
        fecss_calc_config();
    }
    
    /**
    *  @b Description
    *  @n
    *    Function calculates the magnitude corresponding to 2nd Doppler (if some velocity is present in the Doppler bin1-basicaly some object movement in front of radar) bin which will be used for presence detection
    */
    void presence_detection()
    {
        uint8_t i;
        float maxDistChirpCfg;
        uint8_t minRangeBinPresence, maxRangeBinPresence;
    
        maxDistChirpCfg = (3*pow(10,8)*gMmwMssMCB.adcSamplingRate*1.0*pow(10,6))/(4.0*gMmwMssMCB.chirpSlope*pow(10,12));
        minRangeBinPresence = floor(((gMmwMssMCB.numRangeBins-1)*MIN_RANGE_METERS)/maxDistChirpCfg);
        maxRangeBinPresence = floor(((gMmwMssMCB.numRangeBins-1)*MAX_RANGE_METERS)/maxDistChirpCfg);
    
        if(MIN_RANGE_METERS>maxDistChirpCfg || MAX_RANGE_METERS>maxDistChirpCfg || MIN_RANGE_METERS<0.10)
        {
            DebugP_assert(0);
        }
    
        for(i=minRangeBinPresence; i<maxRangeBinPresence; ++i)
        {
            gMmwMssMCB.presence_sumMagnitudeRangeBins += ((uint32_t *)gMmwMssMCB.detMatrix.data)[i*2-1];//Skipping the zero doppler bin
        }
        if(gMmwMssMCB.presenceDetectCfg.presenceDetectMode == 1 && (gMmwMssMCB.presence_sumMagnitudeRangeBins > gMmwMssMCB.presenceDetectCfg.thresholdRange))
        {
            ++sumFramesPresenceDetect;
        }
    }
    /**
    *  @b Description
    *  @n
    *    To generate the Vector Multiplication table for Doppler compensation
    */
    void VectorMult_gen(int32_t numDopplerBins, cmplx32ImRe_t *vectMult)
    {   
        int32_t amp,i;
        float t1,t2,coeff;
        
    
        t1 = round((gMmwMssMCB.profileComCfg.h_ChirpRampEndTime*0.1+gMmwMssMCB.profileTimeCfg.h_ChirpIdleTime*0.1))*pow(10,-6); //time between chirp1 Tx1 and chirp1 tx2 : Via CLI
        t2 = round(gMmwMssMCB.frameCfg.w_BurstPeriodicity*0.1)*pow(10,-6);//time between chirp1 Tx1 and chirp2 tx1 : Via CLI
        amp = pow(2,20)-1;//21 bits quantization
    
        for(i=0;i<numDopplerBins;++i)
        {
            if(i<=numDopplerBins/2)
            {
                coeff = (2*PI_*t1*i)/(t2*numDopplerBins);
            }
            else
            {
                coeff = (2*PI_*t1*(i-numDopplerBins))/(t2*numDopplerBins);
            }
            vectMult[i].real = floor(amp*sin(coeff));
            vectMult[i].imag = floor(amp*cos(coeff));
        }
    }
    
    /**
    *  @b Description
    *  @n
    *    Function to compute the elevation-azimuth index maxVal_elev_azim
    */
    void compute_elev_azim_idx(uint8_t numDetectedPoints)
    {
        uint8_t i, numPoints = numDetectedPoints; 
        if(NUM_AZIMUTH_ELEMENTS !=1 && NUM_ELEVATION_ELEMENTS !=1)
        {
            for(i=0;i<numPoints;++i)
            {
                gMmwMssMCB.elev_idx[i] = ceil((gMmwMssMCB.maxVal_elev_azim[i]*1.0+1)/gMmwMssMCB.sigProcChainCfg.azimuthFftSize)-1;
                if(gMmwMssMCB.elev_idx[i]>(gMmwMssMCB.sigProcChainCfg.elevationFftSize/2-1))
                    gMmwMssMCB.elev_idx[i] = gMmwMssMCB.elev_idx[i] - gMmwMssMCB.sigProcChainCfg.elevationFftSize;
                gMmwMssMCB.azim_idx[i] = (gMmwMssMCB.maxVal_elev_azim[i]+1)%gMmwMssMCB.sigProcChainCfg.azimuthFftSize-1;
                if(gMmwMssMCB.azim_idx[i]>(gMmwMssMCB.sigProcChainCfg.azimuthFftSize/2-1))
                    gMmwMssMCB.azim_idx[i] = gMmwMssMCB.azim_idx[i] - gMmwMssMCB.sigProcChainCfg.azimuthFftSize;
            }
        }
        else if(NUM_AZIMUTH_ELEMENTS == 1)
        {
            for(i=0;i<numPoints;++i)
            {
                gMmwMssMCB.elev_idx[i] = (gMmwMssMCB.maxVal_elev_azim[i]+1)%gMmwMssMCB.sigProcChainCfg.azimuthFftSize-1;
                if(gMmwMssMCB.elev_idx[i]>(gMmwMssMCB.sigProcChainCfg.azimuthFftSize/2-1))
                    gMmwMssMCB.elev_idx[i] = gMmwMssMCB.elev_idx[i] - gMmwMssMCB.sigProcChainCfg.azimuthFftSize;
                gMmwMssMCB.azim_idx[i] = 0;
            }
        }
        else if(NUM_ELEVATION_ELEMENTS == 1)
        {
            for(i=0;i<numPoints;++i)
            {
                gMmwMssMCB.azim_idx[i] = (gMmwMssMCB.maxVal_elev_azim[i]+1)%gMmwMssMCB.sigProcChainCfg.azimuthFftSize-1;
                if(gMmwMssMCB.azim_idx[i]>(gMmwMssMCB.sigProcChainCfg.azimuthFftSize/2-1))
                    gMmwMssMCB.azim_idx[i] = gMmwMssMCB.azim_idx[i] - gMmwMssMCB.sigProcChainCfg.azimuthFftSize;
                gMmwMssMCB.elev_idx[i] = 0;
            }
        }
    }
    
    //The function reads the FRAME_REF_TIMER that runs free at 40MHz
    uint32_t Cycleprofiler_getTimeStamp(void)
    {
        uint32_t *frameRefTimer;
        frameRefTimer = (uint32_t *) 0x5B000020;
        return *frameRefTimer;
    }
    
    #define HWA_MAX_NUM_DMA_TRIG_CHANNELS 16
    
    /**
     *  @b Description
     *  @n
     *      The function allocates HWA DMA source channel from the pool
     *
     *  @param[in]  pool Handle to pool object.
     *
     *  @retval
     *      channel Allocated HWA trigger source channel
     */
    uint8_t DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(HwaDmaTrigChanPoolObj *pool)
    {
        uint8_t channel = 0xFF;
        if(pool->dmaTrigSrcNextChan < HWA_MAX_NUM_DMA_TRIG_CHANNELS)
        {
            channel = pool->dmaTrigSrcNextChan;
            pool->dmaTrigSrcNextChan++;
        }
        return channel;
    }
    
    /**
     *  @b Description
     *  @n
     *      The function resets HWA DMA source channel pool
     *
     *  @param[in]  pool Handle to pool object.
     *
     *  @retval
     *      none
     */
    void DPC_ObjDet_HwaDmaTrigSrcChanPoolReset(HwaDmaTrigChanPoolObj *pool)
    {
        pool->dmaTrigSrcNextChan = 0;
    }
    
    
    /**
     *  @b Description
     *  @n
     *      Utility function for reseting memory pool.
     *
     *  @param[in]  pool Handle to pool object.
     *
     *  \ingroup DPC_OBJDET__INTERNAL_FUNCTION
     *
     *  @retval
     *      none.
     */
    static void DPC_ObjDet_MemPoolReset(MemPoolObj *pool)
    {
        pool->currAddr = (uintptr_t)pool->cfg.addr;
        pool->maxCurrAddr = pool->currAddr;
    }
    
    
    /**
     *  @b Description
     *  @n
     *      Utility function for setting memory pool to desired address in the pool.
     *      Helps to rewind for example.
     *
     *  @param[in]  pool Handle to pool object.
     *  @param[in]  addr Address to assign to the pool's current address.
     *
     *  \ingroup DPC_OBJDET__INTERNAL_FUNCTION
     *
     *  @retval
     *      None
     */
    static void DPC_ObjDet_MemPoolSet(MemPoolObj *pool, void *addr)
    {
        pool->currAddr = (uintptr_t)addr;
        pool->maxCurrAddr = MAX(pool->currAddr, pool->maxCurrAddr);
    }
    
    /**
     *  @b Description
     *  @n
     *      Utility function for getting memory pool current address.
     *
     *  @param[in]  pool Handle to pool object.
     *
     *  \ingroup DPC_OBJDET__INTERNAL_FUNCTION
     *
     *  @retval
     *      pointer to current address of the pool (from which next allocation will
     *      allocate to the desired alignment).
     */
    static void *DPC_ObjDet_MemPoolGet(MemPoolObj *pool)
    {
        return((void *)pool->currAddr);
    }
    
    /**
     *  @b Description
     *  @n
     *      Utility function for getting maximum memory pool usage.
     *
     *  @param[in]  pool Handle to pool object.
     *
     *  \ingroup DPC_OBJDET__INTERNAL_FUNCTION
     *
     *  @retval
     *      Amount of pool used in bytes.
     */
    static uint32_t DPC_ObjDet_MemPoolGetMaxUsage(MemPoolObj *pool)
    {
        return((uint32_t)(pool->maxCurrAddr - (uintptr_t)pool->cfg.addr));
    }
    
    /**
     *  @b Description
     *  @n
     *      Utility function for allocating from a static memory pool.
     *
     *  @param[in]  pool Handle to pool object.
     *  @param[in]  size Size in bytes to be allocated.
     *  @param[in]  align Alignment in bytes
     *
     *  \ingroup DPC_OBJDET__INTERNAL_FUNCTION
     *
     *  @retval
     *      pointer to beginning of allocated block. NULL indicates could not
     *      allocate.
     */
    static void *DPC_ObjDet_MemPoolAlloc(MemPoolObj *pool,
                                  uint32_t size,
                                  uint8_t align)
    {
        void *retAddr = NULL;
        uintptr_t addr;
    
        addr = MEM_ALIGN(pool->currAddr, align);
        if ((addr + size) <= ((uintptr_t)pool->cfg.addr + pool->cfg.size))
        {
            retAddr = (void *)addr;
            pool->currAddr = addr + size;
            pool->maxCurrAddr = MAX(pool->currAddr, pool->maxCurrAddr);
        }
    
        return(retAddr);
    }
    
    void featExtract_heapConstruct()
    {
        HeapP_construct(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, (void *) gMmwCoreLocMem2, MMWDEMO_OBJDET_CORE_LOCAL_MEM2_SIZE);
    }
    
    void *classifier_malloc(uint32_t sizeInBytes)
    {
        return HeapP_alloc(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, sizeInBytes);
    }
    void classifier_free(void *pFree, uint32_t sizeInBytes)
    {
        HeapP_free(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, pFree);
    }
    
    void *featExtract_malloc(uint32_t sizeInBytes)
    {
        return HeapP_alloc(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, sizeInBytes);
    }
    void featExtract_free(void *pFree, uint32_t sizeInBytes)
    {
        HeapP_free(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, pFree);
    }
    uint32_t featExtract_memUsage()
    {
        uint32_t usedMemSizeInBytes;
        HeapP_MemStats heapStats;
    
        HeapP_getHeapStats(&gMmwMssMCB.CoreLocalFeatExtractHeapObj, &heapStats);
        usedMemSizeInBytes = sizeof(gMmwCoreLocMem2) - heapStats.availableHeapSpaceInBytes;
    
        return usedMemSizeInBytes;
    }
    
    /**
     *  @b Description
     *  @n
     *      This function reads calibration data from flash and send it to front end
     *
     *  @param[in]  ptrCalibData         Pointer to Calibration data
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_calibRestore(MmwDemo_calibData  *ptrCalibData)
    {
        int32_t    retVal = 0;
        uint32_t   flashOffset;
    
        /* Get Flash Offset */
        flashOffset = gMmwMssMCB.factoryCalCfg.flashOffset;
    
        /* Read calibration data */
        if(mmwDemo_flashRead(flashOffset, (uint8_t *)ptrCalibData, sizeof(MmwDemo_calibData) )< 0)
        {
            /* Error: only one can be enable at at time */
            CLI_write ("Error: MmwDemo failed when reading calibration data from flash.\r\n");
            return -1;
        }
    
        /* Validate Calib data Magic number */
        if(ptrCalibData->magic != MMWDEMO_CALIB_STORE_MAGIC)
        {
            /* Header validation failed */
            CLI_write ("Error: MmwDemo calibration data header validation failed.\r\n");
            return -1;
        }
    
        return retVal;
    }
    
    /**
     *  @b Description
     *  @n
     *      This function retrieves the calibration data from front end and saves it in flash.
     *
     *  @param[in]  ptrCalibrationData      Pointer to Calibration data
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_calibSave(MmwDemo_calibData  *ptrCalibrationData)
    {
        uint32_t                flashOffset;
        int32_t                 retVal = 0;
    
        /* Calculate the read size in bytes */
        flashOffset = gMmwMssMCB.factoryCalCfg.flashOffset;
    
        /* Flash calibration data */
        retVal = mmwDemo_flashWrite(flashOffset, (uint8_t *)ptrCalibrationData, sizeof(MmwDemo_calibData));
        if(retVal < 0)
        {
            /* Flash write failed */
            CLI_write ("Error: MmwDemo failed flashing calibration data with error[%d].\n", retVal);
        }
    
        return retVal;
    }
    
    
    /**
     *  @b Description
     *  @n
     *      Send assert information through CLI.
     */
    void _MmwDemo_debugAssert(int32_t expression, const char *file, int32_t line)
    {
        if (!expression) {
            CLI_write ("Exception: %s, line %d.\r\n",file,line);
        }
    }
    
    /* In order to debug target code (set brake points, step over,...) set this variable below to 1 in CCS
     * expression window. It will prevent ISR mmwDemoFrameStartISR from forcing the code to stop */
    volatile uint32_t gDebugTargetCode = 1;
    
    static void mmwDemoFrameStartISR(void *arg)
    {
        uint32_t curCycle;
        MmwDemo_MSS_MCB *mmwMssMCB = (MmwDemo_MSS_MCB *) arg;
    
        HwiP_clearInt(CSL_APPSS_INTR_FECSS_FRAMETIMER_FRAME_START);
        mmwMssMCB->frameStartTimeStampSlowClk = PRCMSlowClkCtrGet();
        curCycle = Cycleprofiler_getTimeStamp();
        /* For testing */
        mmwMssMCB->stats.framePeriod_us = (curCycle - mmwMssMCB->stats.frameStartTimeStamp)/FRAME_REF_TIMER_CLOCK_MHZ;
        mmwMssMCB->stats.frameStartTimeStamp = curCycle;
    
        if (gDebugTargetCode == 0)
        {
            DebugP_assert(mmwMssMCB->interSubFrameProcToken == 0);
        }
        mmwMssMCB->interSubFrameProcToken++;
    
        mmwMssMCB->stats.frameStartIntCounter++;
    }
    
    static int32_t MmwDemo_calibInit(void)
    {
        int32_t        retVal = 0;
        ATE_CalibData  *ateCalib = (ATE_CalibData *)&gATECalibDataStorage;
    
        gMmwMssMCB.mmwAteCalibCfg.flashOffset = ATE_CALIB_FLASH_OFFSET;
        gMmwMssMCB.mmwAteCalibCfg.restoreEnable = 1;
        gMmwMssMCB.mmwAteCalibCfg.sizeOfCalibDataStorage = ATE_CALIB_DATA_LENGTH;
    
        /* Check if Calibration data is over the Reserved storage */
        if(gMmwMssMCB.mmwAteCalibCfg.restoreEnable == 1)
        {
            /* Resets calibration data */
            memset((void *)&gATECalibDataStorage, 0, sizeof(gATECalibDataStorage));
    
            /* Initialize Flash interface. */
            retVal = mmwDemo_flashInit();
    
            /* Check if the device is RF-Trimmed */
            /* Checking one Trim is enough */
            if(SOC_rcmReadSynthTrimValid() == RF_SYNTH_TRIM_VALID)
            {
                 ateCalib->validityFlag = ATE_CALIB_DATA_VALID;
                 gMmwMssMCB.factoryCalCfg.atecalibinEfuse = true;
            }
            else
            {
                gMmwMssMCB.factoryCalCfg.atecalibinEfuse = false;
                /* Read ATE Calibration data from Flash memory offset. */
                retVal = mmwDemo_flashRead(gMmwMssMCB.mmwAteCalibCfg.flashOffset,
                                       (uint8_t*)&gATECalibDataStorage, sizeof(gATECalibDataStorage));
    
                /* Check the validity of the Calibration data before populating address in mmwave Control MCB */
                if(ateCalib->validityFlag == ATE_CALIB_DATA_VALID )
                {
                    DebugP_log("Calibration Validated for restore \n");
                }
                else
                {
                    DebugP_log("Calibration Invalid \n");
                }
            }
        }
        else
        {
            CLI_write ("Error: Calibration restore not requested\n");
            retVal = -1;
        }
    
        return retVal;
    }
    
    /**
    *  @b Description
    *  @n
    *    Based on the configuration, set up the range processing DPU configurations
    */
    int32_t RangeProc_setProfile()
    {
    
        int32_t retVal = 0;
        DPU_RangeProcHWA_HW_Resources *pHwConfig = &rangeProcDpuCfg.hwRes;
        DPU_RangeProcHWA_StaticConfig  * params;
        uint32_t index;
        uint32_t bytesPerRxChan;
    
        /* Rangeproc DPU */
        pHwConfig = &rangeProcDpuCfg.hwRes;
        params = &rangeProcDpuCfg.staticCfg;
    
        memset((void *)&rangeProcDpuCfg, 0, sizeof(DPU_RangeProcHWA_Config));
    
        params->enableMajorMotion = gMmwMssMCB.enableMajorMotion;
        params->enableMinorMotion = 0; // Always kept to 0 for range DPU, this is transferred via a separate EDMA for gesture demo
        params->lowPowerMode = gMmwMssMCB.lowPowerMode;
    
        /* hwi configuration */
        pHwConfig = &rangeProcDpuCfg.hwRes;
    
        /* HWA configurations, not related to per test, common to all test */
        pHwConfig->hwaCfg.paramSetStartIdx = 0;
        pHwConfig->hwaCfg.numParamSet = DPU_RANGEPROCHWA_NUM_HWA_PARAM_SETS;
        pHwConfig->hwaCfg.hwaWinRamOffset  = DPC_OBJDET_HWA_RANGE_WINDOW_RAM_OFFSET;
        pHwConfig->hwaCfg.hwaWinSym = 1;
        pHwConfig->hwaCfg.dataInputMode = DPU_RangeProcHWA_InputMode_ISOLATED;
        pHwConfig->hwaCfg.dmaTrigSrcChan[0] = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
        pHwConfig->hwaCfg.dmaTrigSrcChan[1] = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
    
        /* edma configuration */
        pHwConfig->edmaHandle  = gEdmaHandle[0];
        /* edma configuration depends on the interleave or non-interleave */
    
        /* windowing buffer is fixed, size will change*/
        params->windowSize = sizeof(uint32_t) * ((gMmwMssMCB.profileComCfg.h_NumOfAdcSamples +1 ) / 2); //symmetric window, for real samples
        params->window =  (int32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             params->windowSize,
                                                             sizeof(uint32_t));
        if (params->window == NULL)
        {
            retVal = DPC_OBJECTDETECTION_ENOMEM__CORE_LOCAL_RAM_RANGE_HWA_WINDOW;
            goto exit;
        }
    
        /* adc buffer buffer, format fixed, interleave, size will change */
        params->ADCBufData.dataProperty.dataFmt = DPIF_DATAFORMAT_REAL16;
        params->ADCBufData.dataProperty.adcBits = 2U; // 12-bit only
        params->ADCBufData.dataProperty.numChirpsPerChirpEvent = 1U;
    
        if(gMmwMssMCB.adcDataSourceCfg.source == 0)
        {
            params->ADCBufData.data = (void *)CSL_APP_HWA_ADCBUF_RD_U_BASE;
        }
        else
        {
            gMmwMssMCB.adcTestBuff  = (uint8_t *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                                                MMW_DEMO_TEST_ADC_BUFF_SIZE,
                                                                                sizeof(uint32_t));
            if(gMmwMssMCB.adcTestBuff == NULL)
            {
                retVal = DPC_OBJECTDETECTION_ENOMEM__L3_RAM_ADC_TEST_BUFF;
                goto exit;
            }
            params->ADCBufData.data = (void *)gMmwMssMCB.adcTestBuff;
    
        }
    
        params->numTxAntennas = (uint8_t) gMmwMssMCB.numTxAntennas;
        params->numVirtualAntennas = (uint8_t) (gMmwMssMCB.numTxAntennas * gMmwMssMCB.numRxAntennas);
        params->numRangeBins = gMmwMssMCB.numRangeBins;
        params->numChirpsPerFrame = gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame * gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst;
        params->numDopplerChirpsPerFrame = params->numChirpsPerFrame/params->numTxAntennas;
    
        if ((params->numTxAntennas == 1) && ((gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame !=1)&&(gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst !=1)))
        {
            retVal = DPC_OBJECTDETECTION_EINVAL_CFG;
            goto exit;
        }
    
        if (params->enableMajorMotion)
        {
            params->numDopplerChirpsPerProc = params->numDopplerChirpsPerFrame;
        }
        else
        {
            params->numDopplerChirpsPerProc = params->numFramesPerMinorMotProc * params->numMinorMotionChirpsPerFrame;
        }
    
        params->isBpmEnabled = gMmwMssMCB.isBpmEnabled;
        /* windowing */
        params->ADCBufData.dataProperty.numRxAntennas = (uint8_t) gMmwMssMCB.numRxAntennas;
        params->ADCBufData.dataSize = gMmwMssMCB.profileComCfg.h_NumOfAdcSamples * params->ADCBufData.dataProperty.numRxAntennas * 4 ;
        params->ADCBufData.dataProperty.numAdcSamples = gMmwMssMCB.profileComCfg.h_NumOfAdcSamples;
    
        mathUtils_genWindow((uint32_t *)params->window,
                            (uint32_t) params->ADCBufData.dataProperty.numAdcSamples,
                            params->windowSize/sizeof(uint32_t),
                            DPC_DPU_RANGEPROC_FFT_WINDOW_TYPE,
                            DPC_OBJDET_QFORMAT_RANGE_FFT);
        
        params->rangeFFTtuning.fftOutputDivShift = 0;
        params->rangeFFTtuning.numLastButterflyStagesToScale = 0; /* no scaling needed as ADC is 16-bit and we have 8 bits to grow */
    
        params->rangeFftSize = mathUtils_pow2roundup(params->ADCBufData.dataProperty.numAdcSamples);
    
        bytesPerRxChan = params->ADCBufData.dataProperty.numAdcSamples * sizeof(uint16_t);
        bytesPerRxChan = (bytesPerRxChan + 15) / 16 * 16;
    
        for (index = 0; index < SYS_COMMON_NUM_RX_CHANNEL; index++)
        {
            params->ADCBufData.dataProperty.rxChanOffset[index] = index * bytesPerRxChan;
        }
    
        params->ADCBufData.dataProperty.interleave = DPIF_RXCHAN_NON_INTERLEAVE_MODE;
        /* Data Input EDMA */
        pHwConfig->edmaInCfg.dataIn.channel         = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_CH;
        pHwConfig->edmaInCfg.dataIn.channelShadow[0]   = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_SHADOW_PING;
        pHwConfig->edmaInCfg.dataIn.channelShadow[1]   = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_SHADOW_PONG;
        pHwConfig->edmaInCfg.dataIn.eventQueue      = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_EVENT_QUE;
        pHwConfig->edmaInCfg.dataInSignature.channel         = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_SIG_CH;
        pHwConfig->edmaInCfg.dataInSignature.channelShadow   = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_SIG_SHADOW;
        pHwConfig->edmaInCfg.dataInSignature.eventQueue      = DPC_OBJDET_DPU_RANGEPROC_EDMAIN_SIG_EVENT_QUE;
        pHwConfig->intrObj = intrObj_rangeProc;
    
        /* Data Output EDMA */
        pHwConfig->edmaOutCfg.path[0].evtDecim.channel = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PING_CH;
        pHwConfig->edmaOutCfg.path[0].evtDecim.channelShadow[0] = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PING_SHADOW_0;
        pHwConfig->edmaOutCfg.path[0].evtDecim.channelShadow[1] = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PING_SHADOW_1;
        pHwConfig->edmaOutCfg.path[0].evtDecim.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PING_EVENT_QUE;
    
        pHwConfig->edmaOutCfg.path[1].evtDecim.channel = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PONG_CH;
        pHwConfig->edmaOutCfg.path[1].evtDecim.channelShadow[0] = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PONG_SHADOW_0;
        pHwConfig->edmaOutCfg.path[1].evtDecim.channelShadow[1] = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PONG_SHADOW_1;
        pHwConfig->edmaOutCfg.path[1].evtDecim.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EVT_DECIM_PONG_EVENT_QUE;
    
        pHwConfig->edmaOutCfg.path[0].dataOutMinor.channel = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PING_CH;
        pHwConfig->edmaOutCfg.path[0].dataOutMinor.channelShadow = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PING_SHADOW;
        pHwConfig->edmaOutCfg.path[0].dataOutMinor.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PING_EVENT_QUE;
    
        pHwConfig->edmaOutCfg.path[1].dataOutMinor.channel = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PONG_CH;
        pHwConfig->edmaOutCfg.path[1].dataOutMinor.channelShadow = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PONG_SHADOW;
        pHwConfig->edmaOutCfg.path[1].dataOutMinor.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MINOR_PONG_EVENT_QUE;
    
        pHwConfig->edmaOutCfg.path[0].dataOutMajor.channel = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PING_CH;
        pHwConfig->edmaOutCfg.path[0].dataOutMajor.channelShadow = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PING_SHADOW;
        pHwConfig->edmaOutCfg.path[0].dataOutMajor.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PING_EVENT_QUE;
    
        pHwConfig->edmaOutCfg.path[1].dataOutMajor.channel = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PONG_CH;
        pHwConfig->edmaOutCfg.path[1].dataOutMajor.channelShadow = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PONG_SHADOW;
        pHwConfig->edmaOutCfg.path[1].dataOutMajor.eventQueue = DPC_OBJDET_DPU_RANGEPROC_EDMAOUT_MAJOR_PONG_EVENT_QUE;
    
        /* Radar cube Major Motion*/
        if (params->enableMajorMotion)
        {
    
            gMmwMssMCB.radarCube[0].dataSize = params->numRangeBins * params->numVirtualAntennas * sizeof(cmplx16ReIm_t) * params->numDopplerChirpsPerProc;
            gMmwMssMCB.radarCube[0].data  = (uint32_t *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                                                   gMmwMssMCB.radarCube[0].dataSize,
                                                                                   sizeof(uint32_t));
            if(gMmwMssMCB.radarCube[0].data == NULL)
            {
                retVal = DPC_OBJECTDETECTION_ENOMEM__L3_RAM_RADAR_CUBE;
                goto exit;
            }
        }
        else
        {
            gMmwMssMCB.radarCube[0].data  = NULL;
            gMmwMssMCB.radarCube[0].dataSize = 0;
        }
        gMmwMssMCB.radarCube[0].datafmt = DPIF_RADARCUBE_FORMAT_6;
        rangeProcDpuCfg.hwRes.radarCube = gMmwMssMCB.radarCube[0];
    
        /* Radar cube Minor Motion*/
        if (gMmwMssMCB.enableMinorMotion)
        {
            gMmwMssMCB.radarCube[1].dataSize = params->numRangeBins * params->numVirtualAntennas * sizeof(cmplx16ReIm_t) * gMmwMssMCB.sigProcChainCfg.numFrmPerMinorMotProc * gMmwMssMCB.sigProcChainCfg.numMinorMotionChirpsPerFrame;
            gMmwMssMCB.radarCube[1].data  = (cmplx16ImRe_t *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                                                         gMmwMssMCB.radarCube[1].dataSize,
                                                                                         sizeof(uint32_t));
            if(gMmwMssMCB.radarCube[1].data == NULL)
            {
                retVal = DPC_OBJECTDETECTION_ENOMEM__L3_RAM_RADAR_CUBE;
                goto exit;
            }
    
        }
        else
        {
            gMmwMssMCB.radarCube[1].data  = NULL;
            gMmwMssMCB.radarCube[1].dataSize = 0;
        }
        gMmwMssMCB.radarCube[1].datafmt = DPIF_RADARCUBE_FORMAT_6;
        rangeProcDpuCfg.hwRes.radarCubeMinMot = gMmwMssMCB.radarCube[1];
    
    exit:
        return retVal;
    }
    
    /**
    *  @b Description
    *  @n
    *    Based on the configuration, set up the Doppler processing DPU configurations
    */
    int32_t DopplerProc_setProfile()
    {   
        uint32_t retVal = 0;
        DPU_DopplerProcHWA_HW_Resources  *pHwConfig;
        DPU_DopplerProcHWA_StaticConfig  *dopStaticConfig;
        
        pHwConfig = &dopplerProcDpuCfg.hwRes; 
        dopStaticConfig = &dopplerProcDpuCfg.staticCfg; 
    
        memset((void *)&dopplerProcDpuCfg, 0, sizeof(DPU_DopplerProcHWA_Config));
        
        /* overwrite the common params with the test configuration*/
        /* edma configuration */
        pHwConfig->edmaCfg.edmaHandle  = gEdmaHandle[0];
        dopStaticConfig->numTxAntennas = gMmwMssMCB.numTxAntennas;
        dopStaticConfig->numRxAntennas = gMmwMssMCB.numRxAntennas;
        dopStaticConfig->numVirtualAntennas = gMmwMssMCB.numTxAntennas * gMmwMssMCB.numRxAntennas;
        gMmwMssMCB.numVirtualAntennas = dopStaticConfig->numVirtualAntennas;
        dopStaticConfig->numRangeBins = gMmwMssMCB.numRangeBins;
        dopStaticConfig->numDopplerChirps = (gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst*gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame)/gMmwMssMCB.numTxAntennas;
        gMmwMssMCB.numDopplerChirps = dopStaticConfig->numDopplerChirps;
        dopStaticConfig->numDopplerBins = mathUtils_pow2roundup(dopStaticConfig->numDopplerChirps);
        dopStaticConfig->log2NumDopplerBins = mathUtils_ceilLog2(dopStaticConfig->numDopplerBins);
        gMmwMssMCB.log2numDopplerBins = dopStaticConfig->log2NumDopplerBins;
        dopStaticConfig->doppFFT_is16b = 0; //Takes into account of 16-bit complex Doppler FFT
        
        /* windowing */
        pHwConfig->hwaCfg.winRamOffset = DPC_OBJDET_HWA_DOPPLER_WINDOW_RAM_OFFSET;
        pHwConfig->hwaCfg.winSym = 1;
        pHwConfig->hwaCfg.windowSize = sizeof(uint32_t) * ((dopStaticConfig->numDopplerChirps + 1) / 2); //symmetric window, for real samples
        pHwConfig->hwaCfg.window =  (int32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             pHwConfig->hwaCfg.windowSize,
                                                             sizeof(uint32_t));
        if (pHwConfig->hwaCfg.window == NULL)
        {
            retVal = DPC_OBJECTDETECTION_ENOMEM__CORE_LOCAL_RAM_DOPPLER_HWA_WINDOW;
            goto exit;
        }
        mathUtils_genWindow((uint32_t *)pHwConfig->hwaCfg.window,
                            (uint32_t) dopStaticConfig->numDopplerBins,
                            pHwConfig->hwaCfg.windowSize/sizeof(uint32_t),
                            DPC_DPU_DOPPLERPROC_FFT_WINDOW_TYPE,
                            DPC_OBJDET_QFORMAT_DOPPLER_FFT);
                            
        /* 1D-FFT radar cube */
        pHwConfig->radar_1D_FFT_Cube.dataSize = dopStaticConfig->numRangeBins * dopStaticConfig->numTxAntennas * dopStaticConfig->numRxAntennas * sizeof(cmplx16ReIm_t) * dopStaticConfig->numDopplerChirps;
        pHwConfig->radar_1D_FFT_Cube.datafmt = DPIF_RADARCUBE_FORMAT_6;
        pHwConfig->radar_1D_FFT_Cube.data = gMmwMssMCB.radarCube[0].data;
        
        /* detection Matrix after 2D-FFT and non-coherent addition*/
        pHwConfig->detMatrix.datafmt = DPIF_DETMATRIX_FORMAT_1;
        pHwConfig->detMatrix.dataSize = dopStaticConfig->numRangeBins * dopStaticConfig->numDopplerBins*sizeof(uint32_t);
        pHwConfig->detMatrix.data = DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                            pHwConfig->detMatrix.dataSize,
                                                            sizeof(uint32_t));
        /*Calculate parameters for minor motion if enabled*/
        if(gMmwMssMCB.enableMinorMotion)
        {   
            gMmwMssMCB.numDopplerChirpsMinorMot = gMmwMssMCB.sigProcChainCfg.numFrmPerMinorMotProc * gMmwMssMCB.sigProcChainCfg.numMinorMotionChirpsPerFrame;
            gMmwMssMCB.numDopplerBinsMinorMot = mathUtils_pow2roundup(gMmwMssMCB.numDopplerChirpsMinorMot);
            gMmwMssMCB.log2numDopplerBinsMinorMot = mathUtils_ceilLog2(gMmwMssMCB.numDopplerBinsMinorMot);
            gMmwMssMCB.detMatrixMinorMot.datafmt = DPIF_DETMATRIX_FORMAT_1;
            gMmwMssMCB.detMatrixMinorMot.dataSize = dopStaticConfig->numRangeBins * gMmwMssMCB.numDopplerBinsMinorMot * sizeof(uint32_t);
            gMmwMssMCB.detMatrixMinorMot.data = DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                            gMmwMssMCB.detMatrixMinorMot.dataSize,
                                                            sizeof(uint32_t));
        }
    
        /* Data Input EDMA */
        pHwConfig->edmaCfg.edmaIn.ping.channel        = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PING;
        pHwConfig->edmaCfg.edmaIn.pong.channel        = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PONG;
        pHwConfig->edmaCfg.edmaIn.ping.channelShadow  = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PING;
        pHwConfig->edmaCfg.edmaIn.pong.channelShadow  = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaIn.ping.eventQueue     = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaIn.pong.eventQueue     = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_EVENT_QUE_PONG;
    
        /* Hot signature EDMA */
        pHwConfig->edmaCfg.edmaHotSig.ping.channel    = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_CH_PING;
        pHwConfig->edmaCfg.edmaHotSig.pong.channel    = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_CH_PONG;
        pHwConfig->edmaCfg.edmaHotSig.ping.channelShadow  = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_SHADOW_PING;
        pHwConfig->edmaCfg.edmaHotSig.pong.channelShadow  = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaHotSig.ping.eventQueue     = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaHotSig.pong.eventQueue     = DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SIG_EVENT_QUE_PING;
        pHwConfig->intrObj = &intrObj_dopplerProc;
    
        /* Data Output EDMA */
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.ping.channel = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH;
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.pong.channel = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH;
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.ping.channelShadow = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW;
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.pong.channelShadow = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW;
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.ping.eventQueue = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_EVENT_QUE;
        pHwConfig->edmaCfg.edmaOutDetectionMatrix.pong.eventQueue = DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_EVENT_QUE;
    
        gMmwMssMCB.detMatrix.data = pHwConfig->detMatrix.data;
        gMmwMssMCB.detMatrix.datafmt = DPIF_DETMATRIX_FORMAT_1;
        gMmwMssMCB.detMatrix.dataSize = pHwConfig->detMatrix.dataSize;
        gMmwMssMCB.numDopplerBins = dopStaticConfig->numDopplerBins;
        
        pHwConfig->hwaCfg.paramSetStartIdx = DPU_RANGEPROCHWA_NUM_HWA_PARAM_SETS/2;
        pHwConfig->hwaCfg.dmaTrigSrcPingChan = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
        pHwConfig->hwaCfg.dmaTrigSrcPongChan = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
    
    
    exit:
        return retVal;
    }
    
    int32_t AoAProc_setProfile()
    {
        DPU_AoAProcHWA_HW_Resources  *pHwConfig;
        DPU_AoAProcHWA_StaticConfig  *aoaStaticConfig;
        DPU_AoAProcHWA_maxDetMatrix_Resources *detMatrix_res;
        
        pHwConfig = &aoaProcDpuCfg.hwRes; 
        aoaStaticConfig = &aoaProcDpuCfg.staticCfg;
        detMatrix_res = &aoaProcDpuCfg.maxDetmatrix_res;
    
        memset((void *)&aoaProcDpuCfg, 0, sizeof(DPU_AoAProcHWA_Config));
    
        /* HWA configurations common to demo */
        pHwConfig->hwaCfg.paramSetStartIdx = gMmwMssMCB.numUsedHwaParamSets;
        pHwConfig->hwaCfg.hwaDmaTriggerDoppPing = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
        pHwConfig->hwaCfg.hwaDmaTriggerDoppPong = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
        pHwConfig->hwaCfg.hwaDmaTriggerAoAPing = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
        pHwConfig->hwaCfg.hwaDmaTriggerAoAPong = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
    
        gMmwMssMCB.AoAhwaNumLoops = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             2,sizeof(uint16_t));
        pHwConfig->hwaCfg.AoAhwaNumLoops = gMmwMssMCB.AoAhwaNumLoops;
    
        /* edma configuration */
        pHwConfig->edmaCfg.edmaHandle  = gEdmaHandle[0];
    
        /* common params for AoA DPU */
        aoaStaticConfig->numTxAntennas = gMmwMssMCB.numTxAntennas;
        aoaStaticConfig->numRxAntennas = gMmwMssMCB.numRxAntennas;
        aoaStaticConfig->numVirtualAntennas = gMmwMssMCB.numTxAntennas * gMmwMssMCB.numRxAntennas;
        aoaStaticConfig->numRangeBins = gMmwMssMCB.numRangeBins;
        aoaStaticConfig->numDopplerChirps = (gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst*gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame)/gMmwMssMCB.numTxAntennas;
        aoaStaticConfig->numDopplerBins = mathUtils_pow2roundup(aoaStaticConfig->numDopplerChirps);
        aoaStaticConfig->log2NumDopplerBins = mathUtils_ceilLog2(aoaStaticConfig->numDopplerBins);
        aoaStaticConfig->doppFFT_is16b = 0; //Takes into account of 16-bit complex Doppler FFT
        aoaStaticConfig->elevationFFTSize = gMmwMssMCB.sigProcChainCfg.elevationFftSize; //Via CLI
        aoaStaticConfig->azimuthFFTSize = gMmwMssMCB.sigProcChainCfg.azimuthFftSize; //Via CLI
        aoaStaticConfig->log2NumElevationBins = mathUtils_ceilLog2(aoaStaticConfig->elevationFFTSize);
        aoaStaticConfig->log2NumAzimuthBins = mathUtils_ceilLog2(aoaStaticConfig->azimuthFFTSize);
    
        /* windowing */
        pHwConfig->hwaCfg.windowSize = sizeof(uint32_t) * ((aoaStaticConfig->numDopplerChirps + 1) / 2); //symmetric window, for real samples
        pHwConfig->hwaCfg.winRamOffset  = DPC_OBJDET_HWA_DOPPLER_WINDOW_RAM_OFFSET; 
        pHwConfig->hwaCfg.winSym = 1;
        pHwConfig->hwaCfg.window = dopplerProcDpuCfg.hwRes.hwaCfg.window;
    
        /* Vector Multiplication RAM */
        pHwConfig->hwaCfg.vecRamOffset = DPC_OBJDET_HWA_VECTOR_RAM_OFFSET;
        pHwConfig->hwaCfg.vectorRamSize = sizeof(cmplx32ImRe_t)*aoaStaticConfig->numDopplerBins;
        pHwConfig->hwaCfg.vectorRam = (cmplx32ImRe_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             pHwConfig->hwaCfg.vectorRamSize,
                                                             sizeof(uint32_t));
        VectorMult_gen((int32_t)aoaStaticConfig->numDopplerBins, (cmplx32ImRe_t *)pHwConfig->hwaCfg.vectorRam);
        
        /* 1D-FFT radar cube */
        pHwConfig->radar_1D_FFT_Cube.dataSize = aoaStaticConfig->numRangeBins * aoaStaticConfig->numTxAntennas * aoaStaticConfig->numRxAntennas * sizeof(cmplx16ReIm_t) * aoaStaticConfig->numDopplerChirps;
        pHwConfig->radar_1D_FFT_Cube.datafmt = DPIF_RADARCUBE_FORMAT_6;
        pHwConfig->radar_1D_FFT_Cube.data = gMmwMssMCB.radarCube[0].data;
    
        /* By default doppler phase compensation is enabled for feature extraction and major motion and is disabled for minor motion*/ 
        gMmwMssMCB.isDopplerPhaseCompensationEnabled = (uint8_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             1,sizeof(uint8_t));
        gMmwMssMCB.isDopplerPhaseCompensationEnabled[0] = 1;
        pHwConfig->hwaCfg.isDopplerPhaseCompensationEnabled = gMmwMssMCB.isDopplerPhaseCompensationEnabled;
    
        /* Antenna Array elements and max num of points for the test case*/
        detMatrix_res->antenna_array_elements = NUM_AZIMUTH_ELEMENTS*NUM_ELEVATION_ELEMENTS;
        detMatrix_res->max_num_points = gMmwMssMCB.sigProcChainCfg.maxNumPoints; //Via CLI
        if(gMmwMssMCB.sigProcChainCfg.azimuthFftSize !=1 && gMmwMssMCB.sigProcChainCfg.elevationFftSize !=1)
        {
            aoaStaticConfig->numCols_Antenna = NUM_AZIMUTH_ELEMENTS;
            aoaStaticConfig->numRows_Antenna = NUM_ELEVATION_ELEMENTS;
        }
        else
        {
            aoaStaticConfig->numCols_Antenna = NUM_AZIMUTH_ELEMENTS*NUM_ELEVATION_ELEMENTS;
            aoaStaticConfig->numRows_Antenna = 1;
        }
    
        /* Max n number of points pointers mapping*/
        detMatrix_res->rangeGatesCount = gMmwMssMCB.rangeGatesCount;
        detMatrix_res->range_idx_arr = gMmwMssMCB.range_idx_arr;
        detMatrix_res->angle_idx_doppler_count_arr = gMmwMssMCB.angle_idx_doppler_count_arr;
        detMatrix_res->doppler_idx_arr = gMmwMssMCB.doppler_idx_arr;
        detMatrix_res->antenna_array = gMmwMssMCB.antenna_array;
    
        /* Angle Matrix data arrangement for storing data before AoA */
        gMmwMssMCB.angleMat.dataSize = detMatrix_res->max_num_points*aoaStaticConfig->numCols_Antenna*aoaStaticConfig->numRows_Antenna*sizeof(cmplx32ImRe_t);
        gMmwMssMCB.angleMat.datafmt = DPIF_DPIF_ANGLEMATRIX_FORMAT_1;
        gMmwMssMCB.angleMat.data = (uint64_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                             gMmwMssMCB.angleMat.dataSize,
                                                             sizeof(uint32_t));
        
        pHwConfig->angleMat.data = gMmwMssMCB.angleMat.data;
        pHwConfig->angleMat.datafmt = gMmwMssMCB.angleMat.datafmt;
        pHwConfig->angleMat.dataSize = gMmwMssMCB.angleMat.dataSize;
    
        /*max of AoA index */
        gMmwMssMCB.maxVal_elev_azim = (uint32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             detMatrix_res->max_num_points*sizeof(uint32_t),
                                                             sizeof(uint32_t));
    
        pHwConfig->maxVal_elev_azim = gMmwMssMCB.maxVal_elev_azim;
    
        /* Data Input EDMA Doppler*/
        pHwConfig->edmaCfg.edmaIn_rangeFFT.ping.channel        = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PING;
        pHwConfig->edmaCfg.edmaIn_rangeFFT.pong.channel        = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PONG;
        pHwConfig->edmaCfg.edmaIn_rangeFFT.ping.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PING;
        pHwConfig->edmaCfg.edmaIn_rangeFFT.pong.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaIn_rangeFFT.ping.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaIn_rangeFFT.pong.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_EVENT_QUE_PONG;
    
        /* Hot signature EDMA Doppler*/
        pHwConfig->edmaCfg.edmaHotSigDoppler.ping.channel    = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_CH_PING;
        pHwConfig->edmaCfg.edmaHotSigDoppler.pong.channel    = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_CH_PONG;
        pHwConfig->edmaCfg.edmaHotSigDoppler.ping.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_SHADOW_PING;
        pHwConfig->edmaCfg.edmaHotSigDoppler.pong.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaHotSigDoppler.ping.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaHotSigDoppler.pong.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SIG_EVENT_QUE_PING;
    
        /* Data Input EDMA AoA*/
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.ping.channel        = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_CH_PING;
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.pong.channel        = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_CH_PONG;
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.ping.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SHADOW_PING;
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.pong.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.ping.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaIn_dopplerFFT.pong.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_EVENT_QUE_PONG;
    
        /* Hot signature EDMA AoA*/
        pHwConfig->edmaCfg.edmaHotSigAoA.ping.channel    = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_CH_PING;
        pHwConfig->edmaCfg.edmaHotSigAoA.pong.channel    = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_CH_PONG;
        pHwConfig->edmaCfg.edmaHotSigAoA.ping.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_SHADOW_PING;
        pHwConfig->edmaCfg.edmaHotSigAoA.pong.channelShadow  = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_SHADOW_PONG;
        pHwConfig->edmaCfg.edmaHotSigAoA.ping.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_EVENT_QUE_PING;
        pHwConfig->edmaCfg.edmaHotSigAoA.pong.eventQueue     = DPC_OBJDET_DPU_AOAPROC_EDMAIN_AOA_SIG_EVENT_QUE_PING;
        pHwConfig->intrObj = &intrObj_aoaProc;
    
        /* Data Output EDMA */
        pHwConfig->edmaCfg.edmaOut_maxAoA.ping.channel = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PING_CH;
        pHwConfig->edmaCfg.edmaOut_maxAoA.pong.channel = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PONG_CH;
        pHwConfig->edmaCfg.edmaOut_maxAoA.ping.channelShadow = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PING_SHADOW;
        pHwConfig->edmaCfg.edmaOut_maxAoA.pong.channelShadow = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PONG_SHADOW;
        pHwConfig->edmaCfg.edmaOut_maxAoA.ping.eventQueue = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PING_EVENT_QUE;
        pHwConfig->edmaCfg.edmaOut_maxAoA.pong.eventQueue = DPC_OBJDET_DPU_AOAPROC_EDMAOUT_MAXAOA_PONG_EVENT_QUE;
    
        return 0;
    }
    
    /**
    *  @b Description
    *  @n
    *    Based on the configuration, set up the CFAR detection processing DPU configurations
    */
    int32_t CfarProc_setProfile()
    {
        int32_t retVal = 0;
        float adcStart, startFreq, slope, bandwidth, centerFreq;
        DPU_CFARProcHWA_HW_Resources *pHwConfig;
        DPU_CFARProcHWA_StaticConfig  *params;
    
        /* CFARproc DPU based on Range/Doppler heatmap */
        pHwConfig = &cfarProcDpuCfg.res;
        params = &cfarProcDpuCfg.staticCfg;
    
        memset((void *)&cfarProcDpuCfg, 0, sizeof(DPU_CFARProcHWA_Config));
    
        /* HWA configurations, not related to per test, common to all test */
        pHwConfig->hwaCfg.paramSetStartIdx = gMmwMssMCB.numUsedHwaParamSets;
        pHwConfig->hwaCfg.dmaTrigSrcChan = DPC_ObjDet_HwaDmaTrigSrcChanPoolAlloc(&gMmwMssMCB.HwaDmaChanPoolObj);
    
        /* edma configuration */
        pHwConfig->edmaHandle  = gEdmaHandle[0];
    
        /* Data Input EDMA */
        pHwConfig->edmaHwaIn.channel         = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_CH;
        pHwConfig->edmaHwaIn.channelShadow   = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_SHADOW;
        pHwConfig->edmaHwaIn.eventQueue      = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_EVENT_QUE;
        pHwConfig->edmaHwaInSignature.channel         = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_SIG_CH;
        pHwConfig->edmaHwaInSignature.channelShadow   = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_SIG_SHADOW;
        pHwConfig->edmaHwaInSignature.eventQueue      = DPC_OBJDET_DPU_CFAR_PROC_EDMAIN_SIG_EVENT_QUE;
        pHwConfig->intrObj = &intrObj_cfarProc;
    
        /* Data Output EDMA */
        pHwConfig->edmaHwaOut.channel         = DPC_OBJDET_DPU_CFAR_PROC_EDMAOUT_RNG_PROFILE_CH;
        pHwConfig->edmaHwaOut.channelShadow   = DPC_OBJDET_DPU_CFAR_PROC_EDMAOUT_RNG_PROFILE_SHADOW;
        pHwConfig->edmaHwaOut.eventQueue      = DPC_OBJDET_DPU_CFAR_PROC_EDMAOUT_RNG_PROFILE_EVENT_QUE;
    
        /* Give M0 and M1 memory banks for detection matrix scratch. */
        pHwConfig->hwaMemInp = (uint16_t *) CSL_APP_HWA_DMA0_RAM_BANK0_BASE;
        pHwConfig->hwaMemInpSize = (CSL_APP_HWA_BANK_SIZE * 2) / sizeof(uint16_t);
    
        /* M2 bank: for CFAR detection list */
        pHwConfig->hwaMemOutDetList = (DPU_CFARProcHWA_CfarDetOutput *) CSL_APP_HWA_DMA0_RAM_BANK2_BASE;
        pHwConfig->hwaMemOutDetListSize = CSL_APP_HWA_BANK_SIZE /
                                    sizeof(DPU_CFARProcHWA_CfarDetOutput);
    
        /* M3 bank: for maximum azimuth values per range bin  (range profile) */
        pHwConfig->hwaMemOutRangeProfile = (DPU_CFARProcHWA_HwaMaxOutput *) CSL_APP_HWA_DMA0_RAM_BANK3_BASE;
    
        /* dynamic config */
        cfarProcDpuCfg.dynCfg.cfarCfg   = &gMmwMssMCB.cfarCfg;
        cfarProcDpuCfg.dynCfg.fovRange  = &gMmwMssMCB.rangeSelCfg;
        cfarProcDpuCfg.dynCfg.fovAoaCfg    = &gMmwMssMCB.fovAoaCfg;
    
        /* DPU Static config */
        params->detectionHeatmapType = DPU_CFAR_RANGE_DOPPLER_HEATMAP;
        params->numRangeBins = gMmwMssMCB.numRangeBins;
        params->numDopplerBins     = gMmwMssMCB.numDopplerBins;
        params->log2NumDopplerBins = mathUtils_ceilLog2(params->numDopplerBins);
    
        params->angleDimension        = gMmwMssMCB.angleDimension;
        params->isDetMatrixLogScale   = false;
        params->azimuthFftSize        = gMmwMssMCB.sigProcChainCfg.azimuthFftSize;
        params->elevationFftSize      = gMmwMssMCB.sigProcChainCfg.elevationFftSize;
        params->isStaticClutterRemovalEnabled = gMmwMssMCB.staticClutterRemovalEnable;
    
    
        gMmwMssMCB.cfarCfg.thresholdScale = (uint32_t) lroundf(pow(10, gMmwMssMCB.cfarCfg.threshold_dB/20.0) * 16.0);
    
        pHwConfig->detMatrix.data = gMmwMssMCB.detMatrix.data;    
    
        /* Allocate range profile */
        gMmwMssMCB.rangeProfile = DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                          params->numRangeBins * sizeof(uint32_t),
                                                          sizeof(uint32_t));
        if (gMmwMssMCB.rangeProfile == NULL)
        {
            retVal = DPC_OBJECTDETECTION_ENOMEM__CORE_LOCAL_RAM_RANGE_PROFILE;
            goto exit;
        }
    
        pHwConfig->rangeDopplerDetPointBitMap =  (uint32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                    sizeof(uint32_t) * ((params->numRangeBins * params->numDopplerBins + 31)>>5),
                                                                                    sizeof(uint32_t));
    
    
        gMmwMssMCB.adcStartTime         = (gMmwMssMCB.profileTimeCfg.h_ChirpAdcStartTime >> 10) * (1/gMmwMssMCB.adcSamplingRate); //us
        adcStart                        =   (gMmwMssMCB.adcStartTime * 1.e-6);
        startFreq                       =   (float)(gMmwMssMCB.startFreq * 1.e9);
        slope                           =   (float)(gMmwMssMCB.chirpSlope * 1.e12);
        bandwidth                       =   (slope * gMmwMssMCB.profileComCfg.h_NumOfAdcSamples)/(gMmwMssMCB.adcSamplingRate * 1.e6);
        centerFreq                      =   startFreq + bandwidth * 0.5f + adcStart * slope;
    
        params->rangeStep            =   (MMWDEMO_RFPARSER_SPEED_OF_LIGHT_IN_METERS_PER_SEC * (gMmwMssMCB.adcSamplingRate * 1.e6)) /
                                            (2.f * slope * (2*params->numRangeBins));
    
        gMmwMssMCB.range_step        = params->rangeStep; 
    
        if (gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame > 1)
        {
            /* Burst mode: h_NumOfBurstsInFrame > 1, h_NumOfChirpsInBurst = 2 */
            params->dopplerStep          =   MMWDEMO_RFPARSER_SPEED_OF_LIGHT_IN_METERS_PER_SEC /
                                                (2.f * params->numDopplerBins *
                                                centerFreq * (gMmwMssMCB.burstPeriod * 1e-6));
        }
        else
        {
            /* Normal mode: h_NumOfBurstsInFrame = 1, h_NumOfChirpsInBurst >= 2 */
            params->dopplerStep          =   MMWDEMO_RFPARSER_SPEED_OF_LIGHT_IN_METERS_PER_SEC /
                                                (2.f * gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst *
                                                centerFreq * ((gMmwMssMCB.profileTimeCfg.h_ChirpIdleTime + gMmwMssMCB.profileComCfg.h_ChirpRampEndTime) * 1e-1 * 1e-6));
        }
    
        gMmwMssMCB.doppler_step          = params->dopplerStep;
    
        gMmwMssMCB.antennaGeometryCfg.antDistanceXdim = 2.418;
        gMmwMssMCB.antennaGeometryCfg.antDistanceZdim = 2.418;
    
        params->lambdaOverDistX = 3e8 / (centerFreq * gMmwMssMCB.antennaGeometryCfg.antDistanceXdim);
        params->lambdaOverDistZ = 3e8 / (centerFreq * gMmwMssMCB.antennaGeometryCfg.antDistanceZdim);
    
    exit:
        return retVal;
    }
    
    void rangeProc_dpuInit()
    {
        int32_t errorCode = 0;
        DPU_RangeProcHWA_InitParams initParams;
        initParams.hwaHandle = hwaHandle;
    
        /* generate the dpu handler*/
        gMmwMssMCB.rangeProcDpuHandle = DPU_RangeProcHWA_init(&initParams, &errorCode);
        if (gMmwMssMCB.rangeProcDpuHandle == NULL)
        {
            CLI_write("Error: RangeProc DPU initialization returned error %d\n", errorCode);
            DebugP_assert(0);
            return;
        }
    }
    
    void dopplerProc_dpuInit()
    {
        int32_t  errorCode = 0;
        DPU_DopplerProcHWA_InitParams initParams;
        initParams.hwaHandle =  hwaHandle;
        /* generate the dpu handler*/
        gMmwMssMCB.dopplerProcDpuHandle =  DPU_DopplerProcHWA_init(&initParams, &errorCode);
        if (gMmwMssMCB.dopplerProcDpuHandle == NULL)
        {
            CLI_write ("Error: Doppler Proc DPU initialization returned error %d\n", errorCode);
            DebugP_assert (0);
            return;
        }
    }
    
    void aoaProc_dpuInit()
    {
        int32_t  errorCode = 0;
        DPU_AoAProcHWA_InitParams initParams;
        initParams.hwaHandle =  hwaHandle;
        /* generate the dpu handler*/
        gMmwMssMCB.aoaProcDpuHandle =  DPU_AoAProcHWA_init(&initParams, &errorCode);
        if (gMmwMssMCB.aoaProcDpuHandle == NULL)
        {
            CLI_write ("Error: AoA Proc DPU initialization returned error %d\n", errorCode);
            DebugP_assert (0);
            return;
        }
    }
    
    /**
    *  @b Description
    *  @n
    *    CFAR DPU Initialization
    */
    void cfarProc_dpuInit()
    {
        int32_t  errorCode = 0;
        DPU_CFARProcHWA_InitParams initParams;
        initParams.hwaHandle =  hwaHandle;
        /* generate the dpu handler*/
        gMmwMssMCB.cfarProcDpuHandle =  DPU_CFARProcHWA_init(&initParams, &errorCode);
        if (gMmwMssMCB.cfarProcDpuHandle == NULL)
        {
            CLI_write ("Error: CFAR Proc DPU initialization returned error %d\n", errorCode);
            DebugP_assert (0);
            return;
        }
    }
    
    void DPC_Init()
    {
        /* hwa, edma, and DPU initialization*/
    
        /* Register Frame Start Interrupt */
        if(mmwDemo_registerFrameStartInterrupt() != 0){
            CLI_write("Error: Failed to register frame start interrupts\n");
            DebugP_assert(0);
        }
    
        int32_t status = SystemP_SUCCESS;
    
        /* Shared memory pool */
        gMmwMssMCB.L3RamObj.cfg.addr = (void *)&gMmwL3[0];
        gMmwMssMCB.L3RamObj.cfg.size = sizeof(gMmwL3);
    
        /* Local memory pool */
        gMmwMssMCB.CoreLocalRamObj.cfg.addr = (void *)&gMmwCoreLocMem[0];
        gMmwMssMCB.CoreLocalRamObj.cfg.size = sizeof(gMmwCoreLocMem);
    
        /* Memory pool for the feature extraction */
        featExtract_heapConstruct();
    
        hwaHandle = HWA_open(0, NULL, &status);
        if (hwaHandle == NULL)
        {
            CLI_write("Error: Unable to open the HWA Instance err:%d\n", status);
            DebugP_assert(0);
        }
    
        rangeProc_dpuInit();
        dopplerProc_dpuInit();
        aoaProc_dpuInit();
        cfarProc_dpuInit();
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring rangeproc
    */
    void mmwDemo_rangeProcConfig()
    {
        int32_t retVal = 0;
        uint8_t numUsedHwaParamSets;
    
        retVal = RangeProc_setProfile();
        if (retVal < 0)
        {
            CLI_write("Error in setting up range profile:%d \n", retVal);
            DebugP_assert(0);
        }
    
        retVal = DPU_RangeProcHWA_config(gMmwMssMCB.rangeProcDpuHandle, &rangeProcDpuCfg);
        if (retVal < 0)
        {
            CLI_write("Error: RANGE DPU config return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
         /* Get number of used HWA param sets by this DPU */
        retVal = DPU_RangeProcHWA_GetNumUsedHwaParamSets(gMmwMssMCB.rangeProcDpuHandle, &numUsedHwaParamSets);
        if (retVal < 0)
        {
            CLI_write("Error: RANGE DPU return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Update number of used HWA param sets */
        gMmwMssMCB.numUsedHwaParamSets += numUsedHwaParamSets;
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring dopplerproc
    */
    void mmwDemo_dopplerProcConfig()
    {
        int32_t retVal = 0;
        uint8_t numUsedHwaParamSets;
    
        retVal = DopplerProc_setProfile();
        if (retVal < 0)
        {
            CLI_write("Error: Error in setting up doppler profile:%d \n", retVal);
            DebugP_assert(0);
        }
    
        retVal = DPU_DopplerProcHWA_config (gMmwMssMCB.dopplerProcDpuHandle, &dopplerProcDpuCfg);
        if (retVal < 0)
        {
            CLI_write("Doppler DPU config return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Get number of used HWA param sets by this DPU */
        retVal = DPU_DopplerProcHWA_GetNumUsedHwaParamSets(gMmwMssMCB.dopplerProcDpuHandle, &numUsedHwaParamSets);
        if (retVal < 0)
        {
            CLI_write("Doppler DPU return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Update number of used HWA param sets */
        gMmwMssMCB.numUsedHwaParamSets += numUsedHwaParamSets;
    
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring aoaproc
    */
    void mmwDemo_aoaProcConfig()
    {
        int32_t retVal = 0;
        uint8_t numUsedHwaParamSets;
    
        retVal = AoAProc_setProfile();
        if (retVal < 0)
        {
            CLI_write("Error in setting up AoA profile:%d \n", retVal);
            DebugP_assert(0);
        }
    
        retVal = DPU_AoAProcHWA_config(gMmwMssMCB.aoaProcDpuHandle, &aoaProcDpuCfg);
        if (retVal < 0)
        {
            CLI_write("AOA DPU config return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Get number of used HWA param sets by this DPU */
        retVal = DPU_AoAProcHWA_GetNumUsedHwaParamSets(gMmwMssMCB.aoaProcDpuHandle, &numUsedHwaParamSets);
        if (retVal < 0)
        {
            CLI_write("AoA DPU return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Update number of used HWA param sets */
        gMmwMssMCB.numUsedHwaParamSets += numUsedHwaParamSets;
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring CFAR DPU
    */
    void mmwDemo_cfarProcConfig()
    {
        int32_t retVal = 0;
        uint8_t numUsedHwaParamSets;
    
        retVal = CfarProc_setProfile();
        if (retVal < 0)
        {
            CLI_write("Error in setting up CFAR profile:%d \n", retVal);
            DebugP_assert(0);
        }
    
        retVal = DPU_CFARProcHWA_config(gMmwMssMCB.cfarProcDpuHandle, &cfarProcDpuCfg);
        if (retVal < 0)
        {
            CLI_write("CFAR DPU config return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Get number of used HWA param sets by this DPU */
        retVal = DPU_CFARProcHWA_GetNumUsedHwaParamSets(gMmwMssMCB.cfarProcDpuHandle, &numUsedHwaParamSets);
        if (retVal < 0)
        {
            CLI_write("CFAR DPU return error:%d \n", retVal);
            DebugP_assert(0);
        }
    
        /* Update number of used HWA param sets */
        gMmwMssMCB.numUsedHwaParamSets += numUsedHwaParamSets;
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring fetaure extraction
    */
    void featExtract_config_create()
    {   
        /* create heap */
        FeatExtract_moduleConfig config={0};// Initializing the module with 0 at the start
        int32_t errCode;
    
        // Get required parameters for configuring the feature extraction module 
        config.numRangeBins = gMmwMssMCB.numRangeBins;
        config.numDopplerBins = gMmwMssMCB.numDopplerBins;
        config.noOfPts = gMmwMssMCB.sigProcChainCfg.maxNumPoints;
        config.minNumRangeBins = gMmwMssMCB.sigProcChainCfg.minNumRangeBins;
        config.maxNumRangeBins = gMmwMssMCB.sigProcChainCfg.maxNumRangeBins;
        config.minNumDopplerBins = NUM_ZERO_DOPPLER_BINS;
        config.maxNumDopplerBins = gMmwMssMCB.numDopplerBins - NUM_ZERO_DOPPLER_BINS - 1;
        config.numFrames = NUM_FRAMES_HYBRID_METRICS;
        
        config.elev_idx = gMmwMssMCB.elev_idx;
        config.azim_idx = gMmwMssMCB.azim_idx;
        config.detMatrixMax = gMmwMssMCB.detMatrixMaxIndex;
        config.azimuthFFTSize = gMmwMssMCB.sigProcChainCfg.azimuthFftSize;
        config.elevationFFTSize = gMmwMssMCB.sigProcChainCfg.elevationFftSize;
    
        featExtractHandle = featExtract_create(&config,&errCode);
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring classifier
    */
    void algClassifier_config_create()
    {   
        /* create heap */
        Classifier_moduleConfig config={0};// Initializing the module with 0 at the start
        int32_t errCode;
    
        // Get required parameters for configuring the feature extraction module 
        config.num_classes = CLASSIFIER_NUM_CLASSES; // this demo is done initially for K2O
        config.num_features = CLASSIFIER_NUM_FEATURES;// For K2O, we have found that use of 3 features range_ave, doppler_ave, elev_wt_mean gives the best performance
        config.num_frames = CLASSIFIER_NUM_FRAMES;// This is the number of frames after which the classification starts
        config.scratchBuffer = NULL;
        config.scratchBufferSizeInBytes = 0;
    
        algClassifierHandle = classifier_create(&config,&errCode);
    }
    
    
    /**
    *  @b Description
    *  @n
    *        Function configuring DPUs
    */
    void mmwDemo_DpcConfig()
    {
        DPC_ObjDet_MemPoolReset(&gMmwMssMCB.L3RamObj);
        DPC_ObjDet_MemPoolReset(&gMmwMssMCB.CoreLocalRamObj);
        DPC_ObjDet_HwaDmaTrigSrcChanPoolReset(&gMmwMssMCB.HwaDmaChanPoolObj);
    
    if(gMmwMssMCB.presence_detected)
    {
        /* Allocate memory for storing the max 'n' values from detection matrix and associated values*/
        gMmwMssMCB.rangeGatesCount = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(uint16_t), sizeof(uint16_t));
    
        gMmwMssMCB.range_idx_arr = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.numRangeBins*sizeof(uint16_t),
                                                             sizeof(uint16_t));
    
        gMmwMssMCB.range_idx = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.numRangeBins*sizeof(uint16_t),
                                                             sizeof(uint16_t));
    
        gMmwMssMCB.angle_idx_doppler_count_arr = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.numRangeBins*sizeof(uint16_t),
                                                             sizeof(uint16_t));
    
        gMmwMssMCB.angle_idx_doppler_count = (uint16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.numRangeBins*sizeof(uint16_t),
                                                             sizeof(uint16_t));
        
        gMmwMssMCB.doppler_idx_arr =  (int16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.sigProcChainCfg.maxNumPoints*gMmwMssMCB.numRangeBins*sizeof(uint16_t),
                                                             sizeof(uint16_t));
    
        gMmwMssMCB.antenna_array = (cmplx32ImRe_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             NUM_AZIMUTH_ELEMENTS*NUM_ELEVATION_ELEMENTS*sizeof(cmplx32ImRe_t),
                                                             sizeof(uint32_t));
    
        gMmwMssMCB.elev_idx = (int16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(int16_t),
                                                             sizeof(int16_t));
    
        gMmwMssMCB.azim_idx = (int16_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(int16_t),
                                                             sizeof(int16_t));
    
        gMmwMssMCB.detMatrixMaxIndex = (uint32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(uint32_t),
                                                             sizeof(uint32_t));
    
        gMmwMssMCB.featOutput = (FeatExtract_featOutput *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(FeatExtract_featOutput),
                                                             sizeof(float)));
    
        gMmwMssMCB.classifierInput = (float *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(float)*CLASSIFIER_NUM_FEATURES*CLASSIFIER_NUM_FRAMES,
                                                             sizeof(float)));
    
        gMmwMssMCB.classifierProbability = (float *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(float)*CLASSIFIER_NUM_CLASSES,
                                                             sizeof(float)));
        
        gMmwMssMCB.classifierMatrix = (uint8_t *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(uint8_t)*NUM_FRAMES_POSTPROC*CLASSIFIER_NUM_CLASSES,
                                                             sizeof(uint8_t)));
        
        gMmwMssMCB.classifierOutput = (uint8_t *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(uint8_t),
                                                             sizeof(uint8_t)));
    
        gMmwMssMCB.classifierPrevOutput = (uint8_t *)(DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                             sizeof(uint8_t),
                                                             sizeof(uint8_t)));
        if(gMmwMssMCB.pointCloudEnabled)
        {
            /*Allocate memory for CFAR Range/Doppler detection output*/
            gMmwMssMCB.detRngDopList = (DPIF_CFARRngDopDetListElement *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                            gMmwMssMCB.sigProcChainCfg.maxNumPoints * sizeof(DPIF_CFARRngDopDetListElement),
                                                                                            sizeof(uint32_t));
            if (gMmwMssMCB.detRngDopList == NULL)
            {
                CLI_write("DPC configuration: memory allocation failed\n");
                DebugP_assert(0);
            }
    
            /*Allocate memory for point cloud */
            gMmwMssMCB.aoaDetObjOutCartesian = (DPIF_PointCloudCartesianExt *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                            gMmwMssMCB.sigProcChainCfg.maxNumPoints * sizeof(DPIF_PointCloudCartesianExt),
                                                                                            sizeof(uint32_t));
            
            gMmwMssMCB.aoaDetObjOutSpherical = (DPIF_PointCloudSpherical *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                           gMmwMssMCB.sigProcChainCfg.maxNumPoints * sizeof(DPIF_PointCloudSpherical),
                                                                                           sizeof(uint32_t));
            if(gMmwMssMCB.enableMinorMotion)
            {
                gMmwMssMCB.minorMotObjOut = (DPIF_PointCloudCartesian *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                            gMmwMssMCB.sigProcChainCfg.maxNumPoints * sizeof(DPIF_PointCloudCartesian),
                                                                                            sizeof(uint32_t));
    
                /*Allocate memory for CFAR Range/Doppler detection output for minor motion*/
                gMmwMssMCB.detRngDopListMinor = (DPIF_CFARRngDopDetListElement *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,
                                                                                                gMmwMssMCB.sigProcChainCfg.maxNumPoints * sizeof(DPIF_CFARRngDopDetListElement),
                                                                                                sizeof(uint32_t));
                if (gMmwMssMCB.detRngDopListMinor == NULL)
                {
                    CLI_write("DPC configuration: memory allocation failed\n");
                    DebugP_assert(0);
                }
    
                gMmwMssMCB.paramAddrStore = (uint32_t *)DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.CoreLocalRamObj,sizeof(uint32_t),sizeof(uint32_t));
            }     
        }
    }
        gMmwMssMCB.numUsedHwaParamSets = 0;
        /* Configure DPUs */
        mmwDemo_rangeProcConfig();
        mmwDemo_dopplerProcConfig();
    if(gMmwMssMCB.presence_detected)
    {
        mmwDemo_aoaProcConfig();
        /* Configure the CFAR DPU if point cloud is enabled*/
        if(gMmwMssMCB.pointCloudEnabled)
            mmwDemo_cfarProcConfig();
        /* Configure the HWA and EDMA for minor motion if enabled*/
        if(gMmwMssMCB.enableMinorMotion)
            minorMotionRangeDopp_config();
        /* Configure the feature extraction and create the module */
        maxOfDetectionMatrix_config();
        featExtract_config_create();
        /* Configure the neural network classifier and create the module */
        algClassifier_config_create();
    }
    
        if (!gMmwMssMCB.oneTimeConfigDone)
        {
    
            /* Report RAM usage */
            gMmwMssMCB.memUsage.CoreLocalRamUsage = DPC_ObjDet_MemPoolGetMaxUsage(&gMmwMssMCB.CoreLocalRamObj);
            gMmwMssMCB.memUsage.L3RamUsage = DPC_ObjDet_MemPoolGetMaxUsage(&gMmwMssMCB.L3RamObj);
    
            gMmwMssMCB.memUsage.L3RamTotal = gMmwMssMCB.L3RamObj.cfg.size;
            gMmwMssMCB.memUsage.CoreLocalRamTotal = gMmwMssMCB.CoreLocalRamObj.cfg.size;
        
            if(gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_DISABLE)
            {
                DebugP_log(" ========== Memory Stats ==========\n");
                DebugP_log("%20s %12s %12s %12s\n", " ", "Size", "Used", "Free");
    
                DebugP_log("%20s %12d %12d %12d\n", "L3",
                          sizeof(gMmwL3),
                          gMmwMssMCB.memUsage.L3RamUsage,
                          sizeof(gMmwL3) - gMmwMssMCB.memUsage.L3RamUsage);
    
                DebugP_log("%20s %12d %12d %12d\n", "Local",
                          sizeof(gMmwCoreLocMem),
                          gMmwMssMCB.memUsage.CoreLocalRamUsage,
                          sizeof(gMmwCoreLocMem) - gMmwMssMCB.memUsage.CoreLocalRamUsage);
                DebugP_log("%20s %12d %12d %12d\n", "FeatExt",
                          sizeof(gMmwCoreLocMem2),
                          featExtract_memUsage(),
                          sizeof(gMmwCoreLocMem2) - featExtract_memUsage());
            }
        }
    }
    
    void mmw_UartWrite (UART_Handle handle,
                        uint8_t *payload,
                        uint32_t payloadLength)
    {
    #if 0
        UART_Transaction trans;
    
        UART_Transaction_init(&trans);
    
        trans.buf   = payload;
        trans.count = payloadLength;
    
        UART_write(handle, &trans);
    #endif
    }
    
    
    #ifndef INA228
    void mmwDemo_PM_Null(I2C_Handle i2cHandle, uint16_t *ptrPwrMeasured)
    {
        ptrPwrMeasured[0] = (uint16_t)0xFFFF;
        ptrPwrMeasured[1] = (uint16_t)0xFFFF;
        ptrPwrMeasured[2] = (uint16_t)0xFFFF;
        ptrPwrMeasured[3] = (uint16_t)0xFFFF;
    }
    #endif
    
    #define PARAMSET_JUMP 32
    #define PARAMSET_ROWJUMP 4
    #define CSL_APP_HWA_PARAM_BASE (0x55014000U)
    #define PARAMSET_ADDR(regAddr, paramsetIdx, row) ((regAddr)=(uint32_t *)(CSL_APP_HWA_PARAM_BASE+paramsetIdx*PARAMSET_JUMP+row*PARAMSET_ROWJUMP))
    #define DOPPLER_FFT_PING_PARAMSET1 2
    #define DOPPLER_FFT_PING_PARAMSET2 3
    #define DOPPLER_FFT_PONG_PARAMSET1 6
    #define DOPPLER_FFT_PONG_PARAMSET2 7
    
    #define ABS_SUM_PING_PARAMSET1 4
    #define ABS_SUM_PING_PARAMSET2 5
    #define ABS_SUM_PONG_PARAMSET1 8
    #define ABS_SUM_PONG_PARAMSET2 9
    
    #define DOPPLER_FFT_PING_AOAPARAMSET 10
    #define DOPPLER_FFT_PONG_AOAPARAMSET 13
    #define DOPPLER_COMP_PING_PARAMSET1  11
    #define DOPPLER_COMP_PING_PARAMSET2  12
    #define DOPPLER_COMP_PONG_PARAMSET1  14
    #define DOPPLER_COMP_PONG_PARAMSET2  15
    
    /* For the below, refer to HWA paramset layout register arrangement */
    #define WIN_ACCELMODE_ROW 0
    #define SRCDST_ADDR_ROW 1
    #define SRCDST_ACNT_ROW 2
    #define BCNT_ROW 5
    #define FFTSIZE_ROW 6 
    
    /*Inherited EDMA paramset setting function*/
    void EDMADmaSetPaRAMEntry2(uint32_t baseAddr,
                                uint32_t paRAMId,
                                uint32_t paRAMEntry,
                                uint32_t newPaRAMEntryVal)
    {   
        uint32_t *paRAMEntryAddr;
        if (paRAMEntry <= EDMACC_PARAM_ENTRY_CCNT)
        {
            paRAMEntryAddr=(uint32_t *)(baseAddr + EDMA_TPCC_OPT(paRAMId) + (paRAMEntry * 0x04U));
            CSL_FINSR(paRAMEntryAddr[0],31,16,newPaRAMEntryVal);
        }
    }
    
    /* Function to set destination address in HWA paramset */
    void setDst_addr(uint32_t *reg, uint32_t addr)
    {   
        volatile uint32_t Address = reg[0] & 0x0000FFFF;
        reg[0] = 0x0U;
        reg[0] |= (addr<<16);
        reg[0] |= Address;
    }
    /* Function to set source address in HWA paramset */
    void setSrc_addr(uint32_t *reg, uint32_t addr)
    {   
        volatile uint32_t Address = reg[0] & 0xFFFF0000;
        reg[0] = 0x0U;
        reg[0] |= addr;
        reg[0] |= Address;
    }
    /* Function to switch HWA/EDMA paramsets to major motion for Doppler DPU */
    void paramSwitchMinorToMajorDopplerDPU()
    {   
        uint32_t baseAddr, regionId;
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
        /******************************************************************************************Doppler DPU changes ***************************************************************************************/
        /****************************************************************************************************************************************************************************************************/
        /************************************************ EDMA Paramset changes **********************************************/
        /******* EDMA In for doppler FFT ******/
        //Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[0]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[0]));
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[2*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[2*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
    
        /******* EDMA Out for Detection Matrix ******/
        //Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrix.data[0]));//Starting of detection matrix base address
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrix.data[0]));//Starting of detection matrix base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBins));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBins));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBins * sizeof(uint32_t)));
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBins * sizeof(uint32_t)));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrix.data[0])+2*gMmwMssMCB.numDopplerBins*sizeof(uint32_t));//Jump by two doppler bins, base address for Pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBins));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBins * sizeof(uint32_t)));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrix.data[0])+2*gMmwMssMCB.numDopplerBins*sizeof(uint32_t));//Jump by two doppler bins, base address for Pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBins));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBins * sizeof(uint32_t)));
    
        /************************************************ HWA Paramset changes **********************************************/
        /***Change 1st range bin's Doppler FFT paramset (Ping)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
    
        /***Change 2nd range bin's Doppler FFT paramset (Ping)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
        // Set to DST Addr with offset for 2nd range gate after 1st range gate for major motion
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,SRCDST_ADDR_ROW);
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK1_BASE)+gMmwMssMCB.numDopplerBins*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
    
        /***Change 1st range bin's Sum Abs paramset (Ping)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET1,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBins-1);
    
        /***Change 2nd range bin's Sum Abs paramset (Ping)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET2,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBins-1);
        // Set the Source Address
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET2,SRCDST_ADDR_ROW);
        setSrc_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK1_BASE)+gMmwMssMCB.numDopplerBins*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
        // Set the Destination Address
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK0_BASE)+gMmwMssMCB.numDopplerBins*sizeof(uint64_t)));
    
    
        /***Change 1st range bin's Doppler FFT paramset (Pong)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
    
        /***Change 2nd range bin's Doppler FFT paramset (Pong)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
        // Set to DST Addr with offset for 2nd range gate after 1st range gate for major motion
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,SRCDST_ADDR_ROW);
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK3_BASE)+gMmwMssMCB.numDopplerBins*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
    
        /***Change 1st range bin's Sum Abs paramset (Pong)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET1,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBins-1);
    
        /***Change 2nd range bin's Sum Abs paramset (Pong)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET2,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBins-1);
        // Set the Source Address
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET2,SRCDST_ADDR_ROW);
        setSrc_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK3_BASE)+gMmwMssMCB.numDopplerBins*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
        // Set the Destination Address
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK2_BASE)+gMmwMssMCB.numDopplerBins*sizeof(uint64_t)));
    
        flagMinorToMajorDopp = 1;
    }
    
    /* Function to switch HWA/EDMA paramsets to major motion for AoA DPU */
    void paramSwitchMinorToMajorAoADPU()
    {   
        uint32_t baseAddr, regionId;
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
        /******************************************************************************************AoA DPU changes *******************************************************************************************/
        /****************************************************************************************************************************************************************************************************/
        /************************************************ EDMA Paramset changes **********************************************/
        /******* EDMA In for doppler FFT recalculation (AoA) ******/
        ///Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[gMmwMssMCB.range_idx_arr[0]*sizeof(uint32_t)]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[gMmwMssMCB.range_idx_arr[0]*sizeof(uint32_t)]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[gMmwMssMCB.range_idx_arr[1]*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[0].data[gMmwMssMCB.range_idx_arr[1]*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirps * gMmwMssMCB.numTxAntennas));
    
        /************************************************ HWA Paramset changes **********************************************/
        
        /***Change range bin's Doppler FFT paramset AoA (Ping)***/
        gMmwMssMCB.isDopplerPhaseCompensationEnabled[0]=1;//Enable Doppler Phase Compensation in major motion 
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
    
        /***Change range bin's Doppler FFT paramset AoA (Pong)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,1);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirps-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBins-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBins);
    
        /***Change to Doppler Compensation enabled for Major motion (Ping/Pong)***/
        // Change from dummy to FFT mode    
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PING_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_FFT);
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PING_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_FFT);
    
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PONG_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_FFT);
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PONG_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_FFT);
    
        flagMinorToMajorAoA = 1;
    }
    /* Function to switch HWA/EDMA paramsets to minor motion for Doppler DPU */
    void paramSwitchMajorToMinorDopplerDPU()
    {   
        uint32_t baseAddr, regionId;
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
        /******************************************************************************************Doppler DPU changes ***************************************************************************************/
        /****************************************************************************************************************************************************************************************************/
        /************************************************ EDMA Paramset changes **********************************************/
        /******* EDMA In for doppler FFT ******/
        //Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[0]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[0]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[2*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_CH_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[2*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAIN_SHADOW_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
    
        /******* EDMA Out for Detection Matrix ******/
        //Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrixMinorMot.data[0]));//Starting of detection matrix base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBinsMinorMot));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_CH, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBinsMinorMot * sizeof(uint32_t)));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrixMinorMot.data[0]));//Starting of detection matrix base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBinsMinorMot));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PING_SHADOW, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBinsMinorMot * sizeof(uint32_t)));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrixMinorMot.data[0])+2*gMmwMssMCB.numDopplerBinsMinorMot*sizeof(uint32_t));//Jump by two doppler bins, base address for Pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBinsMinorMot));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_CH, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBinsMinorMot * sizeof(uint32_t)));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_DST, (uint32_t)SOC_virtToPhy(&gMmwMssMCB.detMatrixMinorMot.data[0])+2*gMmwMssMCB.numDopplerBinsMinorMot*sizeof(uint32_t));//Jump by two doppler bins, base address for Pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(2 * gMmwMssMCB.numDopplerBinsMinorMot));//As we take 2-range gates per ping/pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_DOPPLERPROC_EDMAOUT_DETMATRIX_PONG_SHADOW, EDMACC_PARAM_ENTRY_SRC_DST_CIDX, (uint16_t)(4 * gMmwMssMCB.numDopplerBinsMinorMot * sizeof(uint32_t)));
    
        /************************************************ HWA Paramset changes **********************************************/
        /***Change 1st range bin's Doppler FFT paramset (Ping)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to minor motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to minor motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET1,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
    
        /***Change 2nd range bin's Doppler FFT paramset (Ping)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to minor motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to minor motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
        // Set to DST Addr with offset for 2nd range gate after 1st range gate for major motion
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_PARAMSET2,SRCDST_ADDR_ROW);
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK1_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
    
        /***Change 1st range bin's Sum Abs paramset (Ping)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET1,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBinsMinorMot-1);
    
        /***Change 2nd range bin's Sum Abs paramset (Ping)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET2,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set the Source Address
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PING_PARAMSET2,SRCDST_ADDR_ROW);
        setSrc_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK1_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
        // Set the Destination Address
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK0_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*sizeof(uint64_t)));
    
    
        /***Change 1st range bin's Doppler FFT paramset (Pong)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET1,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
    
        /***Change 2nd range bin's Doppler FFT paramset (Pong)***/
        // Disable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to minor motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to minor motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
        // Set to DST Addr with offset for 2nd range gate after 1st range gate for major motion
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_PARAMSET2,SRCDST_ADDR_ROW);
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK3_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
    
        /***Change 1st range bin's Sum Abs paramset (Pong)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET1,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBinsMinorMot-1);
    
        /***Change 2nd range bin's Sum Abs paramset (Pong)***/
        // Change Bcnt
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET2,BCNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set the Source Address
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,ABS_SUM_PONG_PARAMSET2,SRCDST_ADDR_ROW);
        setSrc_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK3_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*gMmwMssMCB.numVirtualAntennas*sizeof(uint64_t)));
        // Set the Destination Address
        setDst_addr(gMmwMssMCB.paramAddrStore,(HWADRV_ADDR_TRANSLATE_CPU_TO_HWA(CSL_APP_HWA_DMA0_RAM_BANK2_BASE)+gMmwMssMCB.numDopplerBinsMinorMot*sizeof(uint64_t)));
    
        flagMajorToMinorDopp = 1;
    }
    /* Function to switch HWA/EDMA paramsets to major motion for AoA DPU */
    void paramSwitchMajorToMinorAoADPU()
    {   
        uint32_t baseAddr, regionId;
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
        /******************************************************************************************AoA DPU changes *******************************************************************************************/
        /****************************************************************************************************************************************************************************************************/
        /************************************************ EDMA Paramset changes **********************************************/
        /******* EDMA In for doppler FFT recalculation (AoA) ******/
        ///Ping Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[gMmwMssMCB.range_idx_arr[0]*sizeof(uint32_t)]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PING, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[gMmwMssMCB.range_idx_arr[0]*sizeof(uint32_t)]));//Starting of radar cube base address
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PING, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        //Pong Paramsets
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[gMmwMssMCB.range_idx_arr[1]*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_CH_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
        EDMADmaSetPaRAMEntry(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PONG, EDMACC_PARAM_ENTRY_SRC, (uint32_t)(&gMmwMssMCB.radarCube[1].data[gMmwMssMCB.range_idx_arr[1]*sizeof(uint32_t)]));//As we take 2 range gates, jump by 2 x 4 = 8bytes, base address for pong
        EDMADmaSetPaRAMEntry2(baseAddr, DPC_OBJDET_DPU_AOAPROC_EDMAIN_DOPPLER_SHADOW_PONG, EDMACC_PARAM_ENTRY_ACNT_BCNT, (uint16_t)(gMmwMssMCB.numRxAntennas * gMmwMssMCB.numDopplerChirpsMinorMot * gMmwMssMCB.numTxAntennas));
    
        /************************************************ HWA Paramset changes **********************************************/
        
        /***Change range bin's Doppler FFT paramset AoA (Ping)***/
        gMmwMssMCB.isDopplerPhaseCompensationEnabled[0]=0;//Enable Doppler Phase Compensation in major motion 
        // Diasble Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to minor motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to minor motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PING_AOAPARAMSET,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
    
        /***Change range bin's Doppler FFT paramset AoA (Pong)***/
        // Enable Window
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],15,15,0);
        // Set to major motion chirps and doppler bin values
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,SRCDST_ACNT_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],11,0,gMmwMssMCB.numDopplerChirpsMinorMot-1);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],27,16,gMmwMssMCB.numDopplerBinsMinorMot-1);
        // Set to major motion FFT size value in doppler
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_FFT_PONG_AOAPARAMSET,FFTSIZE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],5,2,gMmwMssMCB.log2numDopplerBinsMinorMot);
    
        /***Change to Doppler Compensation disbled for Minor motion (Ping/Pong)***/
        // Change from dummy to FFT mode    
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PING_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_NONE);
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PING_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_NONE);
    
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PONG_PARAMSET1,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_NONE);
        PARAMSET_ADDR(gMmwMssMCB.paramAddrStore,DOPPLER_COMP_PONG_PARAMSET2,WIN_ACCELMODE_ROW);
        CSL_FINSR(gMmwMssMCB.paramAddrStore[0],23,21,HWA_ACCELMODE_NONE);
    
        flagMajorToMinorAoA = 1;
    }
    
    /** @brief Transmits detection data over UART 
    *
    *    The following data is transmitted:
    *    1. Header (size = 32bytes), including "Magic word", (size = 8 bytes)
    *       and including the number of TLV items
    *    TLV Items:
    *    2. Feature Vectors calculated for heatmap and angle related and hybrid metric features
    *    3. Gesture detected
    *    4. The stats information, timing, temperature and power
    *    5. In presence mode sum across range bins of 1st doppler bin, presence detected or not
    *    6. x,y,z point cloud of major motion
    *    7. Spherical point cloud of major motion
    *    8. x,y,z point cloud of minor motion
    */
    void mmwDemo_TransmitProcessedOutputTask()
    {
        UART_Handle uartHandle = gUartHandle[0];
        I2C_Handle  i2cHandle = gI2cHandle[CONFIG_I2C0];
        MmwDemo_output_message_header header;
        uint32_t tlvIdx = 0;
        uint32_t numPaddingBytes;
        uint32_t packetLen;
        uint8_t padding[MMWDEMO_OUTPUT_MSG_SEGMENT_LEN]={0};
        MmwDemo_output_message_tl   tl[MMWDEMO_OUTPUT_ALL_MSG_MAX];
    
        while(true)
        {
            SemaphoreP_pend(&gMmwMssMCB.tlvSemHandle, SystemP_WAIT_FOREVER);
    
            tlvIdx = 0;
    
            /* Clear message header */
            memset((void *)&header, 0, sizeof(MmwDemo_output_message_header));
            /* Header: */
            #ifdef SOC_XWRL64XX
                header.platform =  0xA6432;
            #elif SOC_XWRL14XX
                header.platform =  0xA1432;
            #endif
            header.magicWord[0] = 0x0102;
            header.magicWord[1] = 0x0304;
            header.magicWord[2] = 0x0506;
            header.magicWord[3] = 0x0708;
            //header.numDetectedObj = result->numObjOut;
            header.version =    MMWAVE_SDK_VERSION_BUILD |   //DEBUG_VERSION
                                (MMWAVE_SDK_VERSION_BUGFIX << 8) |
                                (MMWAVE_SDK_VERSION_MINOR << 16) |
                                (MMWAVE_SDK_VERSION_MAJOR << 24);
    
            packetLen = sizeof(MmwDemo_output_message_header);
            if(gMmwMssMCB.presenceDetectCfg.presenceDetectMode)
            {
                if(gMmwMssMCB.presence_detected)
                {   
                    if(gMmwMssMCB.guiMonSel.RDFeatures)
                    {  
                        /* Send via Uart the computed features */
                        tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_RANGE_DOPPLER_FEATURES;
                        tl[tlvIdx].length = sizeof(FeatExtract_featOutput);
                        packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                        tlvIdx++;
                    }
                    /* Send via Uart the classifier output */
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_CLASSIFIER_OUTPUT;
                    tl[tlvIdx].length = sizeof(uint8_t);
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
    
                    if((gMmwMssMCB.dpcResult.numObjOut>0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled)
                    {   /* Send via Uart the point cloud output (major motion) */
                        tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_CARTESIAN;
                        tl[tlvIdx].length = sizeof(DPIF_PointCloudCartesianExt)*gMmwMssMCB.dpcResult.numObjOut;
                        packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                        tlvIdx++;
                    }
                    if((gMmwMssMCB.dpcResult.numObjOutMinor>0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled && gMmwMssMCB.enableMinorMotion)
                    {   /* Send via Uart the point cloud output (minor motion) */
                        tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_MINOR;
                        tl[tlvIdx].length = sizeof(DPIF_PointCloudCartesian)*gMmwMssMCB.dpcResult.numObjOutMinor;
                        packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                        tlvIdx++;
                    }
                    
                    if((gMmwMssMCB.dpcResult.numObjOut>0) && gMmwMssMCB.guiMonSel.pointCloudSpherical && gMmwMssMCB.pointCloudEnabled)
                    {   /* Send via Uart the point cloud output (major motion spherical coordinates) */
                        tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_SPHERICAL;
                        tl[tlvIdx].length = sizeof(DPIF_PointCloudSpherical)*gMmwMssMCB.dpcResult.numObjOut;
                        packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                        tlvIdx++;
                    }
                }
                /* Send presence output via uart*/
                tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_PRESENCE_OUTPUT;
                tl[tlvIdx].length = sizeof(uint8_t);
                packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                tlvIdx++;
    
                if(gMmwMssMCB.guiMonSel.statsInfo)
                {   /* Send stats info via uart*/
                    memcpy((void*)gMmwMssMCB.outStats.tempReading, &tempStats.tempValue, (4 * sizeof(int16_t)));
                    #ifdef INA228
                    mmwDemo_PowerMeasurement(i2cHandle, &gMmwMssMCB.outStats.powerMeasured[0]);
                    #else
                    mmwDemo_PM_Null(i2cHandle, &gMmwMssMCB.outStats.powerMeasured[0]);
                    #endif
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_MSG_STATS;
                    tl[tlvIdx].length = sizeof(MmwDemo_output_message_stats);
                    packetLen += sizeof(MmwDemo_output_message_tl) +  tl[tlvIdx].length;
                    tlvIdx++;
                }
    
                if(!flagPresenceDetect)
                {
                    /* Send via Uart the detection threshold */
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_PRESENCE_DETECT_THRESHOLD;
                    tl[tlvIdx].length = sizeof(uint32_t);
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
                }
    
                /* Fill header */
                header.numTLVs = tlvIdx;
                /* Round up packet length to multiple of MMWDEMO_OUTPUT_MSG_SEGMENT_LEN */
                header.totalPacketLen = MMWDEMO_OUTPUT_MSG_SEGMENT_LEN *
                        ((packetLen + (MMWDEMO_OUTPUT_MSG_SEGMENT_LEN-1))/MMWDEMO_OUTPUT_MSG_SEGMENT_LEN);
                header.timeCpuCycles =  0; //TODO: Populate with actual time
                header.frameNumber = gMmwDemoFrameCnt++; //result->stats->frameStartIntCounter
                header.subFrameNumber = -1;
    
                if(tlvIdx != 0)
                {
                    mmw_UartWrite (uartHandle, (uint8_t*)&header, sizeof(MmwDemo_output_message_header));
                    tlvIdx = 0;
                }
    
                if(gMmwMssMCB.presence_detected)
                {   
                    if(gMmwMssMCB.guiMonSel.RDFeatures)
                    {  
                        /*Send array of features computed */
                        mmw_UartWrite (uartHandle,
                                        (uint8_t*)&tl[tlvIdx],
                                        sizeof(MmwDemo_output_message_tl));
                        mmw_UartWrite (uartHandle, (uint8_t *)&gMmwMssMCB.featOutput->rangeAvg,
                                        sizeof(FeatExtract_featOutput));
                        tlvIdx++;
                    }
    
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
                    /*Send the classifier output */
                    mmw_UartWrite (uartHandle, (uint8_t *)&gMmwMssMCB.classifierOutput[0],
                                    sizeof(uint8_t));
                    tlvIdx++;
    
                    gMmwDemoFrameCntGesture++;
                    gestureToPresenceSwitchCntr++;
    
                    /* Send detected Objects Cartesian Coordinates (of major motion)*/
                    if ((gMmwMssMCB.dpcResult.numObjOut) > 0 && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled)
                    {
                        mmw_UartWrite (uartHandle,
                                        (uint8_t*)&tl[tlvIdx],
                                        sizeof(MmwDemo_output_message_tl));
    
                        /*Send array of objects */
                        mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.aoaDetObjOutCartesian->x,
                                        sizeof(DPIF_PointCloudCartesianExt) * gMmwMssMCB.dpcResult.numObjOut);
                        tlvIdx++;
                    }
    
                    if(gMmwMssMCB.enableMinorMotion && (gMmwMssMCB.dpcResult.numObjOutMinor > 0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled)  
                    {/* Send detected Objects Cartesian Coordinates (of minor motion)*/
                        mmw_UartWrite (uartHandle,
                                        (uint8_t*)&tl[tlvIdx],
                                        sizeof(MmwDemo_output_message_tl));
    
                        /*Send array of objects */
                        mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.minorMotObjOut->x,
                                        sizeof(DPIF_PointCloudCartesian) * gMmwMssMCB.dpcResult.numObjOutMinor);
                        tlvIdx++;
                    }   
    
                    /* Send detected Objects Spherical Coordinates*/
                    if (gMmwMssMCB.dpcResult.numObjOut > 0 && gMmwMssMCB.guiMonSel.pointCloudSpherical && gMmwMssMCB.pointCloudEnabled)
                    {
                        mmw_UartWrite (uartHandle,
                                        (uint8_t*)&tl[tlvIdx],
                                        sizeof(MmwDemo_output_message_tl));
    
                        /*Send array of objects */
                        mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.aoaDetObjOutSpherical->range,
                                        sizeof(DPIF_PointCloudSpherical) * gMmwMssMCB.dpcResult.numObjOut);
                        tlvIdx++;
                    }
                }
    
                /* Send presence output via UART */
                mmw_UartWrite (uartHandle,
                                (uint8_t*)&tl[tlvIdx],
                                sizeof(MmwDemo_output_message_tl));
    
                mmw_UartWrite (uartHandle,
                                (uint8_t*) &gMmwMssMCB.presence_detected,
                                tl[tlvIdx].length);
                tlvIdx++;
    
                if(gMmwMssMCB.guiMonSel.statsInfo)
                {
                    /* Send stats information (interframe processing time and uart transfer time) */
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*) &gMmwMssMCB.outStats,
                                    tl[tlvIdx].length);
                    tlvIdx++;
                }
    
                if(!flagPresenceDetect)
                {
                    /* Send Presence detection threshold information */
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*) &gMmwMssMCB.presence_sumMagnitudeRangeBins,
                                    tl[tlvIdx].length);
                    tlvIdx++;
                    gMmwMssMCB.presence_sumMagnitudeRangeBins = 0;
                    gMmwDemoFrameCntPresence++;
                }
            }
            else
            {   
                if(gMmwMssMCB.guiMonSel.RDFeatures)
                {
                    /* Send via Uart the computed features */
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_RANGE_DOPPLER_FEATURES;
                    tl[tlvIdx].length = sizeof(FeatExtract_featOutput);
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
                }
                
                /* Send via Uart the classifier output*/
                tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_CLASSIFIER_OUTPUT;
                tl[tlvIdx].length = sizeof(uint8_t);
                packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                tlvIdx++;
    
                if((gMmwMssMCB.dpcResult.numObjOut>0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled)
                {   /* Send via Uart the major motion point cloud */
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_CARTESIAN;
                    tl[tlvIdx].length = sizeof(DPIF_PointCloudCartesianExt)*gMmwMssMCB.dpcResult.numObjOut;
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
                }
    
                if((gMmwMssMCB.dpcResult.numObjOutMinor>0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled && gMmwMssMCB.enableMinorMotion)
                {   /* Send via Uart the minor motion point cloud */
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_MINOR;
                    tl[tlvIdx].length = sizeof(DPIF_PointCloudCartesian)*gMmwMssMCB.dpcResult.numObjOutMinor;
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
                }
                
                if((gMmwMssMCB.dpcResult.numObjOut>0) && gMmwMssMCB.guiMonSel.pointCloudSpherical && gMmwMssMCB.pointCloudEnabled)
                {   /* Send via Uart the major motion point cloud (cylindrical coordinates)*/
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_POINT_CLOUD_SPHERICAL;
                    tl[tlvIdx].length = sizeof(DPIF_PointCloudSpherical)*gMmwMssMCB.dpcResult.numObjOut;
                    packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                    tlvIdx++;
                }
    
                // tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_RANGE_DOPPLER_MAP;
                // tl[tlvIdx].length = gMmwMssMCB.numDopplerBins*gMmwMssMCB.numRangeBins*sizeof(uint32_t);
                // packetLen += sizeof(MmwDemo_output_message_tl) + tl[tlvIdx].length;
                // tlvIdx++;
    
                if(gMmwMssMCB.guiMonSel.statsInfo)
                {   /* Send via Uart the stats info */
                    memcpy((void*)gMmwMssMCB.outStats.tempReading, &tempStats.tempValue, (4 * sizeof(int16_t)));
                    #ifdef INA228
                    mmwDemo_PowerMeasurement(i2cHandle, &gMmwMssMCB.outStats.powerMeasured[0]);
                    #else
                    mmwDemo_PM_Null(i2cHandle, &gMmwMssMCB.outStats.powerMeasured[0]);
                    #endif
                    tl[tlvIdx].type = MMWDEMO_OUTPUT_EXT_MSG_STATS;
                    tl[tlvIdx].length = sizeof(MmwDemo_output_message_stats);
                    packetLen += sizeof(MmwDemo_output_message_tl) +  tl[tlvIdx].length;
                    tlvIdx++;
                }
    
                /* Fill header */
                header.numTLVs = tlvIdx;
                /* Round up packet length to multiple of MMWDEMO_OUTPUT_MSG_SEGMENT_LEN */
                header.totalPacketLen = MMWDEMO_OUTPUT_MSG_SEGMENT_LEN *
                        ((packetLen + (MMWDEMO_OUTPUT_MSG_SEGMENT_LEN-1))/MMWDEMO_OUTPUT_MSG_SEGMENT_LEN);
                header.timeCpuCycles =  0; //TODO: Populate with actual time
                header.frameNumber = gMmwDemoFrameCnt++; //result->stats->frameStartIntCounter
                header.subFrameNumber = -1;
    
                if(tlvIdx != 0)
                {
                    mmw_UartWrite (uartHandle, (uint8_t*)&header, sizeof(MmwDemo_output_message_header));
                    tlvIdx = 0;
                }
                if(gMmwMssMCB.guiMonSel.RDFeatures)
                {
                    /*Send array of features computed */
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
                    mmw_UartWrite (uartHandle, (uint8_t *)&gMmwMssMCB.featOutput->rangeAvg,
                                    sizeof(FeatExtract_featOutput));
                    tlvIdx++;
                }
    
                mmw_UartWrite (uartHandle,
                                (uint8_t*)&tl[tlvIdx],
                                sizeof(MmwDemo_output_message_tl));
                /*Send the classifier output */
                mmw_UartWrite (uartHandle, (uint8_t *)&gMmwMssMCB.classifierOutput[0],
                                sizeof(uint8_t));
                tlvIdx++;
    
                gMmwDemoFrameCntGesture++;
    
                /* Send detected Objects Cartesian (major motion)*/
                if (gMmwMssMCB.dpcResult.numObjOut > 0 && gMmwMssMCB.guiMonSel.pointCloud)
                {
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    /*Send array of objects */
                    mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.aoaDetObjOutCartesian->x,
                                    sizeof(DPIF_PointCloudCartesianExt) * gMmwMssMCB.dpcResult.numObjOut);
                    tlvIdx++;
                }
    
                if(gMmwMssMCB.enableMinorMotion && (gMmwMssMCB.dpcResult.numObjOutMinor > 0) && gMmwMssMCB.guiMonSel.pointCloud && gMmwMssMCB.pointCloudEnabled)  
                {   /* Send detected Objects Cartesian (minor motion)*/
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    /*Send array of objects */
                    mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.minorMotObjOut->x,
                                    sizeof(DPIF_PointCloudCartesian) * gMmwMssMCB.dpcResult.numObjOutMinor);
                    tlvIdx++;
                }          
    
                /* Send detected Objects Spherical (major motion)*/
                if ((gMmwMssMCB.dpcResult.numObjOut > 0) && gMmwMssMCB.guiMonSel.pointCloudSpherical)
                {
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    /*Send array of objects */
                    mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.aoaDetObjOutSpherical->range,
                                    sizeof(DPIF_PointCloudSpherical) * gMmwMssMCB.dpcResult.numObjOut);
                    tlvIdx++;
                }
    
                // mmw_UartWrite (uartHandle,
                //                 (uint8_t*)&tl[tlvIdx],
                //                 sizeof(MmwDemo_output_message_tl));
    
                // /*Send range doppler heatmap */
                // mmw_UartWrite (uartHandle, (uint8_t*)&gMmwMssMCB.detMatrix.data[0],
                //                 gMmwMssMCB.numDopplerBins*gMmwMssMCB.numRangeBins*sizeof(uint32_t));
                // tlvIdx++;
    
    
                if(gMmwMssMCB.guiMonSel.statsInfo)
                {
                    /* Send stats information (interframe processing time and uart transfer time) */
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*)&tl[tlvIdx],
                                    sizeof(MmwDemo_output_message_tl));
    
                    mmw_UartWrite (uartHandle,
                                    (uint8_t*) &gMmwMssMCB.outStats,
                                    tl[tlvIdx].length);
                    tlvIdx++;
                }
                
            }
    
            if(tlvIdx != 0)
            {
                /* Send padding bytes */
                numPaddingBytes = MMWDEMO_OUTPUT_MSG_SEGMENT_LEN - (packetLen & (MMWDEMO_OUTPUT_MSG_SEGMENT_LEN-1));
                if (numPaddingBytes < MMWDEMO_OUTPUT_MSG_SEGMENT_LEN)
                {
                    mmw_UartWrite (uartHandle, (uint8_t*)padding, numPaddingBytes);
                }
            }
            /* Flush UART buffer here for each frame. */
            UART_flushTxFifo(uartHandle);
    
            /* End of UART data transmission */
            gMmwMssMCB.stats.uartTransferEndTimeStamp = Cycleprofiler_getTimeStamp();
            gMmwMssMCB.outStats.transmitOutputTime = (gMmwMssMCB.stats.uartTransferEndTimeStamp - gMmwMssMCB.stats.interFrameEndTimeStamp)/FRAME_REF_TIMER_CLOCK_MHZ;
            gMmwMssMCB.stats.totalActiveTime_us = (gMmwMssMCB.stats.uartTransferEndTimeStamp - gMmwMssMCB.stats.frameStartTimeStamp)/FRAME_REF_TIMER_CLOCK_MHZ;
    
            //Interframe processing and UART data transmission completed
            gMmwMssMCB.interSubFrameProcToken--;
    
            // Capture the time elaspsed till here
            demoEndTime = PRCMSlowClkCtrGet();
            // Demo Run time for one frame (From Sensor Start till Completion of UART transmit)
            demoTimeus = (demoEndTime - demoStartTime)*(30.5);
            if (gMmwMssMCB.adcDataSourceCfg.source == 1 || gMmwMssMCB.adcDataSourceCfg.source == 2)
            {
                demoTimeus = 0;
            }
            
            if((gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_ENABLE) || (gMmwMssMCB.lowPowerMode == LOW_PWR_TEST_MODE))
            {
                if(flagPEnable==1)
                {
                    xSemaphoreGive(gPowerSem);
                    if(gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_ENABLE)
                    {
                        Power_enablePolicy();
                    }
                }
                if((gMmwMssMCB.classifierOutput[0]==0 && ((gestureToPresenceSwitchCntr) % (framesToSwitch-1))==0)) 
                {   
                    flagG2PEnable = 1;
                    if(flagConditionalSwitch)
                        flagPEnable = 1;
                }
            }
            App_mcanTxRx();
            if (gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_DISABLE)
            {
                if(gMmwMssMCB.adcDataSourceCfg.source == 1 || gMmwMssMCB.adcDataSourceCfg.source == 2)
                {
                    /* In test mode trigger next frame processing */
                    SemaphoreP_post(&gMmwMssMCB.adcFileTaskSemHandle);
                }
                // Imp Note: Sensor Stop command is honoured only when Low Power Cfg is disabled
                if(sensorStop == 1)
                {
                    int32_t err;
                    // Stop and Close the front end
                    MMWave_stop(gMmwMssMCB.ctrlHandle,&err);
                    MMWave_close(gMmwMssMCB.ctrlHandle,&err);
                    // Delete the exisitng profile as we receive a new configuration
                    MMWave_delProfile(gMmwMssMCB.ctrlHandle,gMmwMssMCB.mmwCtrlCfg.frameCfg[0].profileHandle[0],&err);
                    // Free up all the edma channels and close the EDMA interface 
                    mmwDemo_freeDmaChannels(gEdmaHandle[0]);
                    Drivers_edmaClose();
                    EDMA_deinit();
                    // Demo Stopped
                    rangeProcHWAObj* temp = gMmwMssMCB.rangeProcDpuHandle;
                    temp->inProgress = false;
                    gMmwMssMCB.oneTimeConfigDone = 0;
                    // Re-init the EDMA interface for next configuration
                    EDMA_init();
                    Drivers_edmaOpen();
                    gMmwDemoFrameCnt = 0;
                    gMmwDemoFrameCntGesture = 1;
                    gMmwDemoFrameCntPresence = 0;
                    sensorStop = 0;
                    isSensorStarted = 0;
                
                    // Delete the DPC, TLV as we will create them again in next configuration
                    vTaskDelete(gDpcTask);
                    vTaskDelete(NULL);
                }
            }
        }
    }
    
    
    void mmwDemo_DpcExecute(){
        int32_t retVal;
        int32_t errCode = 0;
        int32_t i,j=0,k;
        DPU_DopplerProcHWA_OutParams outParmsDoppler;
        DPU_AoAProcHWA_OutParams outParmsAoA;
        DPU_RangeProcHWA_OutParams outParmsRange;
        DPU_CFARProcHWA_OutParams outParmsCfar;
        uint32_t baseAddr, regionId;
        uint8_t noOfPtsDone, numPointswithVel=0;
    
        uint32_t numDetectedPoints, numDetectedPointsMinor;
        DPC_ObjectDetection_ExecuteResult *result = &gMmwMssMCB.dpcResult;
        result->rngDopplerHeatMap = (uint32_t *) gMmwMssMCB.detMatrix.data;
    
        if(gMmwMssMCB.adcDataSourceCfg.source == 1 && SAVE_BIN_FILES)
        {
            featExtractOutput = fopen("../../../../../datapath/common/testBench/gestureRecognitionOutData/featOut.bin", "wb");
            DebugP_assert(featExtractOutput!=NULL);
    
            detMatData = fopen("../../../../../datapath/common/testBench/gestureRecognitionOutData/detMat.bin", "wb");
            DebugP_assert(detMatData!=NULL);
    
            probOutput = fopen("../../../../../datapath/common/testBench/gestureRecognitionOutData/probOut.bin", "wb");
            DebugP_assert(probOutput!=NULL);
        }
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
    
        /* give initial trigger for the first frame */
        errCode = DPU_RangeProcHWA_control(gMmwMssMCB.rangeProcDpuHandle,
                     DPU_RangeProcHWA_Cmd_triggerProc, NULL, 0);
        if(errCode < 0)
        {
            CLI_write("Error: Range control execution failed [Error code %d]\n", errCode);
        }
    
        while(true){
            memset((void *)&outParmsRange, 0, sizeof(DPU_RangeProcHWA_OutParams));
            retVal = DPU_RangeProcHWA_process(gMmwMssMCB.rangeProcDpuHandle, &outParmsRange);
            if(retVal != 0){
                CLI_write("DPU_RangeProcHWA_process failed with error code %d", retVal);
                DebugP_assert(0);
            }
            /* EDMA transfer to form the minor motion radar cube from major motion radar cube */
            if(gMmwMssMCB.enableMinorMotion && gMmwMssMCB.presence_detected)
            {
                EDMAEnableTransferRegion(baseAddr, regionId, DPC_OBJDET_MINORMOT_EDMAOUT_CH, EDMA_TRIG_MODE_MANUAL);
                while(EDMAReadIntrStatusRegion(baseAddr, regionId, DPC_OBJDET_MINORMOT_EDMAOUT_CH) != 1);// Poll for EDMA transfer completion
                EDMAClrIntrRegion(baseAddr, regionId, DPC_OBJDET_MINORMOT_EDMAOUT_CH);
            }
    
            // Read the temperature
            MMWave_getTemperatureReport(&tempStats);
    
            if(((gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_ENABLE) || (gMmwMssMCB.lowPowerMode == LOW_PWR_TEST_MODE)) && (flagPEnable==1))
            {
                //Shutdown the FECSS after chirping
                // Retain FECSS Code Memory
                int32_t err;
    
                if(pgVersion==1)
                {
                    PRCMSetSRAMRetention((PRCM_FEC_PD_SRAM_CLUSTER_2 | PRCM_FEC_PD_SRAM_CLUSTER_3), PRCM_SRAM_LPDS_RET);
                }
                else
                {
                    PRCMSetSRAMRetention((PRCM_FEC_PD_SRAM_CLUSTER_1), PRCM_SRAM_LPDS_RET);
                }
                //Reset The FrameTimer for next frame
                HW_WR_REG32(CSL_APP_RCM_U_BASE + CSL_APP_RCM_BLOCKRESET2, 0x1c0);
                for(int i =0;i<10;i++)
                {
                    test = PRCMSlowClkCtrGet();
                }
                HW_WR_REG32(CSL_APP_RCM_U_BASE + CSL_APP_RCM_BLOCKRESET2, 0x0);
                // MMW Closure in preparation for Low power state
    
                MMWave_stop(gMmwMssMCB.ctrlHandle,&err);
                MMWave_close(gMmwMssMCB.ctrlHandle,&err);
                MMWave_deinit(gMmwMssMCB.ctrlHandle,&err);
            }
    
            /* Chirping finished start interframe processing */
            gMmwMssMCB.stats.interFrameStartTimeStamp = Cycleprofiler_getTimeStamp();
            gMmwMssMCB.stats.chirpingTime_us = (gMmwMssMCB.stats.interFrameStartTimeStamp - gMmwMssMCB.stats.frameStartTimeStamp)/FRAME_REF_TIMER_CLOCK_MHZ;
    
            if(gMmwMssMCB.enableMinorMotion && gMmwMssMCB.presence_detected)
            {   
                /* Param Switch to Major motion from minor motion Doppler DPU*/
                paramSwitchMinorToMajorDopplerDPU();
                while(!flagMinorToMajorDopp);
                flagMinorToMajorDopp = 0;
            }
    
            /* Trigger Doppler DPU */
            memset((void *)&outParmsDoppler, 0, sizeof(DPU_DopplerProcHWA_OutParams));
            retVal = DPU_DopplerProcHWA_process(gMmwMssMCB.dopplerProcDpuHandle, &outParmsDoppler);
            if(retVal != 0){
                CLI_write("DPU_DopplerProc_process failed with error code %d", retVal);
                DebugP_assert(0);
            }
            if(gMmwMssMCB.adcDataSourceCfg.source == 1 && SAVE_BIN_FILES)
            {
                fwrite(gMmwMssMCB.detMatrix.data, sizeof(uint32_t)*gMmwMssMCB.numDopplerBins*gMmwMssMCB.numRangeBins, 1, detMatData);
            }
    
            if(gMmwMssMCB.presenceDetectCfg.presenceDetectMode && gMmwMssMCB.presence_detected == 0)
            {
                presence_detection();
                if(sumFramesPresenceDetect % NUM_FRAMES_PRESENCE==0)
                {
                    flagPresenceDetect = 1;
                    // gMmwMssMCB.presence_detected = 1;
                    sumFramesPresenceDetect = 1;
                }
            }
            else
            {
                /* Find the max of n points in detection Matrix */
                maxOfDetectionMatrix_HWACommonConfig();// Set the common config parameters of HWA
                uint32_t *setSoftwareTrigger = (uint32_t *)0x55010008;
                EDMAEnableTransferRegion(baseAddr, regionId, DPC_OBJDET_MAX_DETMATRIX_EDMAIN_CH, EDMA_TRIG_MODE_MANUAL);// Trigger to bring in the detection matrix
                while(EDMAReadIntrStatusRegion(baseAddr, regionId, DPC_OBJDET_MAX_DETMATRIX_EDMAIN_CH) != 1);// Poll for EDMA transfer completion
                EDMAClrIntrRegion(baseAddr, regionId, DPC_OBJDET_MAX_DETMATRIX_EDMAIN_CH); 
                for(i=0; i<gMmwMssMCB.sigProcChainCfg.maxNumPoints; ++i)
                {   
                    //HWA_setSoftwareTrigger(hwaHandle);// Trigger the HWA to perform the max operation
                    *setSoftwareTrigger = 0x1;
                    SemaphoreP_pend(&hwaParamDoneHandlemaxDetmatrix, SystemP_WAIT_FOREVER);
                    maxOfDetectionMatrix_copyDataOut();
                }
    
                /**************************************************************************/
                /*       WAIT FOR HWA NUMLOOPS INTERRUPT (from finding n max points)     */
                /************************************************************************/
                SemaphoreP_pend(&hwaDoneHandlemaxDetmatrix, SystemP_WAIT_FOREVER);
    
                /* Disable the HWA to reset it*/
                retVal = HWA_enable(hwaHandle,0); 
                if (retVal != 0)
                {
                    DebugP_assert(0);
                }
    
                noOfPtsDone = 0;
                j=0;
                //A for loop to copy out the data in the right format before AoA processing
                for(i=0;i<gMmwMssMCB.sigProcChainCfg.maxNumRangeBins;++i)
                {
                    if(gMmwMssMCB.angle_idx_doppler_count[i]!=0)   
                    {   
                        gMmwMssMCB.rangeGatesCount[0]++;
                        gMmwMssMCB.range_idx_arr[j] = gMmwMssMCB.range_idx[i];
                        gMmwMssMCB.angle_idx_doppler_count_arr[j] = gMmwMssMCB.angle_idx_doppler_count[i];
                        for(k=0;k<gMmwMssMCB.angle_idx_doppler_count_arr[j];++k)
                            gMmwMssMCB.detMatrixMaxIndex[noOfPtsDone++] = gMmwMssMCB.range_idx_arr[j]*gMmwMssMCB.numDopplerBins+gMmwMssMCB.doppler_idx_arr[gMmwMssMCB.range_idx_arr[j]*gMmwMssMCB.sigProcChainCfg.maxNumPoints+k]; // This would be used by the feature extraction library
                        ++j;
                    }
                }
    
                if(gMmwMssMCB.enableMinorMotion && gMmwMssMCB.presence_detected)
                {   /* Param Switch to Major motion from minor motion AoA DPU*/
                    paramSwitchMinorToMajorAoADPU();
                    while(!flagMinorToMajorAoA);
                    flagMinorToMajorAoA = 0;
                }
    
                /* Trigger AoA DPU - 1st for Doppler processing of range gates with max values*/
                memset((void *)&outParmsAoA, 0, sizeof(DPU_AoAProcHWA_OutParams));
                retVal = DPU_AoAProcHWA_Dopplerprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                if(retVal < 0)
                {
                    DebugP_log("DEBUG: DOPPLER DPU process return error:%d \n", retVal);
                    DebugP_assert(0);
                }
                gMmwMssMCB.AoAhwaNumLoops[0] = (gMmwMssMCB.sigProcChainCfg.maxNumPoints/2)+(gMmwMssMCB.sigProcChainCfg.maxNumPoints%2);
                /* Trigger AoA DPU - 2nd for AoA processing of max values*/
                retVal = DPU_AoAProcHWA_AoAprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                if(retVal != 0){
                    CLI_write("DPU_AoAProc_process failed with error code %d", retVal);
                    DebugP_assert(0);
                }
    
                //Function to calculate the elevation-azimuth index out of the maxVal found out from elevation-azimuth heatmap
                compute_elev_azim_idx(gMmwMssMCB.sigProcChainCfg.maxNumPoints);
    
                // Function which invokes feature extraction 
                featExtract_compute(featExtractHandle, (uint32_t *)gMmwMssMCB.detMatrix.data, gMmwDemoFrameCntGesture, gMmwMssMCB.featOutput);
    
                //Function to perform normalization based on mean and standard deviation and have the data arranged for classification
                classifier_pre_proc();
    
                if(gMmwDemoFrameCntGesture >= CLASSIFIER_NUM_FRAMES-1)
                {
                    // Classifier function to predict the output
                    classifier_predict(algClassifierHandle, gMmwMssMCB.classifierInput, gMmwMssMCB.classifierProbability);
    
                    // Classifier function to post-process the output to reduce false positives and multiple kicks as a gesture
                    classifier_post_proc();
                }
    
                if(gMmwMssMCB.adcDataSourceCfg.source == 1 && SAVE_BIN_FILES)
                {
                    fwrite(gMmwMssMCB.featOutput, sizeof(FeatExtract_featOutput), 1, featExtractOutput);
                    fwrite(gMmwMssMCB.classifierProbability, sizeof(float)*CLASSIFIER_NUM_CLASSES, 1, probOutput);
                }
    
                uKickDetect = gMmwMssMCB.classifierOutput[0];         //Kickdown status (0x00 : inactive ; 0x01 : active)
    
                if(gMmwMssMCB.classifierOutput[0])
                {
                    flagGestureDetect = 1;
                    gestureToPresenceSwitchCntr = 1;
                }
    
                if(gMmwMssMCB.pointCloudEnabled)
                {
                    /* CFAR DPU for major motion point cloud*/
                    gMmwMssMCB.dpcResult.numObjOut = 0;
                    numPointswithVel = 0;
                    numDetectedPoints = 0;
                    memset((void *)&outParmsCfar, 0, sizeof(DPU_CFARProcHWA_OutParams));
                    outParmsCfar.rangeProfile = gMmwMssMCB.rangeProfile;
                    outParmsCfar.detObjOut = gMmwMssMCB.cfarDetObjOut;
                    outParmsCfar.detObjIndOut = gMmwMssMCB.dpcObjIndOut;
                    outParmsCfar.detObjOutMaxSize = MAX_NUM_POINTS_MAJOR_MOTION;
                    outParmsCfar.detRngDopList = gMmwMssMCB.detRngDopList;
    
                    retVal = DPU_CFARProcHWA_process(gMmwMssMCB.cfarProcDpuHandle,
                                                    &gMmwMssMCB.detMatrix,
                                                    &gMmwMssMCB.cfarRunTimeInputParams,
                                                    &outParmsCfar);
                    numDetectedPoints = outParmsCfar.numCfarDetectedPoints;
    
                    result->numObjOut = numDetectedPoints;
                    if(retVal != 0){
                        CLI_write("DPU_CFARProcHWA_process failed with error code %d", retVal);
                        DebugP_assert(0);
                    }
                    if(numDetectedPoints>0)
                    {
                        //Reset the values of arrays where the rangeIdx, dopplerIdx etc are stored
                        memset(gMmwMssMCB.rangeGatesCount,0,sizeof(uint16_t));
                        memset(gMmwMssMCB.angle_idx_doppler_count_arr,0,gMmwMssMCB.numRangeBins*sizeof(uint16_t));
                        memset(gMmwMssMCB.angle_idx_doppler_count,0,gMmwMssMCB.numRangeBins*sizeof(uint16_t));
                        memset(gMmwMssMCB.range_idx_arr,0,gMmwMssMCB.numRangeBins*sizeof(uint16_t));
                        memset(gMmwMssMCB.range_idx,0,gMmwMssMCB.numRangeBins*sizeof(uint16_t));
                        memset(gMmwMssMCB.doppler_idx_arr,0,gMmwMssMCB.numRangeBins*gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(uint16_t));
                        memset(gMmwMssMCB.elev_idx,0,gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(int16_t));
                        memset(gMmwMssMCB.azim_idx,0,gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(int16_t));
                        memset(gMmwMssMCB.maxVal_elev_azim,0,gMmwMssMCB.sigProcChainCfg.maxNumPoints*sizeof(uint32_t));
    
                        for(i=0; i<numDetectedPoints; ++i)
                        {   
                            gMmwMssMCB.range_idx[outParmsCfar.detRngDopList[i].rangeIdx] = outParmsCfar.detRngDopList[i].rangeIdx;
                            gMmwMssMCB.angle_idx_doppler_count[outParmsCfar.detRngDopList[i].rangeIdx] = gMmwMssMCB.angle_idx_doppler_count[outParmsCfar.detRngDopList[i].rangeIdx] + 1;
                            if(outParmsCfar.detRngDopList[i].dopplerIdx<0)
                            {
                                gMmwMssMCB.doppler_idx_arr[outParmsCfar.detRngDopList[i].rangeIdx*gMmwMssMCB.sigProcChainCfg.maxNumPoints+gMmwMssMCB.angle_idx_doppler_count[outParmsCfar.detRngDopList[i].rangeIdx]-1] = outParmsCfar.detRngDopList[i].dopplerIdx+gMmwMssMCB.numDopplerBins;
                            }
                            else
                            {
                                gMmwMssMCB.doppler_idx_arr[outParmsCfar.detRngDopList[i].rangeIdx*gMmwMssMCB.sigProcChainCfg.maxNumPoints+gMmwMssMCB.angle_idx_doppler_count[outParmsCfar.detRngDopList[i].rangeIdx]-1] = outParmsCfar.detRngDopList[i].dopplerIdx;
                            }
                            
                        }
    
                        j=0;
                        //A for loop to copy out the data in the right format before AoA processing
                        for(i=0;i<gMmwMssMCB.numRangeBins;++i)
                        {
                            if(gMmwMssMCB.angle_idx_doppler_count[i]!=0)   
                            {   
                                gMmwMssMCB.rangeGatesCount[0]++;
                                gMmwMssMCB.range_idx_arr[j] = gMmwMssMCB.range_idx[i];
                                gMmwMssMCB.angle_idx_doppler_count_arr[j] = gMmwMssMCB.angle_idx_doppler_count[i];
                                ++j;
                            }
                        }
    
                        /* Trigger AoA DPU - 1st for Doppler processing of detected points (major motion)*/
                        memset((void *)&outParmsAoA, 0, sizeof(DPU_AoAProcHWA_OutParams));
                        retVal = DPU_AoAProcHWA_Dopplerprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                        if(retVal < 0)
                        {
                            DebugP_log("DEBUG: DOPPLER DPU process return error:%d \n", retVal);
                            DebugP_assert(0);
                        }
                        gMmwMssMCB.AoAhwaNumLoops[0] = (numDetectedPoints/2) + (numDetectedPoints%2);
                        /* Trigger AoA DPU - 2nd for AoA processing of detected points (major motion)*/
                        retVal = DPU_AoAProcHWA_AoAprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                        if(retVal != 0){
                            CLI_write("DPU_AoAProc_process failed with error code %d", retVal);
                            DebugP_assert(0);
                        }
                        
                        //Function to calculate the elevation-azimuth index out of the maxVal found out from elevation-azimuth heatmap
                        compute_elev_azim_idx(numDetectedPoints);
    
                        //Point Cloud calculation for spherical and cartesian coordinates
                        for(i=0;i<numDetectedPoints;++i)
                        {   
                            if(gMmwMssMCB.sigProcChainCfg.isZeroDopplerRemovedMajorMot)
                            {
                                if(outParmsCfar.detRngDopList[i].dopplerIdx!=0 && outParmsCfar.detRngDopList[i].dopplerIdx!=1 && outParmsCfar.detRngDopList[i].dopplerIdx!=-1)
                                {
                                    gMmwMssMCB.aoaDetObjOutSpherical[i].range = outParmsCfar.detRngDopList[i].range;
                                    gMmwMssMCB.aoaDetObjOutSpherical[i].velocity = outParmsCfar.detRngDopList[i].doppler;
                                    gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle = asin(2.0f*gMmwMssMCB.azim_idx[i]/gMmwMssMCB.sigProcChainCfg.azimuthFftSize);
                                    gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle = asin(2.0f*gMmwMssMCB.elev_idx[i]/gMmwMssMCB.sigProcChainCfg.elevationFftSize);
    
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].velocity = outParmsCfar.detRngDopList[i].doppler;
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].snr = outParmsCfar.detRngDopList[i].snrdB;
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].noise = outParmsCfar.detRngDopList[i].noisedB;
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].x = gMmwMssMCB.aoaDetObjOutSpherical[i].range*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle)*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].y = gMmwMssMCB.aoaDetObjOutSpherical[i].range*sin(gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle)*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].z = gMmwMssMCB.aoaDetObjOutSpherical[i].range*sin(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
    
                                    if(gMmwMssMCB.boardTiltAngle!=0)
                                    {
                                        gMmwMssMCB.aoaDetObjOutCartesian[i].x = gMmwMssMCB.aoaDetObjOutCartesian[i].x*cos(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.aoaDetObjOutCartesian[i].z*sin(gMmwMssMCB.boardTiltAngle);
                                        // gMmwMssMCB.aoaDetObjOutCartesian[i].z = -gMmwMssMCB.aoaDetObjOutCartesian[i].x*sin(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.aoaDetObjOutCartesian[i].z*cos(gMmwMssMCB.boardTiltAngle);
                                    }  
                                    numPointswithVel++;
                                }     
                            }
                            else
                            {
                                gMmwMssMCB.aoaDetObjOutSpherical[i].range = outParmsCfar.detRngDopList[i].range;
                                gMmwMssMCB.aoaDetObjOutSpherical[i].velocity = outParmsCfar.detRngDopList[i].doppler;
                                gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle = asin(2.0f*gMmwMssMCB.azim_idx[i]/gMmwMssMCB.sigProcChainCfg.azimuthFftSize);
                                gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle = asin(2.0f*gMmwMssMCB.elev_idx[i]/gMmwMssMCB.sigProcChainCfg.elevationFftSize);
    
                                gMmwMssMCB.aoaDetObjOutCartesian[i].velocity = outParmsCfar.detRngDopList[i].doppler;
                                gMmwMssMCB.aoaDetObjOutCartesian[i].snr = outParmsCfar.detRngDopList[i].snrdB;
                                gMmwMssMCB.aoaDetObjOutCartesian[i].noise = outParmsCfar.detRngDopList[i].noisedB;
                                gMmwMssMCB.aoaDetObjOutCartesian[i].x = gMmwMssMCB.aoaDetObjOutSpherical[i].range*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle)*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
                                gMmwMssMCB.aoaDetObjOutCartesian[i].y = gMmwMssMCB.aoaDetObjOutSpherical[i].range*sin(gMmwMssMCB.aoaDetObjOutSpherical[i].azimuthAngle)*cos(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
                                gMmwMssMCB.aoaDetObjOutCartesian[i].z = gMmwMssMCB.aoaDetObjOutSpherical[i].range*sin(gMmwMssMCB.aoaDetObjOutSpherical[i].elevAngle);
    
                                if(gMmwMssMCB.boardTiltAngle!=0)
                                {
                                    gMmwMssMCB.aoaDetObjOutCartesian[i].x = gMmwMssMCB.aoaDetObjOutCartesian[i].x*cos(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.aoaDetObjOutCartesian[i].z*sin(gMmwMssMCB.boardTiltAngle);
                                    // gMmwMssMCB.aoaDetObjOutCartesian[i].z = -gMmwMssMCB.aoaDetObjOutCartesian[i].x*sin(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.aoaDetObjOutCartesian[i].z*cos(gMmwMssMCB.boardTiltAngle);
                                }  
                            }         
                        }
    
                    
                        gMmwMssMCB.dpcResult.numObjOut = numPointswithVel;
    
                    }
                }
                /* Calculation of point cloud for minor motion */
                if(gMmwMssMCB.enableMinorMotion && gMmwDemoFrameCntGesture>=(gMmwMssMCB.sigProcChainCfg.numFrmPerMinorMotProc))
                {   
                    numDetectedPointsMinor = 0;
                    gMmwMssMCB.dpcResult.numObjOutMinor = 0;
                    // Param Switch to Major motion from minor motion for Doppler DPU
                    paramSwitchMajorToMinorDopplerDPU();
                    while(!flagMajorToMinorDopp);
                    flagMajorToMinorDopp = 0;
                    memset((void *)&outParmsDoppler, 0, sizeof(DPU_DopplerProcHWA_OutParams));
                    retVal = DPU_DopplerProcHWA_process(gMmwMssMCB.dopplerProcDpuHandle, &outParmsDoppler);
                    if(retVal != 0){
                    CLI_write("DPU_DopplerProc_process failed with error code %d", retVal);
                    DebugP_assert(0);
                    }
    
                    // HWA commonConfig of minor motion for CFAR, sum and max
                    minorMotionRangeDopp_HWACommonConfig();
    
                    //Trigger the EDMA to transfer the minor motion detection matrix to HWA which triggers HWA
                    EDMAEnableTransferRegion(baseAddr, regionId, DPC_OBJDET_MINORMOT_EDMAIN_CH, EDMA_TRIG_MODE_MANUAL);
                    /**************************************************************************/
                    /*       WAIT FOR HWA NUMLOOPS INTERRUPT (from minor motion calcculation)     */
                    /************************************************************************/
                    SemaphoreP_pend(&hwaDoneMinorMotCalc, SystemP_WAIT_FOREVER);
    
                    //Read the peaks from CFAR operations
                    HWA_readCFARPeakCountReg(hwaHandle, (uint8_t *)&numDetectedPointsMinor, sizeof(uint16_t));
    
                    /* Disable the HWA to reset it*/
                    retVal = HWA_enable(hwaHandle,0); 
                    if (retVal != 0)
                    {
                        DebugP_assert(0);
                    }
                    
                    if(numDetectedPointsMinor>0)
                    {   
                        if(numDetectedPointsMinor>MAX_NUM_POINTS_MINOR_MOTION)
                            numDetectedPointsMinor = MAX_NUM_POINTS_MINOR_MOTION;
                        // Call the fuction which will calculate range, velocity for minor motion object detected
                        rangeDoppMinorCalc_forAoA(numDetectedPointsMinor);
    
                        j=0;
                        //A for loop to copy out the data in the right format before AoA processing
                        for(i=0;i<gMmwMssMCB.numRangeBins;++i)
                        {
                            if(gMmwMssMCB.angle_idx_doppler_count[i]!=0)   
                            {   
                                gMmwMssMCB.rangeGatesCount[0]++;
                                gMmwMssMCB.range_idx_arr[j] = gMmwMssMCB.range_idx[i];
                                gMmwMssMCB.angle_idx_doppler_count_arr[j] = gMmwMssMCB.angle_idx_doppler_count[i];
                                ++j;
                            }
                        }
                        // Param Switch to Major motion from minor motion for AoA DPU
                        paramSwitchMajorToMinorAoADPU();
                        while(!flagMajorToMinorAoA);
                        flagMajorToMinorAoA = 0;
    
                        /* Trigger AoA DPU - 1st for Doppler processing of of detected points(minor motion)*/
                        memset((void *)&outParmsAoA, 0, sizeof(DPU_AoAProcHWA_OutParams));
                        retVal = DPU_AoAProcHWA_Dopplerprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                        if(retVal < 0)
                        {
                            DebugP_log("DEBUG: DOPPLER DPU process return error:%d \n", retVal);
                            DebugP_assert(0);
                        }
    
                        gMmwMssMCB.AoAhwaNumLoops[0] = (numDetectedPointsMinor/2) + (numDetectedPointsMinor%2);
                        /* Trigger AoA DPU - 2nd for AoA processing of detected points(minor motion) */
                        retVal = DPU_AoAProcHWA_AoAprocess(gMmwMssMCB.aoaProcDpuHandle, &outParmsAoA);
                        if(retVal != 0){
                            CLI_write("DPU_AoAProc_process failed with error code %d", retVal);
                            DebugP_assert(0);
                        }
                            
                        //Function to calculate the elevation-azimuth index out of the maxVal found out from elevation-azimuth heatmap
                        compute_elev_azim_idx(numDetectedPointsMinor);
    
                        float azimuthAngle=0.0, elevAngle=0.0;
                        //Point Cloud calculation cartesian coordinates in minor motion
                        for(i=0;i<numDetectedPointsMinor;++i)
                        {                   
                            gMmwMssMCB.minorMotObjOut[i].velocity = gMmwMssMCB.detRngDopListMinor[i].doppler;
                            azimuthAngle = asin(2.0f*gMmwMssMCB.azim_idx[i]/gMmwMssMCB.sigProcChainCfg.azimuthFftSize);
                            elevAngle = asin(2.0f*gMmwMssMCB.elev_idx[i]/gMmwMssMCB.sigProcChainCfg.elevationFftSize);
                            gMmwMssMCB.minorMotObjOut[i].x = gMmwMssMCB.detRngDopListMinor[i].range*cos(azimuthAngle)*cos(elevAngle);
                            gMmwMssMCB.minorMotObjOut[i].y = gMmwMssMCB.detRngDopListMinor[i].range*sin(azimuthAngle)*cos(elevAngle);
                            gMmwMssMCB.minorMotObjOut[i].z = gMmwMssMCB.detRngDopListMinor[i].range*sin(elevAngle);   
    
                            if(gMmwMssMCB.boardTiltAngle!=0)
                            {
                                gMmwMssMCB.minorMotObjOut[i].x = gMmwMssMCB.minorMotObjOut[i].x*cos(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.minorMotObjOut[i].z*sin(gMmwMssMCB.boardTiltAngle);
                                // gMmwMssMCB.minorMotObjOut[i].z = -gMmwMssMCB.minorMotObjOut[i].x*sin(gMmwMssMCB.boardTiltAngle)+gMmwMssMCB.minorMotObjOut[i].z*cos(gMmwMssMCB.boardTiltAngle);
                            }
    
                            gMmwMssMCB.dpcResult.numObjOutMinor = numDetectedPointsMinor;    
                        }
                    }
                }
            }
    
            /* Give initial trigger for the next frame */
            retVal = DPU_RangeProcHWA_control(gMmwMssMCB.rangeProcDpuHandle,
                        DPU_RangeProcHWA_Cmd_triggerProc, NULL, 0);
            if(retVal < 0)
            {
                CLI_write("Error: DPU_RangeProcHWA_control failed with error code %d", retVal);
                DebugP_assert(0);
            }
    
            /* Interframe processing finished */
            gMmwMssMCB.stats.interFrameEndTimeStamp = Cycleprofiler_getTimeStamp();
            gMmwMssMCB.outStats.interFrameProcessingTime = (gMmwMssMCB.stats.interFrameEndTimeStamp - gMmwMssMCB.stats.interFrameStartTimeStamp)/FRAME_REF_TIMER_CLOCK_MHZ;
            #if(!SAVE_BIN_FILES)
            if((gMmwMssMCB.outStats.interFrameProcessingTime*1.0/1000)>frameIdleTime)
                CLI_write("Error: Interframe Processing time is greater than frame idle time\n");
            #endif
            /* Trigger UART task to send TLVs to host */
            SemaphoreP_post(&gMmwMssMCB.tlvSemHandle);
        }
    }
    
    /**
    *  @b Description
    *  @n
    *        Function configuring and executing DPC
    */
    void mmwDemo_dpcTask()
    {
        mmwDemo_DpcConfig();
    
        mmwDemo_DpcExecute();
    
        /* Never return for this task. */
        SemaphoreP_pend(&gMmwMssMCB.TestSemHandle, SystemP_WAIT_FOREVER);
    }
    
    /**
    *  @b Description
    *  @n
    *        Function to read ADC data from file
    */
    uint32_t counter_adc;
    int16_t *gPreStoredAdcTestBuff;
    int32_t gPreStoredAdcTestBuffInd = 0;
    int32_t gPreStoredAdcTestBuffRdInd = 0;
    
    uint32_t  localRead(uint8_t * adcTestBuff, uint32_t sizeOfSamp,  uint32_t numSamp)
    {
        memcpy((uint8_t *)adcTestBuff, (uint8_t *)&gPreStoredAdcTestBuff[gPreStoredAdcTestBuffInd], sizeOfSamp * numSamp);
        gPreStoredAdcTestBuffInd += numSamp;
        return numSamp;
    }
    
    void mmwDemo_adcFileReadTask(){
        uint32_t baseAddr, regionId, numAdcSamplesPerEvt, numReadSamples;
        int32_t  errorCode = 0;
        int32_t status = SystemP_SUCCESS;
        uint16_t frameCnt, i, j;
        bool endOfFile = false;
        FILE * fileIdAdcData;
        rangeProcTestConfig_t testConfig={0};
    
        baseAddr = EDMA_getBaseAddr(gEdmaHandle[0]);
        DebugP_assert(baseAddr != 0);
    
        regionId = EDMA_getRegionId(gEdmaHandle[0]);
        DebugP_assert(regionId < SOC_EDMA_NUM_REGIONS);
    
        if (gMmwMssMCB.adcDataSourceCfg.source == 1)
        {
            /* start the test */
            fileIdAdcData = fopen(gMmwMssMCB.adcDataSourceCfg.fileName, "rb");
            if (fileIdAdcData == NULL)
            {
                printf("Error:  Cannot open ADC file !\n");
                exit(0);
            }
        }
    
        testConfig.numRxAntennas = gMmwMssMCB.numRxAntennas;
        if (gMmwMssMCB.adcDataSourceCfg.source == 1)
        {
            fread(&testConfig.numAdcSamples, sizeof(uint16_t),1,fileIdAdcData);
            fread(&testConfig.numVirtualAntennas, sizeof(uint16_t),1,fileIdAdcData);
            fread(&testConfig.numChirpsPerFrame, sizeof(uint16_t),1,fileIdAdcData);
            fread(&testConfig.numFrames, sizeof(uint16_t),1,fileIdAdcData);
        }
        else
        {
            //CLI_write ("\n\nInput config data from file\n\n");
    
            //CLI_write ("No of adc samples:/>");
            status = CLI_readLine(gUartHandle[0], (char*)&testConfig.numAdcSamples, READ_LINE_BUFSIZE);
            if(status != SystemP_SUCCESS)
            {
                CLI_write("Error reading input config\n");
                DebugP_assert(0);
            }
            testConfig.numAdcSamples = atoi ((char*)&testConfig.numAdcSamples);
            
            //CLI_write ("\nNo of virtual antennas:/>");
            status = CLI_readLine(gUartHandle[0], (char*)&testConfig.numVirtualAntennas, READ_LINE_BUFSIZE);
            if(status != SystemP_SUCCESS)
            {
                CLI_write("Error reading input config\n");
                DebugP_assert(0);
            }
            testConfig.numVirtualAntennas = atoi ((char*)&testConfig.numVirtualAntennas);
            
            //CLI_write ("\nNo of chirps per frame:/>");
            status = CLI_readLine(gUartHandle[0], (char*)&testConfig.numChirpsPerFrame, READ_LINE_BUFSIZE);
            if(status != SystemP_SUCCESS)
            {
                CLI_write("Error reading input config\n");
                DebugP_assert(0);
            }
            testConfig.numChirpsPerFrame = atoi ((char*)&testConfig.numChirpsPerFrame);
    
            //CLI_write ("\nNo of frames:/>");
            status = CLI_readLine(gUartHandle[0], (char*)&testConfig.numFrames, READ_LINE_BUFSIZE);
            if(status != SystemP_SUCCESS)
            {
                CLI_write("Error reading input config\n");
                DebugP_assert(0);
            }
            testConfig.numFrames = atoi ((char*)&testConfig.numFrames);
        }
    
        testConfig.numTxAntennas = testConfig.numVirtualAntennas/testConfig.numRxAntennas;
        testConfig.numRangeBins = mathUtils_pow2roundup(testConfig.numAdcSamples)/2; //real only input
        testConfig.numChirpsPerFrameRef = testConfig.numChirpsPerFrame;
    
        numAdcSamplesPerEvt = (testConfig.numAdcSamples * testConfig.numRxAntennas);
    
        if ((testConfig.numTxAntennas > MAX_NUM_TX_ANTENNA) || (testConfig.numRangeBins > MAX_NUM_RANGEBIN) || (testConfig.numChirpsPerFrame > MAX_NUM_CHIRPS_PERFRAME))
        {
            CLI_write("Error: Wrong test configurations \n");
            exit(0);
        }
    
        DebugP_log("numTxAntennas = %d\r", testConfig.numTxAntennas);
        DebugP_log("numRangeBins = %d\r", testConfig.numRangeBins);
        DebugP_log("numChirpsPerFrame = %d\n", testConfig.numChirpsPerFrame);
        DebugP_log("numFrames = %d\n", testConfig.numFrames);
    
        if (gMmwMssMCB.adcDataSourceCfg.source == 2)
        {
            char localAdcTestBuff[READ_LINE_BUFSIZE];
            testConfig.numFrames = gMmwMssMCB.frameCfg.h_NumOfFrames; 
            if((testConfig.numFrames == 0) || (testConfig.numFrames > 8)) //Do a max of 8 frames
            {
                testConfig.numFrames = 8;
            }
            numReadSamples = testConfig.numAdcSamples * testConfig.numRxAntennas * testConfig.numChirpsPerFrame * testConfig.numTxAntennas * testConfig.numFrames * sizeof(uint16_t);
    
            gPreStoredAdcTestBuff  = (int16_t *) DPC_ObjDet_MemPoolAlloc(&gMmwMssMCB.L3RamObj,
                                                                        testConfig.numAdcSamples *
                                                                        testConfig.numRxAntennas *
                                                                        testConfig.numChirpsPerFrame *
                                                                        testConfig.numTxAntennas *
                                                                        testConfig.numFrames *
                                                                        sizeof(uint16_t),
                                                                        sizeof(uint16_t));
    
            
            //Read numFrames into buffer:
            //CLI_write("\n\nReading adc samples for all chirps and frames\n\n");
            for(frameCnt = 0; frameCnt < testConfig.numFrames; frameCnt++)
            {
                /* Read chirps from the file */
                for(i = 0; i < (testConfig.numChirpsPerFrame * testConfig.numTxAntennas); i++)
                {
                    for (j = 0; j < numAdcSamplesPerEvt; j++)
                    {
                        status = CLI_readLine(gUartHandle[0], (char*)localAdcTestBuff, READ_LINE_BUFSIZE);
                        if(status != SystemP_SUCCESS)
                        {
                            CLI_write("Error reading input data\n");
                            DebugP_assert(0);
                        }
                        gPreStoredAdcTestBuff[gPreStoredAdcTestBuffRdInd] = (int16_t) atoi ((char*)localAdcTestBuff);
                        gPreStoredAdcTestBuffRdInd++;
                    }
                }
            }
        }
    
        for(frameCnt = 0; frameCnt < testConfig.numFrames; frameCnt++)
        {
            counter_adc = 0;
            /* Read chirps from the file */
            for(i = 0; i < (testConfig.numChirpsPerFrame * testConfig.numTxAntennas); i++)
            {
                if (!endOfFile && gMmwMssMCB.adcDataSourceCfg.source != 0)
                {
                    /* Read one chirp of ADC samples and to put data in ADC test buffer */
                    if (gMmwMssMCB.adcDataSourceCfg.source == 1)
                    {
                        numReadSamples = fread(gMmwMssMCB.adcTestBuff, sizeof(uint16_t),  numAdcSamplesPerEvt, fileIdAdcData); //ToDo Hard-coded for real samples (int16_t)
                    }
                    else
                    {
                        numReadSamples = localRead(gMmwMssMCB.adcTestBuff, sizeof(uint16_t),  numAdcSamplesPerEvt);
                    }   
                    if (numReadSamples != numAdcSamplesPerEvt)
                    {
                        endOfFile = true;
                    }
                }
    
                /* Manual trigger to simulate chirp avail irq */
                errorCode = EDMAEnableTransferRegion(
                                baseAddr, regionId, EDMA_APPSS_TPCC_B_EVT_CHIRP_AVAIL_IRQ, EDMA_TRIG_MODE_MANUAL); //EDMA_TRIG_MODE_EVENT
                if (errorCode != 1)
                {
                    CLI_write("Error: EDMA start Transfer returned %d\n",errorCode);
                    return;
                }
    
                if (gMmwMssMCB.adcDataSourceCfg.source == 1)
                {
                    ClockP_usleep(1000); //1ms sleep
                }
                ++counter_adc;
            } /* end of chirp loop */
            SemaphoreP_pend(&gMmwMssMCB.adcFileTaskSemHandle, SystemP_WAIT_FOREVER);
        } /* end of frame loop */
    
        fclose(fileIdAdcData);
        if(SAVE_BIN_FILES)
        {
            fclose(detMatData);
            fclose(featExtractOutput);
            fclose(probOutput);
        }
    
        /* check the result */
        DebugP_log("Test finished!\n\r");
        DebugP_log("\n... DPC Finished, Check Output data ....  : \n\n");
    
    }
    
    /* Note: In realtime applications, factory calibration is a one-time activity and users are expected to perform this only once */
    int32_t mmwDemo_factoryCal(void)
    {
        ATE_CalibData    *ateCalib = (ATE_CalibData *)&gATECalibDataStorage;
        uint16_t         calRfFreq = 0U;
        MMWave_calibCfg  factoryCalCfg = {0U};
        int32_t          retVal = SystemP_SUCCESS;
        int32_t          errCode;
        MMWave_ErrorLevel   errorLevel;
        int16_t          mmWaveErrorCode;
        int16_t          subsysErrorCode;
    
        /* Enable sensor boot time calibration: */
        factoryCalCfg.isFactoryCalEnabled = true;
    
        /*
        * @brief  FECSS RFS Boot calibration control:
        * | bits [0] | RESERVED
        * | bits [1] | VCO calibration ON/OFF control
        * | bits [2] | PD calibration ON/OFF control
        * | bits [3] | LODIST calibration ON/OFF control
        * | bits [4] | RESERVED 
        * | bits [5] | RX IFA calibration ON/OFF control
        * | bits [6] | RX Gain calibration ON/OFF control
        * | bits [7] | TX power calibration ON/OFF control
        */
        /* As part of Factory Calibration, enable all calibrations except RX IFA calibration */
        factoryCalCfg.fecRFFactoryCalCmd.h_CalCtrlBitMask = 0xCEU;
        factoryCalCfg.fecRFFactoryCalCmd.c_MiscCalCtrl = 0x0U;
        factoryCalCfg.fecRFFactoryCalCmd.c_CalRxGainSel = gMmwMssMCB.factoryCalCfg.rxGain;
        factoryCalCfg.fecRFFactoryCalCmd.c_CalTxBackOffSel[0] = gMmwMssMCB.factoryCalCfg.txBackoffSel;
        factoryCalCfg.fecRFFactoryCalCmd.c_CalTxBackOffSel[1] = gMmwMssMCB.factoryCalCfg.txBackoffSel;
    
        /* Calculate Calibration Rf Frequency. Use Center frequency of the bandwidth(being used in demo) for calibration */
    #if SOC_XWRL64XX
        calRfFreq = (gMmwMssMCB.profileTimeCfg.w_ChirpRfFreqStart) + \
                    ((((gMmwMssMCB.chirpSlope * 256.0)/300) * (gMmwMssMCB.profileComCfg.h_ChirpRampEndTime * 0.1)) / 2);
        factoryCalCfg.fecRFFactoryCalCmd.xh_CalRfSlope = 0x4Du; /* 2.2Mhz per uSec*/
    #else
        calRfFreq = (gMmwMssMCB.profileTimeCfg.w_ChirpRfFreqStart) + \
                    ((((gMmwMssMCB.chirpSlope * 256.0)/400) * (gMmwMssMCB.profileComCfg.h_ChirpRampEndTime * 0.1)) / 2);
        factoryCalCfg.fecRFFactoryCalCmd.xh_CalRfSlope = 0x3Au; /* 2.2Mhz per uSec*/
    #endif
    
        factoryCalCfg.fecRFFactoryCalCmd.h_CalRfFreq = calRfFreq;
        factoryCalCfg.fecRFFactoryCalCmd.c_TxPwrCalTxEnaMask[0] = 0x3;
        factoryCalCfg.fecRFFactoryCalCmd.c_TxPwrCalTxEnaMask[1] = 0x1;
    
        /* Check if the device is RF-Trimmed */
        /* Checking on one Trim is enough*/
        if(gMmwMssMCB.factoryCalCfg.atecalibinEfuse == true)
        {
            /* If RF-Trimmed, no need to fetch the ATE calib data */ 
            factoryCalCfg.ptrAteCalibration = NULL;
            factoryCalCfg.isATECalibEfused  = true;
        }
        else
        {
            /*If not RF-trimmed, fetch the ATE calibration data from flash */
            factoryCalCfg.isATECalibEfused  = false;
            factoryCalCfg.ptrAteCalibration = (uint8_t *)&gATECalibDataStorage[4];
        }
    
        /* If restore option is selected, Factory Calibration is not re-run and data is restored from Flash */ 
        if(gMmwMssMCB.factoryCalCfg.restoreEnable == 1U)
        {
            if(MmwDemo_calibRestore(&gFactoryCalibDataStorage) < 0)
            {
                CLI_write ("Error: MmwDemo failed restoring Factory Calibration data from flash.\r\n");
                MmwDemo_debugAssert (0);
            }
    
            /* Populate calibration data pointer. */
            factoryCalCfg.ptrFactoryCalibData = &gFactoryCalibDataStorage.calibData;
    
            /* Disable factory calibration. */
            factoryCalCfg.isFactoryCalEnabled = false;
        }
    
        retVal = MMWave_factoryCalibConfig(gMmwMssMCB.ctrlHandle, &factoryCalCfg, &errCode);
        if (retVal != SystemP_SUCCESS)
        {
    
            /* Error: Unable to perform boot calibration */
            MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
    
            /* Error: Unable to initialize the mmWave control module */
            CLI_write ("Error: mmWave Control Initialization failed [Error code %d] [errorLevel %d] [mmWaveErrorCode %d] [subsysErrorCode %d]\n", errCode, errorLevel, mmWaveErrorCode, subsysErrorCode);
            if (mmWaveErrorCode == MMWAVE_ERFSBOOTCAL)
            {
                CLI_write ("Error: Boot Calibration failure\n");
                ateCalib->validityFlag = 0x0U; /* Flag to indicate to re-run ATE calibration */
            }
            else
            {
                MmwDemo_debugAssert (0);
            }
        }
        else
        {
            /* If Saving factory calibration data in flash is enabled and factory calibration is run*/
            if((gMmwMssMCB.factoryCalCfg.saveEnable == 1U) && (factoryCalCfg.isFactoryCalEnabled == true))
            {
                gFactoryCalibDataStorage.magic = MMWDEMO_CALIB_STORE_MAGIC;
                retVal = rl_fecssRfRxTxCalDataGet(M_DFP_DEVICE_INDEX_0, &gFactoryCalibDataStorage.calibData);
                if(retVal != M_DFP_RET_CODE_OK)
                {
                    /* Error: Calibration data restore failed */
                    CLI_write("Error: MMW demo failed rl_fecssRfFactoryCalDataGet with Error[%d]\n", retVal);
                    retVal = SystemP_FAILURE;
                }
    
                /* Save data in flash */
                retVal = MmwDemo_calibSave(&gFactoryCalibDataStorage);
                if(retVal < 0)
                {
                    CLI_write("Error: MMW demo failed Calibration Save with Error[%d]\n", retVal);
                    MmwDemo_debugAssert (0);
                }
            }
        }
    
        /* Configuring command for Run time CLPC calibration (Required if CLPC calib is enabled) */
        gMmwMssMCB.fecTxclpcCalCmd.c_CalMode = 0x0u; /* No Override */
        gMmwMssMCB.fecTxclpcCalCmd.c_CalTxBackOffSel[0] = factoryCalCfg.fecRFFactoryCalCmd.c_CalTxBackOffSel[0];
        gMmwMssMCB.fecTxclpcCalCmd.c_CalTxBackOffSel[1] = factoryCalCfg.fecRFFactoryCalCmd.c_CalTxBackOffSel[1];
        gMmwMssMCB.fecTxclpcCalCmd.h_CalRfFreq = factoryCalCfg.fecRFFactoryCalCmd.h_CalRfFreq;
        gMmwMssMCB.fecTxclpcCalCmd.xh_CalRfSlope = factoryCalCfg.fecRFFactoryCalCmd.xh_CalRfSlope;
        gMmwMssMCB.fecTxclpcCalCmd.c_TxPwrCalTxEnaMask[0] = factoryCalCfg.fecRFFactoryCalCmd.c_TxPwrCalTxEnaMask[0];
        gMmwMssMCB.fecTxclpcCalCmd.c_TxPwrCalTxEnaMask[1] = factoryCalCfg.fecRFFactoryCalCmd.c_TxPwrCalTxEnaMask[1];
    
        return retVal;
    }
    
    int32_t mmwDemo_mmWaveInit(bool iswarmstrt)
    {
        int32_t             errCode;
        int32_t             retVal = SystemP_SUCCESS;
        MMWave_InitCfg      initCfg;
        MMWave_ErrorLevel   errorLevel;
        int16_t             mmWaveErrorCode;
        int16_t             subsysErrorCode;
    
        /* Initialize the mmWave control init configuration */
        memset ((void*)&initCfg, 0, sizeof(MMWave_InitCfg));
    
        /* Is Warm Start? */
        initCfg.iswarmstart = iswarmstrt;
    
        /* Initialize and setup the mmWave Control module */
        gMmwMssMCB.ctrlHandle = MMWave_init (&initCfg, &errCode);
        if (gMmwMssMCB.ctrlHandle == NULL)
        {
            /* Error: Unable to initialize the mmWave control module */
            MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
    
            /* Error: Unable to initialize the mmWave control module */
            CLI_write ("Error: mmWave Control Initialization failed [Error code %d] [errorLevel %d] [mmWaveErrorCode %d] [subsysErrorCode %d]\n", errCode, errorLevel, mmWaveErrorCode, subsysErrorCode);
            retVal = SystemP_FAILURE;
        }
    
        /* FECSS RF Power ON*/
        if(initCfg.iswarmstart)
        {
            errCode = rl_fecssRfPwrOnOff(M_DFP_DEVICE_INDEX_0, &gMmwMssMCB.channelCfg);
            if(errCode != M_DFP_RET_CODE_OK)
            {
                CLI_write ("Error: FECSS RF PowerON failed [Error code %d] \r\n", errCode);
                retVal = SystemP_FAILURE;
            }   
        }
    
        return retVal;
    }
    
    /* Enable Continuous wave mode */
    #define CONTINUOS_WAVE_MODE_ENABLE   0
    
    /**
     *  @b Description
     *  @n
     *      mmw demo helper Function to start sensor.
     *
     *  @retval
     *      Success     - 0
     *  @retval
     *      Error       - <0
     */
    int32_t MmwDemo_startSensor(void)
    {
    #if !(CONTINUOS_WAVE_MODE_ENABLE) /* suppress warning */
        int32_t     errCode;
    #endif
        MMWave_CalibrationCfg   calibrationCfg;
    
    
        /*****************************************************************************
         * RF :: now start the RF and the real time ticking
         *****************************************************************************/
        /* Initialize the calibration configuration: */
        memset ((void *)&calibrationCfg, 0, sizeof(MMWave_CalibrationCfg));
        /* Populate the calibration configuration: */
        Mmwave_populateDefaultCalibrationCfg (&calibrationCfg);
    
        DebugP_logInfo("App: MMWave_start Issued\n");
    
    #if !(CONTINUOS_WAVE_MODE_ENABLE) /* disable mmWave_start for continousMode CW */
        /* Start the mmWave module: The configuration has been applied successfully. */
        if (MMWave_start(gMmwMssMCB.ctrlHandle, &calibrationCfg, &gMmwMssMCB.sensorStart, &errCode) < 0)
        {
            MMWave_ErrorLevel   errorLevel;
            int16_t             mmWaveErrorCode;
            int16_t             subsysErrorCode;
    
            /* Error/Warning: Unable to start the mmWave module */
            MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
            CLI_write ("Error: mmWave Start failed [mmWave Error: %d Subsys: %d]\n", mmWaveErrorCode, subsysErrorCode);
            /* datapath has already been moved to start state; so either we initiate a cleanup of start sequence or
               assert here and re-start from the beginning. For now, choosing the latter path */
            MmwDemo_debugAssert(0);
            return -1;
        }
    #endif
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      mmw demo helper Function to do one time sensor initialization.
     *      User need to fill gMmwMssMCB.mmwOpenCfg before calling this function
     *
     *  @retval
     *      Success     - 0
     *  @retval
     *      Error       - <0
     */
    int32_t MmwDemo_openSensor(void)
    {
        int32_t             errCode;
        MMWave_ErrorLevel   errorLevel;
        int16_t             mmWaveErrorCode;
        int16_t             subsysErrorCode;
    
        /**********************************************************
         **********************************************************/
    
        /* Open mmWave module, this is only done once */
    
        /* Open the mmWave module: */
        if (MMWave_open (gMmwMssMCB.ctrlHandle, &gMmwMssMCB.mmwOpenCfg, &errCode) < 0)
        {
            /* Error: decode and Report the error */
            MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
            CLI_write ("Error: mmWave Open failed [Error code: %d Subsystem: %d]\n",
                            mmWaveErrorCode, subsysErrorCode);
            return -1;
        }
    
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      MMW demo helper Function to configure sensor. User need to fill gMmwMssMCB.mmwCtrlCfg and
     *      add profiles/chirp to mmWave before calling this function
     *
     *  @retval
     *      Success     - 0
     *  @retval
     *      Error       - <0
     */
    int32_t MmwDemo_configSensor(void)
    {
        int32_t     errCode = 0;
    
        /* Configure the mmWave module: */
        if (MMWave_config (gMmwMssMCB.ctrlHandle, &gMmwMssMCB.mmwCtrlCfg, &errCode) < 0)
        {
            MMWave_ErrorLevel   errorLevel;
            int16_t             mmWaveErrorCode;
            int16_t             subsysErrorCode;
    
            /* Error: Report the error */
            MMWave_decodeError (errCode, &errorLevel, &mmWaveErrorCode, &subsysErrorCode);
            CLI_write ("Error: mmWave Config failed [Error code: %d Subsystem: %d]\n",
                            mmWaveErrorCode, subsysErrorCode);
            goto exit;
        }
    
    exit:
        return errCode;
    }
    
    int32_t mmwDemo_registerFrameStartInterrupt(void)
    {
        int32_t           retVal = 0;
        int32_t           status = SystemP_SUCCESS;
        HwiP_Params       hwiPrms;
    
    
        /* Register interrupt */
        HwiP_Params_init(&hwiPrms);
        hwiPrms.intNum      = 16 + CSL_APPSS_INTR_FECSS_FRAMETIMER_FRAME_START;
        hwiPrms.callback    = mmwDemoFrameStartISR;
        //hwiPrms.priority    = 0;
        hwiPrms.args        = (void *) &gMmwMssMCB;
        status              = HwiP_construct(&gHwiFrameStartHwiObject, &hwiPrms);
    
        if(SystemP_SUCCESS != status)
        {
            retVal = SystemP_FAILURE;
        }
        else
        {
            HwiP_enableInt((uint32_t)CSL_APPSS_INTR_FECSS_FRAMETIMER_FRAME_START);
        }
    
        return retVal;
    }
    
    
    void gesture_recognition(void* args)
    {
        int32_t errorCode = SystemP_SUCCESS;
    
        /* Peripheral Driver Initialization */
        Drivers_open();
        Board_driversOpen();
    
        // SLICER LDO TLOAD CONTROL
        // Value should be 0x0 during boot sequence to ensure stability while unloaded, then 0x1 to turn off
        // all current loading after oscillator is enabled to reduce power and extend reliability.
        // Get the version of device.
        pgVersion = SOC_getEfusePgVersion();
        // Configure the LED GPIO
        gpioBaseAddrLed = (uint32_t) AddrTranslateP_getLocalAddr(GPIO_LED_BASE_ADDR);
        pinNumLed       = GPIO_LED_PIN;
        GPIO_setDirMode(gpioBaseAddrLed, pinNumLed, GPIO_LED_DIR);
        App_mcanInit();
    
        #ifdef SOC_XWRL14XX
        /*HWASS_SHRD_RAM, TPCCA and TPCCB memory have to be init before use. */
        /*APPSS SHRAM0 and APPSS SHRAM1 are initialized by RBL, hence no need to re-init again*/
        SOC_memoryInit(SOC_RCM_MEMINIT_HWA_SHRAM_INIT|SOC_RCM_MEMINIT_TPCCA_INIT|SOC_RCM_MEMINIT_TPCCB_INIT);
        #endif
    
        #ifdef SOC_XWRL64XX
        /*HWASS_SHRD_RAM, TPCCA and TPCCB memory have to be init before use. */
        /*APPSS SHRAM0 and APPSS SHRAM1 are initialized by RBL, hence no need to re-init again*/
        /*FECSS SHRAM (96KB) has to be initialized before use as RBL does not perform initialization.*/
        SOC_memoryInit(SOC_RCM_MEMINIT_HWA_SHRAM_INIT|SOC_RCM_MEMINIT_TPCCA_INIT|SOC_RCM_MEMINIT_TPCCB_INIT|SOC_RCM_MEMINIT_FECSS_SHRAM_INIT);
        #endif
    
    
        gMmwMssMCB.commandUartHandle = gUartHandle[0];
    
        /* mmWave initialization*/
        mmwDemo_mmWaveInit(0);
    
        // RPMF: Create a Task for Power Management Framework
        gPowerTask = xTaskCreateStatic( powerManagementTask,      /* Pointer to the function that implements the task. */
                                      "power",          /* Text name for the task.  This is to facilitate debugging only. */
                                      POWER_TASK_SIZE,  /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                      NULL,            /* We are not using the task parameter. */
                                      POWER_TASK_PRI,   /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                      gPowerTaskStack,  /* pointer to stack base */
                                      &gPowerTaskObj ); /* pointer to statically allocated task object memory */
                                      
        //RPMF: Create Semaphore for to pend Power Task
        gPowerSem = xSemaphoreCreateBinaryStatic(&gPowerSemObj);
    
        /* Create binary semaphore to pend Main task, */
        SemaphoreP_constructBinary(&gMmwMssMCB.demoInitTaskCompleteSemHandle, 0);
    
        errorCode = SemaphoreP_constructBinary(&gMmwMssMCB.cliInitTaskCompleteSemHandle, 0);
        DebugP_assert(SystemP_SUCCESS == errorCode);
    
        errorCode = SemaphoreP_constructBinary(&gMmwMssMCB.TestSemHandle, 0);
        DebugP_assert(SystemP_SUCCESS == errorCode);
    
        errorCode = SemaphoreP_constructBinary(&gMmwMssMCB.tlvSemHandle, 0);
        DebugP_assert(SystemP_SUCCESS == errorCode);
    
        errorCode = SemaphoreP_constructBinary(&gMmwMssMCB.adcFileTaskSemHandle, 0);
        DebugP_assert(SystemP_SUCCESS == errorCode);
    
        /* Re-trive ATE-Calibration from Flash Offset: 0x80000 */
        if(MmwDemo_calibInit() < 0)
        {
            CLI_write("Error: ATE Calibration data initialization failed \n");
            MmwDemo_debugAssert (0);
        }
    
        /* DPC initialization*/
        DPC_Init();
    
        // Make the LED HIGH
        GPIO_pinWriteHigh(gpioBaseAddrLed, pinNumLed);
    
        CLI_init(CLI_TASK_PRIORITY);
    
        /* Never return for this task. */
        SemaphoreP_pend(&gMmwMssMCB.demoInitTaskCompleteSemHandle, SystemP_WAIT_FOREVER);
    
        Board_driversClose();
        Drivers_close();
    }
    
    //Idle3 Handle; Currently Unused
    int power_idleresumehook(uint_fast16_t eventType, uintptr_t eventArg, uintptr_t clientArg)
    {
        while(1);
    }
    
    
    void power_LPDSentryhook(void)
    {
        // Anything to do before LPDS entry
    }
    
    
    void power_LPDSresumehook(void)
    {
        static uint8_t ledState = 0;
        // Re-Init MPU
        MpuP_init();
    
        // Debug log init
        DebugP_logZoneEnable(DebugP_LOG_ZONE_ERROR);
        DebugP_logZoneEnable(DebugP_LOG_ZONE_WARN);
    
        // Initialize Clock
        ClockP_init();
        PowerClock_init();
    
        // Now we can do pinmux
        Pinmux_init();
    
        // Re-initialize all peripheral drivers
        QSPI_init();
        EDMA_init();
        HWA_init();
        I2C_init();
        Power_init();
        App_mcanInit();
        Drivers_uartInit();
        Drivers_open();
        Board_driversOpen();
        // Toggle the LED indicating out of deep sleep
        if(ledState == 0)
        {
            ledState = 1;
            GPIO_pinWriteLow(gpioBaseAddrLed, pinNumLed);
        }
        else
        {
           ledState = 0;
           GPIO_pinWriteHigh(gpioBaseAddrLed, pinNumLed);
        }
    }
    
    volatile uint32_t debug_var = 0;
    // RPMF: Power Management Task
    void powerManagementTask(void *args)
    {
        while(1)
        {
            // Wait till the UART transmit is complete
            xSemaphoreTake(gPowerSem, portMAX_DELAY);
    
            if(gMmwMssMCB.presenceDetectCfg.presenceDetectMode)
            {
                if(flagPresenceDetect)
                {
                    presenceToGestureSwitch();
                    gMmwDemoFrameCntPresence = 0;
                    flagPresenceDetect = 0;
                    gMmwMssMCB.presence_detected = 1;
                    if(flagConditionalSwitch==1)
                    {
                        flagPEnable = 0;
                    }
                }
                //else if(gMmwMssMCB.classifierOutput[0] || (gMmwMssMCB.classifierOutput[0]==0 && (gMmwDemoFrameCntGesture % NUM_FRAMES_GESTURE_TO_PRESENCE1)==0))
                //else if((flagGestureDetect && (gestureToPresenceSwitchCntr % NUM_FRAMES_GESTURE_TO_PRESENCE2)==0) || (gMmwMssMCB.classifierOutput[0]==0 && (gMmwDemoFrameCntGesture % NUM_FRAMES_GESTURE_TO_PRESENCE1)==0))
                else if(flagG2PEnable==1)
                {   
                    gestureToPresenceSwitch();
                    gestureToPresenceSwitchCntr = 1;
                    gMmwMssMCB.classifierOutput[0] = 0;
                    gMmwMssMCB.presence_detected = 0;
                    flagGestureDetect = 0;
                    flagG2PEnable = 0;
    
                    if(flagConditionalSwitch==1)
                    {
                        demoTimeus = demoTimeus/(gMmwDemoFrameCntGesture*1.0);
                        flagPEnable = 1;
                    }
                    gMmwDemoFrameCntGesture = 1;
                }
            }
    
            // Delete the DPC, TLV and CLI tasks
            vTaskDelete(gDpcTask);
            vTaskDelete(gTlvTask);
            if (gCliTask != NULL)
            {
                vTaskDelete(gCliTask);
                gCliTask = NULL;
            }
            // Get the Frame Periodicity
            frmPrdus = (gMmwMssMCB.frameCfg.w_FramePeriodicity * 0.025);
            // Time for Low Power State
            slpTimeus = (unsigned long long)(frmPrdus - demoTimeus);
    
            if(gMmwMssMCB.lowPowerMode == LOW_PWR_MODE_ENABLE)
            {
                // RPMF driver call for getting to Low Power State
                Power_idleFunc(slpTimeus);
                Power_disablePolicy();
                demoLowPwrStateTaken = Power_getLowPowModeTaken();
                if(demoLowPwrStateTaken == POWER_NONE)
                {
                    // Use Low Power config only when there is sufficient time.
                    CLI_write("Error: No Sufficient Time for getting into Low Power Modes.\n"); 
                    DebugP_assert(0);
                }
            }
            if(gMmwMssMCB.lowPowerMode == LOW_PWR_TEST_MODE)
            {
                /* Wait till the frame period expires */
                uint64_t frmPeriod = (uint32_t) (frmPrdus * 32.768e-3);
                while ((gMmwMssMCB.frameStartTimeStampSlowClk + frmPeriod) > PRCMSlowClkCtrGet())
                {
                }
                power_LPDSresumehook();
            }
    
    
            if(gMmwMssMCB.adcLogging == true)
            {
                //  Enable MDLL Clock for RDIF interface
                SOC_enableMDLLClock();
            }
            if(demoLowPwrStateTaken == POWER_IDLE)
            {
                static volatile uint32_t ledCnt = 0,ledStateIdle = 0;
                // Free up all the edma channels and close the EDMA interface 
                mmwDemo_freeDmaChannels(gEdmaHandle[0]);
                Drivers_edmaClose();
                EDMA_deinit();
                // Re-init the EDMA interface for next configuration
                EDMA_init();
                Drivers_edmaOpen();
                if((ledCnt%8) == 0)
                {
                    // Toggle the LED indicating out of deep sleep
                    if(ledStateIdle == 0)
                    {
                        ledStateIdle = 1;
                        GPIO_pinWriteLow(gpioBaseAddrLed, pinNumLed);
                    }
                    else
                    {
                        ledStateIdle = 0;
                        GPIO_pinWriteHigh(gpioBaseAddrLed, pinNumLed);
                    }
                }
                ledCnt++;
            }
    
            // DPC initialization
            DPC_Init();
    
            // mmWave initialization as Warmstart
            mmwReinitStatus = mmwDemo_mmWaveInit(1);
    
            // while(debug_var); //Uncomment this line for debug during low power mode after setting this variable to 1
            // Start the Next frame after Low Power Exit
            CLI_MMWStart();
    
            if(gMmwMssMCB.adcDataSourceCfg.source == 1 || gMmwMssMCB.adcDataSourceCfg.source == 2)
            {
                /* In test mode trigger next frame processing */
                SemaphoreP_post(&gMmwMssMCB.adcFileTaskSemHandle);
            }
        }
    }
    
    // Free all the allocated EDMA channels
    static void mmwDemo_freeDmaChannels(EDMA_Handle edmaHandle)
    {
        uint32_t   index;
        uint32_t  dmaCh, tcc, pram, shadow;
        for(index = 0; index < 64; index++)
        {
            dmaCh = index;
            tcc = index;
            pram = index;
            shadow = index;
            DPEDMA_freeEDMAChannel(edmaHandle, &dmaCh, &tcc, &pram, &shadow);
        }
        for(index = 0; index < 128; index++)
        {
            shadow = index;
            DebugP_assert(EDMA_freeParam(edmaHandle, &shadow) == SystemP_SUCCESS);
        }
        return;
    }

    ===== mcan_external_read_write.c =====

    void App_mcanInit()
    {
        /* Assign MCAN instance address */
        gMcanBaseAddr = (uint32_t) AddrTranslateP_getLocalAddr(APP_MCAN_BASE_ADDR);
    
        /* Configure MCAN module, Enable External LoopBack Mode */
        App_mcanConfig(APP_MCAN_LOOPBACK_MODE_DISABLE);
    }
    
    void App_mcanTxRx()
    {
        int32_t                 status = SystemP_SUCCESS;
        MCAN_TxBufElement       txMsg;
        MCAN_ProtocolStatus     protStatus;
        uint32_t                bufNum;
        MCAN_RxBufElement       rxMsg;
        MCAN_RxNewDataStatus    newDataStatus;
        MCAN_ErrCntStatus       errCounter;
        uint32_t                fifoNum, bitPos = 0U, txStatus, fifoFillLvl;
        MCAN_RxFIFOStatus       fifoStatus;
    
        /* Initialize message to transmit */
        MCAN_initTxBufElement(&txMsg);
    
        /* Configure Tx Msg to transmit */
        txMsg.dlc = canbus_cmd_list[CMD_Sequence[uiCmdCount]][0];               // Data Length Code [0-8  = CAN + CAN FD: transmit frame has 0-8 data bytes, 9-15 = CAN: transmit frame has 8 data bytes, 9-15 = CAN FD: transmit frame has 12/16/20/24/32/48/64 data bytes]
        for (uint8_t i = 0; i < txMsg.dlc; ++i)
        {
            txMsg.data[i] = canbus_cmd_list[CMD_Sequence[uiCmdCount]][i+1];     // Data bytes.Only first dlc number of bytes are valid.
        }
        App_mcanConfigTxMsg(&txMsg);
    
        /* Select buffer number, 32 buffers available */
        bufNum = 0U;
    
        /* Write message to Msg RAM */
        MCAN_writeMsgRam(gMcanBaseAddr, MCAN_MEM_TYPE_BUF, bufNum, &txMsg);
    
        /* Add request for transmission, This function will trigger transmission */
        status = MCAN_txBufAddReq(gMcanBaseAddr, bufNum);
        DebugP_assert(status == CSL_PASS);
    
        /* Poll for Tx completion */
        bitPos = (1U << bufNum);
        do
        {
            txStatus = MCAN_getTxBufTransmissionStatus(gMcanBaseAddr);
        }while((txStatus & bitPos) != bitPos);
    
        MCAN_getProtocolStatus(gMcanBaseAddr, &protStatus);
        /* Checking for Tx Errors */
        if (((MCAN_ERR_CODE_NO_ERROR != protStatus.lastErrCode) ||
             (MCAN_ERR_CODE_NO_CHANGE != protStatus.lastErrCode)) &&
            ((MCAN_ERR_CODE_NO_ERROR != protStatus.dlec) ||
             (MCAN_ERR_CODE_NO_CHANGE != protStatus.dlec)) &&
            (0U != protStatus.pxe))
        {
             DebugP_assert(FALSE);
        }
    #ifdef Enable_DebugP_log
        DebugP_log("[MCAN] SendMCAN_cmd finish! protStatus.lastErrCode = %d, protStatus.dlec = %d, protStatus.pxe = %d \r\n",protStatus.lastErrCode,protStatus.dlec,protStatus.pxe);
    #endif
        uiCmdCount++;
        if(uiCmdCount >= sizeof(CMD_Sequence)) uiCmdCount = 0;
    
        //DebugP_log("[MCAN] Wait for Rx completion ... \r\n");
        /* Poll for Rx completion */
        fifoStatus.num = bufNum;
        do
        {
            MCAN_getRxFIFOStatus(gMcanBaseAddr, &fifoStatus);
            fifoFillLvl = fifoStatus.fillLvl;
        }while(fifoFillLvl != APP_MCAN_FIFO_0_CNT);
    
        /* Checking for Rx Errors */
        MCAN_getErrCounters(gMcanBaseAddr, &errCounter);
        DebugP_assert((0U == errCounter.recErrCnt) &&
                      (0U == errCounter.canErrLogCnt));
    
        /* Get the new data staus, indicates buffer num which received message */
        MCAN_getNewDataStatus(gMcanBaseAddr, &newDataStatus);
        MCAN_clearNewDataStatus(gMcanBaseAddr, &newDataStatus);
    
        /* Select buffer and fifo number, Buffer is used in this app */
        bufNum = 0U;
        fifoNum = MCAN_RX_FIFO_NUM_0;
    
        MCAN_readMsgRam(gMcanBaseAddr, MCAN_MEM_TYPE_FIFO, bufNum, fifoNum, &rxMsg);
        MCAN_writeRxFIFOAck(gMcanBaseAddr, fifoNum, 0);
    
        //DebugP_log("[MCAN] Check Rx data ... \r\n");
        /* Check Rx data */
        App_mcanCheckRxMsg(&rxMsg);
    }

  • Hey Johnny,

    Have you been able to measure the processing time, and if so, how much is it? You should be able to get it from the stats TLV when the fourth parameter of guiMonSel is set to 1 or by directly looking at gMmwMssMCB.outStats.interFrameProcessingTime.

    Could you also share the configuration file you are using?

    Regards,

    Kristien

  • The following is a code snippet :

    char *radarCmdString[MAX_RADAR_CMD] = {
        "sensorStop 0 \n\r",
        "channelCfg 3 3 0 \n\r",
        "chirpComnCfg 21 0 0 128 1 34 0 \n\r",
        "chirpTimingCfg 8 20 0 102.98 77 \n\r",
        "frameCfg 2 0 200 128 70 0 \n\r",
        "sigProcChainCfg2 32 32 1 0.6 1.4 25 4 1 1 \n\r",
        "cfarCfg 2 8 3 3 0 7.5 1 0 1 1 0 0 \n\r",
        "aoaFovCfg -80 80 -45 45 \n\r",
        "rangeSelCfg 0.2 3.4 \n\r",
        "cfarMinorMotionCfg 2 8 3 3 7.5 1 \n\r",
        "adcDataSource 0 C:/ti/mmwave_lp_sdk/examples/datapath/common/testBench/gesture_recognition_adc_data/radar_data_35frames.bin \n\r",
        "adcLogging 0 \n\r",
        "boardTiltAngle 0 \n\r",
        "pointCloudEnable 1 \n\r",
        "guiMonSel 1 1 0 1 \n\r",
        "presenceDetectCfg 1 1500 9000 10 \n\r",
        "lowPowerCfg 1 \n\r",
        //"lowPowerCfg 0 \n\r",
        "factoryCalibCfg 1 0 40 0 0x1ff000 \n\r",
        "baudRate 1250000 \r\n",
        "sensorStart 0 0 0 0 \n\r",
    };

  • Hey Johnny,

    Based on your configuration, the processing time shouldn't be greater than 6 ms in gesture mode. I would highly recommend verifying the processing time either through the stats TLV or checking gMmwMssMCB.outStats.interFrameProcessingTime. In the case of the latter method, you will also have to disable low power mode using the lowPowerCfg to ensure the debugger doesn't disconnect.

    Have you also checked the time it takes to transmit data over CAN?

    Regards,

    Kristien

  • Do you mean "frameIdleTime"?

    static int32_t CLI_MMWaveFrameCfg(int32_t argc, char *argv[])
    {
        /* Sanity Check: Minimum argument check */
        if (argc != 7)
        {
            CLI_write("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Populate the frame configuration: */
        gMmwMssMCB.frameCfg.h_NumOfChirpsInBurst = atoi(argv[1]);
        gMmwMssMCB.frameCfg.c_NumOfChirpsAccum   = atoi(argv[2]);
        gMmwMssMCB.burstPeriod                   = atof(argv[3]); // us
        gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame = atoi(argv[4]);
        gMmwMssMCB.frameCfg.w_FramePeriodicity   = ((atof(argv[5])) * gSocClk) / 1000; // x crystal_clk_MHz x 1000
        gMmwMssMCB.frameCfg.h_NumOfFrames        = atoi(argv[6]);
    
        frameIdleTime = (gMmwMssMCB.frameCfg.w_FramePeriodicity * 0.025 - (double)(gMmwMssMCB.burstPeriod * gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame)) / (1000 * 1.0);
        if (frameIdleTime < 16) // Check if the frame idle time is less than 16ms (assuming 5ms for processing and 10ms as set in syscfg for deep sleep)
        {
            flagConditionalSwitch = 1;
        }
    
        if (gMmwMssMCB.frameCfg.h_NumOfBurstsInFrame > 128)
        {
            CLI_write("Error:Max number of bursts supported for this demo is 128\n");
            return -1;
        }
    
        gMmwMssMCB.frameCfg.w_BurstPeriodicity = 10.0 * gMmwMssMCB.burstPeriod;
    
        return 0;
    }

    According to the above calculation, frameIdleTime = 44.4ms

    In addition, according to the original sample program, I set lowPowerCfg to 0, and the system could not run normally.

    I will test how long it takes to capture a CAN transmission.

  • Hey Johhny,

    See my responses below:

    Do you mean "frameIdleTime"?

    No, frameIdleTime is an estimation of the amount of time spent outside of chirping which does include processing time but also inactive time that may be spent in low power mode. The interframeProcessingTime is the measured processing time and is not an estimate.

    In addition, according to the original sample program, I set lowPowerCfg to 0, and the system could not run normally.

    Understood, in that case, I would recommend using the Radar Toolbox Applications Visualizer under <RADAR_TOOLBOX_INSTALL_DIR>/tools/visualizers/Applications_Visualizer/Body_And_Chassis_Visualizer/ and enabling the feature to Save Data to File. You can then keep lowPowerCfg set to 1 but ensure the last parameter of guiMonSel is set 1 so that the stats TLV is outputted. This will be saved to a binData folder.

    Regards,

    Kristien

  • How is the processing time = 6 ms calculated?

    The test takes 476 us to transmit data via CAN.

    Thanks!

    //=================//

    uint32_t iTimeStamp_Start,iProcessingTime;
    iTimeStamp_Start = Cycleprofiler_getTimeStamp();

    App_mcanTxRx();

    iProcessingTime = (Cycleprofiler_getTimeStamp() - iTimeStamp_Start)/FRAME_REF_TIMER_CLOCK_MHZ;
    CLI_write("Johnny: Processing time is : %d us. \n",iProcessingTime);

    //=================//

    Johnny: Processing time is : 476 us. 

  • According to the settings, it seems that the CAN BUS processing time is too long, causing the transmission COM port to time out, and no data is generated in the binData folder.

    I have no other ideas at the moment. Is there any other way to solve this problem? Thank you!

  • Hey Johnny,

    How is the processing time = 6 ms calculated?

    The processing time is calculated by taking a time stamp immediately after chirping has finished and the radar cube has been generated, interFrameStartTimeStamp, before executing all DPUs. It then takes a time stamp after the final DPU has been executed and subtracts the initial time stamp to get the total processing time. For kick to open, the processing time does not includes the classifier processing, though the classification step would account for little here.

    According to the settings, it seems that the CAN BUS processing time is too long, causing the transmission COM port to time out, and no data is generated in the binData folder.

    The error shown in the console is likely not due to the CAN transmit time if its only taking around 500 us. When exactly are CAN messages transmitted - i.e., is App_mcanTxRx called before or after UART? You could set the CAN messages to be sent out after UART is done transmitting instead.

    Regards,

    Kristien

  • App_mcanTxRx is called after UART, but it does cause the kick not to be recognized, and from the LED flashing on the board, it can be seen that the LED is indeed paused when processing the can bus!

  • Hey Johnny,

    App_mcanTxRx should be executed before demoEndTime is calculated and the gPowerSem is given to ensure that frame rate - and thus detection rate - is unaffected by transmission time from the CAN bus. Please verify this is the case.

    However, if the CAN transmit time is only 476 us, this should have negligible impact on kick detection.

    Regards,

    Kristien

  • I followed the suggested location but got an error message

    "Error: No Sufficient Time for getting into Low Power Modes."

    Check the "demoTimeus" value.

    Normal state :

    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:41480.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:41297.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:41327.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:41144.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:12474.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:41175.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:41327.500000 us.

    Open App_mcanTxRx() state : 

    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:259738.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:308507.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:259555.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:308294.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:259341.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:309056.500000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:500000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:12932.000000 us.
    Johnny: slpTimeus:0.000000 us, frmPrdus:70000.000000 us, demoTimeus:288316.500000 us.
    Error: No Sufficient Time for getting into Low Power Modes.

    I tried adjusting "frameCfg 2 0 200 128 70 0 \n\r", The fifth parameter did not improve.

    12932 - 12474.5 = 457.5 us (the CAN transmit time)

    The CAN bus processing procedure does not seem to have a fixed time.

  • I currently have no other ideas to solve this problem, do you have any other suggestions? Thanks!

  • Hey Johnny,

    What exactly are you attempting to transmit each frame? Is there a difference in what is sent out in presence mode vs. gesture mode? The final frame before the insufficient time seems to imply that the same amount of data as a gesture frame is being sent out during presence mode. 

    Regards,

    Kristien

  • It simply obtains the vehicle speed data through the CAN BUS. It is just the most basic command.

    Is it true that gesture recognition can only be performed via UART data transmission, and other interfaces do not have sufficient performance to perform it?