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.

IWR1642: Inserting calibration in people counting for iwr1642

Part Number: IWR1642
Other Parts Discussed in Thread: IWR6843

Hello Champ, 

As per https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/762440/iwr1642-does-people-counting-demo-has-a-real-time-tracking-lag , it seems that people counting on xwr1642 has ability to use the calibration (compRangeBiasAndRxChanPhase) result. But in my experience, I can't simply inserting the compRangeBiasAndRxChanPhase into cfg, event the CLI.c in iwr1642 people counting does not handle compRangeBiasAndRxChanPhase command. I tried to change the CLI.c,, but for no avail. Do you have any solution for this problem?

Thank you very much,

Regards,

Wolfgang

  • Hi, 

    Can you provide some background on what version of the mmWave Industrial Toolbox that you are using?

    Best Regards,
    Alec

  • Hi Alec,

    I use mmWave Industrial Toolbox 4.1.0, the latest version that still has iwr1642 industrial toolbox. Some of the labs in 4.1.0, e.g. traffic monitoring has calibration capabilities, but not for people counting.

    Best Regards,

    Wolfgang

  • Hi Wolfgang,

    I would recommend that you take a look at the Out Of Box Demo for the 1642 device which is included in the corresponding version of the MMWave SDK that you are using. You can look at the calibration method used there and then apply that to the people counting lab.

    Best Regards,
    Alec

  • Hi Alec,

    Yes, we did calibration using Out of Box demo. But when we apply the calibration result to iwr1642's people counting, it is clear that the people counting can't process the compRangeBiasAndRxChanPhase when we send the cfg via uart. As contrast, when I run the iwr6843's people counting, it is running the compRangeBiasAndRxChanPhase, and we can see the different between using the calibration result, and without using it.

    We can even see at cli.c https://dev.ti.com/tirex/explore/node?a=VLyFKFf__4.1.0&node=A__ADHEd0FHCCOv2zu5jdRGWw__com.ti.mmwave_industrial_toolbox__VLyFKFf__4.1.0 of this people counting, there is no command for compRangeBiasAndRxChanPhase.  I tried to change the cli.c, but for no avail

    Any idea how to fix this problem?

    Thanks

    /*
     *   @file  cli.c
     *
     *   @brief
     *      Mmw (Milli-meter wave) DEMO CLI Implementation
     *
     *  Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ 
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /**************************************************************************
     *************************** Include Files ********************************
     **************************************************************************/
    
    /* Standard Include Files. */
    #include <stdint.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <string.h>
    #include <stdio.h>
    
    /* BIOS/XDC Include Files. */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/heaps/HeapBuf.h>
    #include <ti/sysbios/heaps/HeapMem.h>
    #include <ti/sysbios/knl/Event.h>
    
    /* mmWave SDK Include Files: */
    #include <ti/common/sys_common.h>
    #include <ti/drivers/uart/UART.h>
    #include <ti/drivers/osal/MemoryP.h>
    #include <ti/drivers/osal/DebugP.h>
    #include <ti/control/mmwavelink/mmwavelink.h>
    #include <ti/utils/cli/cli.h>
    
    #include <gtrack.h>
    
    /* Demo Include Files */
    #include "mss_mmw.h"
    #include <chains/RadarReceiverPeopleCounting/mmw_PCDemo/common/mmw_messages.h>
    
    /**************************************************************************
     *************************** Local Definitions ****************************
     **************************************************************************/
    
    /* CLI Extended Command Functions */
    static int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLIDoACfg (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLIFrameStart (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLISetDataLogger (int32_t argc, char* argv[]);
    static int32_t MmwDemo_CLIADCBufCfg (int32_t argc, char* argv[]);
    
    /* Tracking configuration is done by application */
    extern int32_t MmwDemo_CLITrackingCfg (int32_t argc, char* argv[]);
    
    /* SceneryParam configuration is done by application */
    extern int32_t MmwDemo_CLISceneryParamCfg (int32_t argc, char* argv[]);
    /* GatingParam configuration is done by application */
    extern int32_t MmwDemo_CLIGatingParamCfg (int32_t argc, char* argv[]);
    /* StateParam configuration is done by application */
    extern int32_t MmwDemo_CLIStateParamCfg (int32_t argc, char* argv[]);
    /* AllocationParam configuration is done by application */
    extern int32_t MmwDemo_CLIAllocationParamCfg (int32_t argc, char* argv[]);
    /* VariationParam configuration is done by application */
    extern int32_t MmwDemo_CLIVariationParamCfg (int32_t argc, char* argv[]);
    /* Point Cloud enable */
    extern int32_t MmwDemo_CLIPointCloudEn (int32_t argc, char* argv[]);
    
    
    /**************************************************************************
     *************************** External Definitions *************************
     **************************************************************************/
    
    extern MmwDemo_MCB    gMmwMssMCB;
    extern int32_t MmwDemo_mboxWrite(MmwDemo_message     * message);
    extern void MmwDemo_printHeapStats(void);
    
    /**************************************************************************
     *************************** CLI  Function Definitions **************************
     **************************************************************************/
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for the sensor start command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[])
    {
        gMmwMssMCB.stats.cliSensorStartEvt ++;
    
        /* Get the configuration from the CLI mmWave Extension */
        CLI_getMMWaveExtensionConfig (&gMmwMssMCB.cfg.ctrlCfg);
    
        /* Get the open configuration from the CLI mmWave Extension */
        CLI_getMMWaveExtensionOpenConfig (&gMmwMssMCB.cfg.openCfg);
    
        /* Post sensorSTart event to notify configuration is done */
        Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_SENSORSTART_EVT);
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for the frame start command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLIFrameStart (int32_t argc, char* argv[])
    {
        gMmwMssMCB.stats.cliFrameStartEvt ++;
    
        /* Post sensorSTart event to notify configuration is done */
        Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_FRAMESTART_EVT);
        return 0;
    }
    
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for the sensor stop command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[])
    {
        gMmwMssMCB.stats.cliSensorStopEvt ++;
    
        /* Post sensorSTOP event to notify sensor stop command */
        Event_post(gMmwMssMCB.eventHandle, MMWDEMO_CLI_SENSORSTOP_EVT);
    
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for gui monitoring configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[])
    {
        MmwDemo_GuiMonSel   guiMonSel;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 5)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize the ADC Output configuration: */
        memset ((void *)&guiMonSel, 0, sizeof(MmwDemo_GuiMonSel));
    
        /* Populate configuration: */
        guiMonSel.detectedObjects           = atoi (argv[1]);
        guiMonSel.logMagRange               = atoi (argv[2]);
        guiMonSel.rangeAzimuthHeatMap       = atoi (argv[3]);
        guiMonSel.rangeDopplerHeatMap       = atoi (argv[4]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.guiMonSel, (void *)&guiMonSel, sizeof(MmwDemo_GuiMonSel));
        
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_GUIMON_CFG;
        memcpy((void *)&message.body.guiMonSel, (void *)&guiMonSel, sizeof(MmwDemo_GuiMonSel));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for CFAR configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[])
    {
    	mmwDemoCfarConfig     cfarCfg;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 13)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize the ADC Output configuration: */
        memset ((void *)&cfarCfg, 0, sizeof(mmwDemoCfarConfig));
    
        //System_printf("CFAR config\n");
    
        //cliCfg.tableEntry[4].helpString     = "<detMode> <discardLeft> <discardRight> <refWinSize1> <refWinSize2> <guardWinSize1> <guardWinSize2> <thre>";
        /* Populate configuration: */
        cfarCfg.cfarMethod       = (uint16_t) atoi (argv[1]);
        cfarCfg.cfarDiscardRangeLeft  = (uint16_t) atoi (argv[2]);
        cfarCfg.cfarDiscardRangeRight = (uint16_t) atoi (argv[3]);
        cfarCfg.cfarDiscardAngleLeft  = (uint16_t) atoi (argv[4]);
        cfarCfg.cfarDiscardAngleRight = (uint16_t) atoi (argv[5]);
        cfarCfg.refWinSize[0]    = (uint16_t) atoi (argv[6]);
        cfarCfg.refWinSize[1]    = (uint16_t) atoi (argv[7]);
        cfarCfg.guardWinSize[0]  = (uint16_t) atoi (argv[8]);
        cfarCfg.guardWinSize[1]  = (uint16_t) atoi (argv[9]);
        cfarCfg.rangeThre             = (float) atoi (argv[10]) * 0.1f;
        cfarCfg.azimuthThre     = (float) atoi (argv[11]) * 0.1f;
        cfarCfg.log2MagFlag        = (uint16_t) atoi (argv[12]);
        //System_printf("CFAR config:method = %d\n", cfarCfg.cfarMethod);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.cfarCfg, (void *)&cfarCfg, sizeof(mmwDemoCfarConfig));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_CFAR_CFG;
        memcpy((void *)&message.body.cfar, (void *)&cfarCfg, sizeof(mmwDemoCfarConfig));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;    
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for DOA configuration
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLIDoACfg (int32_t argc, char* argv[])
    {
    	mmwDemoDoaConfig     doaCfg;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 5)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize the ADC Output configuration: */
        memset ((void *)&doaCfg, 0, sizeof(mmwDemoDoaConfig));
    
        //cliCfg.tableEntry[5].helpString     = "<doaMode> <doaGamma> <sideLobe_dB> <searchRange> <searchRes> <varThre>";
        /* Populate configuration: */
        doaCfg.estAngleRange       	= (float) atoi (argv[1]) * 0.1;
        doaCfg.estAngleResolution      = (float) atoi (argv[2]) * 0.001;
        doaCfg.gamma            = (float) atoi (argv[3]) * 0.001f;
        doaCfg.clutterRemovalFlag = (uint8_t) atoi (argv[4]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.doaCfg, (void *)&doaCfg, sizeof(mmwDemoDoaConfig));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_DOA_CFG;
        memcpy((void *)&message.body.doa, (void *)&doaCfg, sizeof(mmwDemoDoaConfig));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for data logger set command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLIADCBufCfg (int32_t argc, char* argv[])
    {
        MmwDemo_ADCBufCfg   adcBufCfg;
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 5)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
        /* Initialize the ADC Output configuration: */
        memset ((void *)&adcBufCfg, 0, sizeof(MmwDemo_ADCBufCfg));
    
        /* Populate configuration: */
        adcBufCfg.adcFmt          = (uint8_t) atoi (argv[1]);
        adcBufCfg.iqSwapSel       = (uint8_t) atoi (argv[2]);
        adcBufCfg.chInterleave    = (uint8_t) atoi (argv[3]);
        adcBufCfg.chirpThreshold  = (uint8_t) atoi (argv[4]);
    
        /* Save Configuration to use later */
        memcpy((void *)&gMmwMssMCB.cfg.adcBufCfg, (void *)&adcBufCfg, sizeof(MmwDemo_ADCBufCfg));
    
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
        message.type = MMWDEMO_MSS2DSS_ADCBUFCFG;
        memcpy((void *)&message.body.adcBufCfg, (void *)&adcBufCfg, sizeof(MmwDemo_ADCBufCfg));
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Handler for data logger set command
     *
     *  @param[in] argc
     *      Number of arguments
     *  @param[in] argv
     *      Arguments
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static int32_t MmwDemo_CLISetDataLogger (int32_t argc, char* argv[])
    {
        MmwDemo_message     message;
    
        /* Sanity Check: Minimum argument check */
        if (argc != 2)
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
    
    
        /* Save Configuration to use later */
        if (strcmp(argv[1], "mssLogger") == 0)  
            gMmwMssMCB.cfg.dataLogger = 0;
        else if (strcmp(argv[1], "dssLogger") == 0)  
            gMmwMssMCB.cfg.dataLogger = 1;
        else
        {
            CLI_write ("Error: Invalid usage of the CLI command\n");
            return -1;
        }
           
        /* Send configuration to DSS */
        memset((void *)&message, 0, sizeof(MmwDemo_message));
    
        message.type = MMWDEMO_MSS2DSS_SET_DATALOGGER;
        message.body.dataLogger = gMmwMssMCB.cfg.dataLogger;
    
        if (MmwDemo_mboxWrite(&message) == 0)
            return 0;
        else
            return -1;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the CLI Execution Task
     *
     *  @retval
     *      Not Applicable.
     */
    void MmwDemo_CLIInit (void)
    {
        CLI_Cfg     cliCfg;
        char        demoBanner[256];
    
        /* Create Demo Banner to be printed out by CLI */
        sprintf(&demoBanner[0], "******************************************\n" \
                           "MMW TM Demo %s\n"  \
                           "******************************************\n", MMW_VERSION);
        
        /* Initialize the CLI configuration: */
        memset ((void *)&cliCfg, 0, sizeof(CLI_Cfg));
    
        /* Populate the CLI configuration: */
        cliCfg.cliPrompt                    = "mmwDemo:/>";
        cliCfg.cliBanner                    = demoBanner;
        cliCfg.cliUartHandle                = gMmwMssMCB.commandUartHandle;
        cliCfg.taskPriority                 = 3;
        cliCfg.mmWaveHandle                 = gMmwMssMCB.ctrlHandle;
        cliCfg.enableMMWaveExtension        = 1U;
        cliCfg.usePolledMode                = true;
        cliCfg.tableEntry[0].cmd            = "sensorStart";
        cliCfg.tableEntry[0].helpString     = "No arguments";
        cliCfg.tableEntry[0].cmdHandlerFxn  = MmwDemo_CLISensorStart;
        cliCfg.tableEntry[1].cmd            = "sensorStop";
        cliCfg.tableEntry[1].helpString     = "No arguments";
        cliCfg.tableEntry[1].cmdHandlerFxn  = MmwDemo_CLISensorStop;
        cliCfg.tableEntry[2].cmd            = "frameStart";
        cliCfg.tableEntry[2].helpString     = "No arguments";
        cliCfg.tableEntry[2].cmdHandlerFxn  = MmwDemo_CLIFrameStart;
        cliCfg.tableEntry[3].cmd            = "guiMonitor";
        cliCfg.tableEntry[3].helpString     = "<detectedObjects> <logMagRange> <rangeAzimuthHeatMap> <rangeDopplerHeatMap>";
        cliCfg.tableEntry[3].cmdHandlerFxn  = MmwDemo_CLIGuiMonSel;
        cliCfg.tableEntry[4].cmd            = "cfarCfg";
        cliCfg.tableEntry[4].helpString     = "<detMode> <discardLeft> <discardRight> <refWinSize1> <refWinSize2> <guardWinSize1> <guardWinSize2> <thre>";
        cliCfg.tableEntry[4].cmdHandlerFxn  = MmwDemo_CLICfarCfg;
        cliCfg.tableEntry[5].cmd            = "doaCfg";
        cliCfg.tableEntry[5].helpString     = "<doaMode> <doaGamma> <sideLobe_dB> <searchRange> <searchRes> <varThre>";
        cliCfg.tableEntry[5].cmdHandlerFxn  = MmwDemo_CLIDoACfg;
        cliCfg.tableEntry[6].cmd            = "trackingCfg";
        cliCfg.tableEntry[6].helpString     = "<enable> <paramSet> <numPoints> <numTracks> <maxDoppler> <framePeriod>";
        cliCfg.tableEntry[6].cmdHandlerFxn  = MmwDemo_CLITrackingCfg;
        cliCfg.tableEntry[7].cmd            = "dataLogger";
        cliCfg.tableEntry[7].helpString     = "<mssLogger | dssLogger>";
        cliCfg.tableEntry[7].cmdHandlerFxn  = MmwDemo_CLISetDataLogger;
        cliCfg.tableEntry[8].cmd            = "adcbufCfg";
        cliCfg.tableEntry[8].helpString     = "<adcOutputFmt> <SampleSwap> <ChanInterleave> <ChirpThreshold>";
        cliCfg.tableEntry[8].cmdHandlerFxn  = MmwDemo_CLIADCBufCfg;
    	
        cliCfg.tableEntry[9].cmd            = "SceneryParam";// PC OFFICE Left Wall (-1.5), Right Wall (1.5), Bottom Exit Zone (1m), Upper Exit Zone (4.5m)
        cliCfg.tableEntry[9].helpString     = "<Left Wall> <Right Wall> <Bottom Exit Zone> <Upper Exit Zone>";
        cliCfg.tableEntry[9].cmdHandlerFxn  = MmwDemo_CLISceneryParamCfg;
        cliCfg.tableEntry[10].cmd            = "GatingParam";// PC: 4 gating volume, Limits are set to 3m in length, 2m in width, 0 no limit in doppler
        cliCfg.tableEntry[10].helpString     = "<gating volume> <length> <width> <doppler>";
        cliCfg.tableEntry[10].cmdHandlerFxn  = MmwDemo_CLIGatingParamCfg;
    	cliCfg.tableEntry[11].cmd            = "StateParam";// PC: 10 frames to activate, 5 to forget, 10 active to free, 1000 static to free, 5 exit to free
        cliCfg.tableEntry[11].helpString     = "<det2act> <det2free> <act2free> <stat2free> <exit2free>";//det2act, det2free, act2free, stat2free, exit2free
        cliCfg.tableEntry[11].cmdHandlerFxn  = MmwDemo_CLIStateParamCfg;
    	cliCfg.tableEntry[12].cmd            = "AllocationParam";// PC: 250 SNR, 0.1 minimal velocity, 5 points, 1m in distance, 2m/s in velocity
        cliCfg.tableEntry[12].helpString     = "<SNRs> <minimal velocity> <points> <in distance> <in velocity>";
        cliCfg.tableEntry[12].cmdHandlerFxn  = MmwDemo_CLIAllocationParamCfg;
    	cliCfg.tableEntry[13].cmd            = "VariationParam";// PC: 1m height, 1m in width, 1 m/s for doppler
        cliCfg.tableEntry[13].helpString     = "<height> <width> <doppler>";
        cliCfg.tableEntry[13].cmdHandlerFxn  = MmwDemo_CLIVariationParamCfg;
    
        /*! Enable Point Cloud */
        cliCfg.tableEntry[14].cmd            = "PointCloudEn"; //1 is on, 0 is off
        cliCfg.tableEntry[14].helpString     = "1 is on, 0 is off";
        cliCfg.tableEntry[14].cmdHandlerFxn  = MmwDemo_CLIPointCloudEn;
    			
    
        /* Open the CLI: */
        if (CLI_open (&cliCfg) < 0)
        {
            System_printf ("Error: Unable to open the CLI\n");
            return;
        }
        System_printf ("Debug: CLI is operational\n");
        return;
    }
    
    
    

    Wolfgang

  • Wolfgang,

    As you mentioned, you will likely need to update multiple files. You should almost certainly begin with the CLI source files, since that will be the first piece which will interact with the command. If you have any specific questions or issues, let me know.

    Best Regards,
    Alec

  • Understood, and I will try to deep dive the codes.

    Thank you very much.

    Regards,

    Wolfgang

  • Hi Alec,

    I have changed some codes, including cli.c, dss_main.c, and lastly radarProcess.c (and radarProcess.h). My question is, in the radarProcess.c ,line 391 there is phase error compensation process. In this process, there is 2 variable,, l1temp and inputptr,, but I can't see where this two variable is send to. Can you helping me in solving this question, that I believe is relevant to this thread topic.

    Thank you very much,

    Sincerely,

    Wolfgang
    note: This is radarProcess.c that taken from iwr6843 people counting.









    /*!
     *  \file   radarProcess.c
     *
     *  \brief   radar signal processing chain.
     *
     *  Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ 
     * 
     * 
     *  Redistribution and use in source and binary forms, with or without 
     *  modification, are permitted provided that the following conditions 
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright 
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the 
     *    documentation and/or other materials provided with the   
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
    */
    
    #include <radarProcess.h>
    #include <math.h>
    #include <modules/detection/CFAR/api/RADARDEMO_detectionCFAR.h>
    #include <modules/DoA/CaponBF/api/RADARDEMO_aoaEstCaponBF.h>
    #include <modules/rangeProc/rangeProc/api/RADARDEMO_rangeProc.h>
    #include <modules/utilities/cycle_measure.h>
    #include <modules/utilities/radarOsal_malloc.h>
    #include <modules/utilities/radar_c674x.h>
    
    #if (defined SOC_XWR18XX) || (defined SOC_XWR68XX)
    #include <xdc/runtime/System.h>
    #endif
    
    #define ONEOVERFACTORIAL3 (1.f/6.f)
    #define ONEOVERFACTORIAL5 (1.f/230.f)
    #define ONEOVERFACTORIAL7 (1.f/5040.f)
    #define MAXANT (8)
    #define MAXWIN1DSize (16)
    //user input configuration parameters
    typedef struct _processInstance_
    {
        // frame timing in ms
    
    	float framePeriod;
        void  * rangeFFTInstance;
        void  * detectionInstance;
        void  * DoAInstance;
    
    	RADARDEMO_rangeProc_input *rangeProcInput;
        cplx16_t *pFFT1DBuffer;
    
    	//float *localDopplerInBufPtr;
    	float * localPDP;
    	float ** localPDPPtr;
    
    	RADARDEMO_detectionCFAR_output * detectionCFAROutput;
    
    	uint8_t mimoModeFlag;  /**<Flag for MIMO mode: 0 -- SIMO, 1 -- TDM MIMO, 2 -- FDM or BF*/
    	RADARDEMO_aoAEstCaponBF_input *aoaInput;
    	float * aoaInputSignal;
    	RADARDEMO_aoAEstCaponBF_output *aoaOutput;
    
    	RADARDEMO_rangeProc_errorCode rangeProcErrorCode;
    	RADARDEMO_detectionCFAR_errorCode cfarErrorCode;
    	RADARDEMO_aoaEstCaponBF_errorCode aoaBFErrorCode;
    
    	int32_t fftSize1D;
    	int32_t fftSize2D;
    	int32_t numChirpsPerFrame;
    	int32_t numAdcSamplePerChirp;
    	int32_t nRxAnt;
    	int32_t maxNumDetObj;
    	int32_t numAzimuthBin;
    	float   rangeRes;
    	float   dopplerRes;
    	float   angleRes;
    	cplx16_t *antPhaseCompCoeff;
    	uint8_t		dopplerOversampleFactor;
    
    	//float    * scratchBuffer;
    	radarProcessBenchmarkObj * benchmarkPtr;
    }radarProcessInstance_t;
    
    #define RAD_TO_DEG      ( 3.1415926f/180.f)
    #define DEG_TO_RAD      ( 180.f/3.1415926f)
    
    
    void *radarProcessCreate(radarProcessConfig_t  * config, ProcessErrorCodes * procErrorCode)
    {
        radarProcessInstance_t *inst;
    	int32_t    i;
    	int16_t win1D[MAXWIN1DSize];
    	int32_t itemp;
    	ProcessErrorCodes errorCode = PROCESS_OK;
    	
        inst = (radarProcessInstance_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, sizeof(radarProcessInstance_t), 8);
    
    	inst->antPhaseCompCoeff		=	(cplx16_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, config->numAntenna * sizeof(cplx16_t), 8);
    
    	for (i = 0; i < config->numAntenna; i++)
    	{
    		inst->antPhaseCompCoeff[i].real = (int32_t)(32767.f * config->antPhaseCompCoeff[2 * i]);
    		inst->antPhaseCompCoeff[i].imag = (int32_t)(32767.f * config->antPhaseCompCoeff[2 * i + 1]);
    	}
    	itemp								=	config->numChirpPerFrame; 
    	if ((1 << (30 - _norm(itemp))) == itemp)
    		inst->fftSize2D					=	itemp;
    	else
    		inst->fftSize2D					=	1 << (31 - _norm(itemp));
    
    
    	config->fftSize2D =  inst->fftSize2D;
    	config->dopplerOversampleFactor = config->doaConfig.dopplerOversampleFactor; //hardcoded to 2;
    	inst->dopplerOversampleFactor = config->doaConfig.dopplerOversampleFactor;
    
    	for (i = 0; i < (int32_t)config->rangeWinSize; i++ )
    	{
    		itemp		=	(int32_t) (32768.f * config->rangeWindow[i] + 0.5f);
    		if (itemp >= 32767) itemp = 32767;
    		win1D[i]	=	itemp;
    	}
    	inst->numAzimuthBin =   (int32_t) ((2.f * config->doaConfig.estAngleRange) / (config->doaConfig.estAngleResolution) + 0.5f);
    
    	/* range proc */
    	{
    		RADARDEMO_rangeProc_config rangeProcConfig0;
    		RADARDEMO_rangeProc_config *rangeProcConfig = &rangeProcConfig0;
    
    		itemp								=	config->numAdcSamplePerChirp; 
    		if ((1 << (30 - _norm(itemp))) == itemp)
    			inst->fftSize1D					=	itemp;
    		else
    			inst->fftSize1D					=	1 << (31 - _norm(itemp));
    		rangeProcConfig->fft1DSize			=	inst->fftSize1D; 
    		config->fftSize1D					=	inst->fftSize1D; 
    		rangeProcConfig->nSamplesPerChirp	=	config->numAdcSamplePerChirp;
    
    		rangeProcConfig->nRxAnt				=	(uint8_t)config->numPhyRxAntenna;
    		rangeProcConfig->numChirpsPerFrame	=	config->numChirpPerFrame * config->numTxAntenna;
    		rangeProcConfig->adcNumOutputBits	=	(uint8_t) config->numAdcBitsPerSample;
    		rangeProcConfig->win1D				=	win1D;
    		rangeProcConfig->win2D				=	NULL; 
    		rangeProcConfig->adjustDCforInput	=	RADARDEMO_RANGEPROC_ADC_NO_ADJUST; 
    		rangeProcConfig->win1DLength		=	(int32_t)config->rangeWinSize;
    
    		rangeProcConfig->fft1DType			=	RADARDEMO_RANGEPROC_1DFFT_16x16; 
    
    		rangeProcConfig->include2DwinFlag	=	0;  /* hardcoded, memory limitation from XWR16xx*/
    
    		rangeProcConfig->outputFixedpFlag	=	1;  
    
    		inst->rangeFFTInstance		= (void *) RADARDEMO_rangeProc_create(rangeProcConfig, &inst->rangeProcErrorCode);
    		inst->numChirpsPerFrame		=	config->numChirpPerFrame;
    		inst->numAdcSamplePerChirp	=	config->numAdcSamplePerChirp;
    		inst->nRxAnt				=	config->numAntenna;
    		if (inst->rangeProcErrorCode > RADARDEMO_RANGEPROC_NO_ERROR)
    		{
    			errorCode 	=	PROCESS_ERROR_RANGEPROC_INIT_FAILED;
    		}
    		inst->rangeProcInput	=	(RADARDEMO_rangeProc_input *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, 1*sizeof(RADARDEMO_rangeProc_input), 1);
    		if (inst->rangeProcInput == NULL)
    		{
    			errorCode 	=	PROCESS_ERROR_RANGEPROC_INOUTALLOC_FAILED;
    		}
    	}
    
    	/* Detection CFAR */
    	{
    		RADARDEMO_detectionCFAR_config cfarConfig0;
    		RADARDEMO_detectionCFAR_config *cfarConfig = &cfarConfig0;
    
    		cfarConfig->fft1DSize		=	inst->fftSize1D; 
    		cfarConfig->fft2DSize		=	inst->numAzimuthBin; 
    		if (config->cfarConfig.cfarMethod == 6)
    		{
    			cfarConfig->cfarType		=	RADARDEMO_DETECTIONCFAR_RA_CASOCFAR;
    			cfarConfig->enableSecondPassSearch		=	1;
    		}
    		else if (config->cfarConfig.cfarMethod == 4)
    		{
    			cfarConfig->cfarType		=	RADARDEMO_DETECTIONCFAR_CASOCFAR;
    			cfarConfig->enableSecondPassSearch		=	1;
    		}
    		else if (config->cfarConfig.cfarMethod == 3)
    		{
    			cfarConfig->cfarType		=	RADARDEMO_DETECTIONCFAR_CASOCFAR;
    			cfarConfig->enableSecondPassSearch		=	0;
    		}
    		else if (config->cfarConfig.cfarMethod == 2)
    		{
    			cfarConfig->cfarType		=	RADARDEMO_DETECTIONCFAR_CAVGCFAR;
    			cfarConfig->enableSecondPassSearch		=	1;
    		}
    		else if (config->cfarConfig.cfarMethod == 1)
    		{
    			cfarConfig->cfarType		=	RADARDEMO_DETECTIONCFAR_CAVGCFAR;
    			cfarConfig->enableSecondPassSearch		=	0;
    		}
    		else
    		{
    			errorCode 	=	PROCESS_ERROR_CFARPROC_NONSUPPORTEDMETHOD;
    		}
    		cfarConfig->inputType		=	RADARDEMO_DETECTIONCFAR_INPUTTYPE_SP; 
    		cfarConfig->pfa				=	(float)1e-6; //hardcoded, not used for now;
    		cfarConfig->rangeRes		=	config->cfarConfig.rangeRes * config->numAdcSamplePerChirp * _rcpsp(inst->fftSize1D);
    		inst->rangeRes              =   cfarConfig->rangeRes;
    		cfarConfig->dopplerRes		=	config->cfarConfig.velocityRes * config->numChirpPerFrame * _rcpsp(inst->fftSize2D);
            inst->dopplerRes            =   cfarConfig->dopplerRes;
    		cfarConfig->maxNumDetObj	=	(uint16_t)DOA_OUTPUT_MAXPOINTS;    
    		cfarConfig->searchWinSizeRange	=	(uint8_t)config->cfarConfig.refWinSize[0];
    		cfarConfig->guardSizeRange		=	(uint8_t)config->cfarConfig.guardWinSize[0];
    		//hard coded for now for CASO
    		cfarConfig->searchWinSizeDoppler=	(uint8_t)config->cfarConfig.refWinSize[1];
    		cfarConfig->guardSizeDoppler	=	(uint8_t)config->cfarConfig.guardWinSize[1];
    		cfarConfig->K0					=	config->cfarConfig.rangeThre; 
    		cfarConfig->dopplerSearchRelThr	=	config->cfarConfig.azimuthThre; 
    		cfarConfig->leftSkipSize		=	(uint8_t)config->cfarConfig.cfarDiscardRangeLeft;
    		cfarConfig->rightSkipSize		=	(uint8_t)config->cfarConfig.cfarDiscardRangeRight;
    		cfarConfig->leftSkipSizeAzimuth		=	(uint8_t)config->cfarConfig.cfarDiscardAngleLeft;
    		cfarConfig->rightSkipSizeAzimuth	=	(uint8_t)config->cfarConfig.cfarDiscardAngleRight;
    		cfarConfig->log2MagFlag			=	config->cfarConfig.log2MagFlag; 
    
    		inst->detectionInstance = (void *) RADARDEMO_detectionCFAR_create(cfarConfig, &inst->cfarErrorCode);
    		if (inst->cfarErrorCode > RADARDEMO_DETECTIONCFAR_NO_ERROR)
    		{
    			errorCode 	=	PROCESS_ERROR_CFARPROC_INIT_FAILED;
    		}
    
    		inst->maxNumDetObj	=	config->maxNumDetObj;         
    		inst->detectionCFAROutput		=	(RADARDEMO_detectionCFAR_output *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, sizeof(RADARDEMO_detectionCFAR_output), 1);
    		inst->detectionCFAROutput->rangeInd	=	(uint16_t *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(uint16_t), 1);
    		inst->detectionCFAROutput->dopplerInd	=	(uint16_t *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(uint16_t), 1);
    		//not used for range-azimuth CFAR (type 6)
    		//inst->detectionCFAROutput->rangeEst	=	(float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(float), 1);
    		//inst->detectionCFAROutput->dopplerEst	=	(float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(float), 1);
    		inst->detectionCFAROutput->snrEst		=	(float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(float), 1);
    		inst->detectionCFAROutput->noise		=	(float *) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, cfarConfig->maxNumDetObj * sizeof(float), 1);
    
    		if ( (inst->detectionCFAROutput == NULL)
    			|| (inst->detectionCFAROutput->rangeInd == NULL)
    			|| (inst->detectionCFAROutput->dopplerInd == NULL)
    			|| (inst->detectionCFAROutput->snrEst == NULL)
    			|| (inst->detectionCFAROutput->noise == NULL))
    		{
    			errorCode 	=	PROCESS_ERROR_CFARPROC_INOUTALLOC_FAILED;
    		}
    
    	}
    
    	//Capon BF
    	{
    		RADARDEMO_aoaEstCaponBF_config aoaBFConfigParam0;
    		RADARDEMO_aoaEstCaponBF_config *aoaBFConfigParam = &aoaBFConfigParam0;
    		uint8_t antSpacing[MAXANT];
    
    		aoaBFConfigParam->antSpacing = &antSpacing[0];
    		for (i = 0; i < (int32_t)config->numAntenna; i++ )
    		{
    			aoaBFConfigParam->antSpacing[i] = i;
    		}
    
    		aoaBFConfigParam->estAngleResolution = config->doaConfig.estAngleResolution; 
    		aoaBFConfigParam->nRxAnt = config->numAntenna; 
    		aoaBFConfigParam->estAngleRange = config->doaConfig.estAngleRange;
    		aoaBFConfigParam->gamma = config->doaConfig.gamma;
    		aoaBFConfigParam->useCFAR4DopDet = config->doaConfig.useCFAR4DopDet;
    
    		aoaBFConfigParam->dopplerFFTSize = inst->dopplerOversampleFactor * inst->fftSize2D;
            inst->dopplerRes            =   inst->dopplerRes * _rcpsp((float)inst->dopplerOversampleFactor);
    
    		aoaBFConfigParam->nRxAnt = inst->nRxAnt;
    		aoaBFConfigParam->numInputRangeBins = inst->fftSize1D;
    
    		inst->DoAInstance = (void *) RADARDEMO_aoaEstCaponBF_create(aoaBFConfigParam, &inst->aoaBFErrorCode);
    		if (inst->aoaBFErrorCode > RADARDEMO_AOACAPONBF_NO_ERROR)
    		{
    			errorCode 	=	PROCESS_ERROR_DOAPROC_INIT_FAILED;
    		}
    		inst->aoaOutput	=	(RADARDEMO_aoAEstCaponBF_output *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, sizeof(RADARDEMO_aoAEstCaponBF_output), 1);
    		inst->aoaOutput->dopplerIdx	=	(uint16_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, 20 * sizeof(RADARDEMO_aoAEstCaponBF_output), 1);
    		inst->aoaInput		=	(RADARDEMO_aoAEstCaponBF_input *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, sizeof(RADARDEMO_aoAEstCaponBF_input), 1);
    	    inst->aoaInput->fallBackToConvBFFlag = 0; //hardcoded to perform Capon only;
    	    inst->aoaInput->nChirps = config->numChirpPerFrame;
    	    inst->aoaInput->clutterRemovalFlag = config->doaConfig.clutterRemovalFlag;
    		inst->angleRes		=	(float) aoaBFConfigParam->estAngleResolution;
    		config->numAzimuthBin = (uint16_t)inst->numAzimuthBin;
    
    		if ((inst->aoaOutput == NULL) || (inst->aoaInput == NULL))
    		{
    			errorCode 	=	PROCESS_ERROR_DOAPROC_INOUTALLOC_FAILED;
    		}
    	}
    
    
    	inst->framePeriod  = config->framePeriod;
    	inst->pFFT1DBuffer = (cplx16_t *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, inst->numChirpsPerFrame * inst->nRxAnt * inst->fftSize1D * sizeof (cplx16_t), 8);
    
    	inst->mimoModeFlag  	=  config->mimoModeFlag;
    	inst->localPDP  	=  (float * ) radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_DDR_CACHED, 0, inst->numAzimuthBin * inst->fftSize1D * sizeof(float), 8);
    	inst->localPDPPtr	=	(float **)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, inst->fftSize2D*sizeof(float * ), 1);
    	for (i = 0; i < (int32_t) inst->numAzimuthBin; i++)
    	{
    		inst->localPDPPtr[i]	=	(float *)&inst->localPDP[i * inst->fftSize1D];
    	}
        config->heatMapMemSize = inst->fftSize1D * inst->numAzimuthBin * sizeof(float);
        config->heatMapMem = inst->localPDP;
    	memset(inst->localPDP, 0, inst->numAzimuthBin * inst->fftSize1D * sizeof(float));
    	
    
    	//inst->scratchBuffer		=	(float *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, 2 * inst->fftSize1D * sizeof(float), 8);
    
    	inst->benchmarkPtr = (radarProcessBenchmarkObj *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, sizeof(radarProcessBenchmarkObj), 1);
    	inst->benchmarkPtr->bufferLen = 20;
    	inst->benchmarkPtr->bufferIdx = 0;
    	inst->benchmarkPtr->buffer    = (radarProcessBenchmarkElem *)radarOsal_memAlloc(RADARMEMOSAL_HEAPTYPE_LL2, 0, inst->benchmarkPtr->bufferLen * sizeof(radarProcessBenchmarkElem), 1);
    
    	memset(inst->benchmarkPtr->buffer, 0, inst->benchmarkPtr->bufferLen * sizeof(radarProcessBenchmarkElem));
    
    	if ((inst->localPDP == NULL) || (inst->localPDPPtr== NULL)|| (inst->pFFT1DBuffer == NULL)
    		//||(inst->scratchBuffer == NULL) 
    		||(inst->benchmarkPtr == NULL) || (inst->benchmarkPtr->buffer == NULL))
    		errorCode 	=	PROCESS_ERROR_INIT_MEMALLOC_FAILED;
    
    
    	config->benchmarkPtr = inst->benchmarkPtr;
    	config->pFFT1DBuffer = inst->pFFT1DBuffer;
    
    	*procErrorCode = errorCode;
    
    #ifndef CCS
    	System_printf("processCreate: (radarProcessInstance_t *)0x%x\n", (uint32_t)inst);
    	System_printf("processCreate: (RADARDEMO_rangeProc_handle *)0x%x\n", (uint32_t)(inst->rangeFFTInstance));
    	System_printf("processCreate: (RADARDEMO_detectionCFAR_handle *)0x%x\n", (uint32_t)(inst->detectionInstance));
    	System_printf("processCreate: (RADARDEMO_aoaEstCaponBF_handle *)0x%x\n", (uint32_t)(inst->DoAInstance));
    	System_printf("processCreate: (radarProcessBenchmarkObj *)0x%x\n", (uint32_t)(inst->benchmarkPtr));
    	System_printf("processCreate: heatmap (float *)0x%x\n", (uint32_t)(inst->localPDP));
    #endif
    	return (void *) inst;
    }
    
    uint8_t radarRangeProcessRun(void *handle, cplx16_t * pDataIn, cplx16_t * pDataOut)
    {
        radarProcessInstance_t *processInst = (radarProcessInstance_t *)handle;
    
    	processInst->rangeProcInput->inputSignal = pDataIn;
    	processInst->rangeProcInput->chirpNumber = 0;			//irrelavent here because 2D windowing is done in Doppler processing.
    	processInst->rangeProcErrorCode = RADARDEMO_rangeProc_run(
    							processInst->rangeFFTInstance,
    							processInst->rangeProcInput,
    							(void *)pDataOut);
    	return((uint8_t)processInst->rangeProcErrorCode);
    }
    
    uint8_t radarRangeAzimuthProcessRun(void *handle, uint32_t frameNum, int32_t rangeIdx, cplx16_t * pDataIn, float *pDataOut)
    {
        radarProcessInstance_t *processInst = (radarProcessInstance_t *)handle;
    	int32_t i, j;
    	int64_t		lltemp;
    	int64_t     * RESTRICT inputPtr;
    	
    #if 0
        if((frameNum % 10) == 0) {
    		processInst->aoaInput->clutterRemovalFlag = 0;
            processInst->aoaInput->fallBackToConvBFFlag = 1;
    	}
    	else {
            processInst->aoaInput->clutterRemovalFlag = 1;
            processInst->aoaInput->fallBackToConvBFFlag = 0;
    	}
    #endif
    
    	/* phase error compensation*/
    	for (i = 0; i < processInst->nRxAnt; i++)
    	{
    		inputPtr	=	(int64_t *) &pDataIn[i * processInst->fftSize1D];
    		lltemp	=	_itoll(_amem4(&processInst->antPhaseCompCoeff[i]), _amem4(&processInst->antPhaseCompCoeff[i]));
    		for (j = 0; j < (processInst->fftSize1D >> 1); j++)
    		{
    			_amem8(&inputPtr[j])		=	_dcmpyr1(_amem8(&inputPtr[j]), lltemp);
    		}
    	}
    	processInst->aoaInput->rangeIndx = rangeIdx; 
    	processInst->aoaInput->inputAntSamples =  pDataIn;
    	processInst->aoaOutput->rangeAzimuthHeatMap = pDataOut;
    	processInst->aoaInput->processingStepSelector = 0; //BF part
    	processInst->aoaBFErrorCode =     RADARDEMO_aoaEstCaponBF_run(
    							processInst->DoAInstance,
    							processInst->aoaInput,
    							processInst->aoaOutput);
    	return((uint8_t)processInst->aoaBFErrorCode);
    }
    
    
    uint8_t radarFrameProcessRun(void *handle, void * outBuffer)
    {
        radarProcessInstance_t *processInst = (radarProcessInstance_t *)handle;
        uint8_t status = PROCESS_OK;
    	int32_t i, j, k, tempNDet, totalNpnt;
    	uint32_t timeStart, timeStamp;
    	radarProcessBenchmarkObj * benchmarks = processInst->benchmarkPtr;
        radarProcessOutputToTracker * outBuffCntxt;
    
    	outBuffCntxt = (radarProcessOutputToTracker*)outBuffer;
    
    	timeStart	=	ranClock();
    	timeStamp 	=	timeStart;
    	if (benchmarks->bufferIdx > benchmarks->bufferLen)
    		benchmarks->bufferIdx = 0;
    
    	// Detection
    	processInst->cfarErrorCode	=	RADARDEMO_detectionCFAR_run(
                                processInst->detectionInstance,
    							processInst->localPDPPtr,
    							processInst->detectionCFAROutput);
    
    	timeStart	=	ranClock();
    	benchmarks->buffer[benchmarks->bufferIdx].cfarDetectionCycles 	=	timeStart - timeStamp;
    	benchmarks->buffer[benchmarks->bufferIdx].numDetPnts 	=	processInst->detectionCFAROutput->numObjDetected;
    	timeStamp 	=	timeStart;
    
    	tempNDet	=	processInst->detectionCFAROutput->numObjDetected;
    	if (tempNDet > processInst->maxNumDetObj)
    	{
    		tempNDet	=	processInst->maxNumDetObj;
    		status		=	PROCESS_ERROR_CFARPROC_NDET_EXCEEDLIMIT;
    	}
    
    	totalNpnt = 0;
    	processInst->aoaInput->processingStepSelector = 1; //Doppler estimation part
    	for(i = 0; i < tempNDet; i++ )
    	{
    
    		processInst->aoaInput->rangeIndx = processInst->detectionCFAROutput->rangeInd[i]; 
    		processInst->aoaInput->azimuthIndx = processInst->detectionCFAROutput->dopplerInd[i]; 
    		processInst->aoaInput->inputAntSamples = &processInst->pFFT1DBuffer[processInst->aoaInput->rangeIndx * processInst->nRxAnt * processInst->numChirpsPerFrame];
    		processInst->aoaInput->bwDemon = processInst->localPDPPtr[processInst->aoaInput->azimuthIndx][processInst->aoaInput->rangeIndx];
    		processInst->aoaBFErrorCode =     RADARDEMO_aoaEstCaponBF_run(
    								processInst->DoAInstance,
    								processInst->aoaInput,
    								processInst->aoaOutput);
    
    		for (k = 0; k < processInst->aoaOutput->numDopplerIdx; k++)
    		{
    			outBuffCntxt->angle[totalNpnt]		=	RAD_TO_DEG * processInst->aoaOutput->angleEst;
    			outBuffCntxt->range[totalNpnt]		=	(float)processInst->detectionCFAROutput->rangeInd[i] * processInst->rangeRes;
    			if ((uint32_t)processInst->aoaOutput->dopplerIdx[k] >= ((processInst->dopplerOversampleFactor * processInst->fftSize2D) >> 1))
    				j			=	(int32_t)processInst->aoaOutput->dopplerIdx[k] - (int32_t)(processInst->dopplerOversampleFactor * processInst->fftSize2D);
    			else
    				j			=	(int32_t)processInst->aoaOutput->dopplerIdx[k];
    
    			outBuffCntxt->doppler[totalNpnt] = (float)j * processInst->dopplerRes;
    			outBuffCntxt->snr[totalNpnt]	=	processInst->detectionCFAROutput->snrEst[i] ;
    			totalNpnt++;
    			if (totalNpnt > DOA_OUTPUT_MAXPOINTS)
    				break;
    		}
    	}
    
    
    	outBuffCntxt->object_count = totalNpnt;
        timeStart   =   ranClock();
        benchmarks->buffer[benchmarks->bufferIdx].dopplerEstCycles   =   timeStart - timeStamp;
        timeStamp   =   timeStart;
    	
        benchmarks->bufferIdx++;
        if (benchmarks->bufferIdx > benchmarks->bufferLen)
            benchmarks->bufferIdx = 0;
    
        return status;
    
    }
    
    
    int32_t processDelete(void *handle)
    {
        radarProcessInstance_t *inst = (radarProcessInstance_t *)handle;
        //EDMA3_DRV_Result edma3Result = EDMA3_DRV_SOK;
    
        RADARDEMO_rangeProc_delete(inst->rangeFFTInstance);
        RADARDEMO_detectionCFAR_delete(inst->detectionInstance);
    	RADARDEMO_aoaEstCaponBF_delete(inst->DoAInstance);
    
        radarOsal_memFree(inst->rangeProcInput, sizeof(RADARDEMO_rangeProc_input));
    
        radarOsal_memFree(inst->localPDPPtr, inst->fftSize2D*sizeof(float * ));
        radarOsal_memFree(inst->localPDP, inst->fftSize2D * inst->fftSize1D * sizeof(float));
    
        radarOsal_memFree(inst->detectionCFAROutput->rangeInd, inst->maxNumDetObj *sizeof(uint16_t ));
        radarOsal_memFree(inst->detectionCFAROutput->dopplerInd, inst->maxNumDetObj *sizeof(uint16_t ));
        radarOsal_memFree(inst->detectionCFAROutput->rangeEst, inst->maxNumDetObj *sizeof(float ));
        radarOsal_memFree(inst->detectionCFAROutput->dopplerEst, inst->maxNumDetObj *sizeof(float ));
        radarOsal_memFree(inst->detectionCFAROutput->snrEst, inst->maxNumDetObj *sizeof(float ));
        radarOsal_memFree(inst->detectionCFAROutput->noise, inst->maxNumDetObj *sizeof(float ));
        radarOsal_memFree(inst->detectionCFAROutput, sizeof(RADARDEMO_detectionCFAR_output));
    
        radarOsal_memFree(inst->aoaOutput, inst->maxNumDetObj *sizeof(RADARDEMO_aoAEstCaponBF_output ));
        radarOsal_memFree(inst->aoaInput, sizeof(RADARDEMO_aoAEstCaponBF_input));
    
        radarOsal_memFree(inst->pFFT1DBuffer, 2 * inst->nRxAnt * inst->fftSize2D * inst->fftSize1D * sizeof (float));
        radarOsal_memFree(inst->aoaInputSignal, 2 * inst->nRxAnt * sizeof (float));
        //radarOsal_memFree(inst->scratchBuffer, 2 * inst->fftSize1D * sizeof (float));
    
        radarOsal_memFree(inst->benchmarkPtr->buffer, inst->benchmarkPtr->bufferLen * sizeof(radarProcessBenchmarkElem));
        radarOsal_memFree(inst->benchmarkPtr, sizeof(radarProcessBenchmarkObj));
    
        radarOsal_memFree(handle, sizeof(radarProcessInstance_t));
    
        return PROCESS_OK;
    
    }
    
    

  • Hi,

    Since the DPU's are assembly-level optimized, they can be tricky to follow. My best recommendation would be to use CCS Debug in order to view the disassembly and memory browser in order to help you to follow the code.

    Best Regards,
    Alec