Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

[FAQ] IWR6843: How to add a hard coded configuration to mmWave radar projects

Part Number: IWR6843

By default, the mmWave radar demonstration labs accept configuration commands over UART to set up the device with the desired settings. To provide flexibility, these are typically stored in a text file and sent at startup, but this requires a PC connection and takes a small amount of time. When using the devices remotely, or if repeating measurements, it can be very helpful to have these configuration values 'hard coded' so the device will boot, configure, chirp, and output data without further input from the user. 

This functionality can be added very easily to any of the existing demos using the already built CLI driver. The instructions below illustrate a fast way to add this functionality.

    • There are 2 main methods of hard coding the cfg file: Using the existing CLI driver and bypassing the CLI
      • An example of using HCC with CLI bypass is provided in the lab "Hard Coded Config for OOB Demo".
        • This works perfectly well, but can be rather difficult to modify the cfg parameters and is quite prone to typos affecting functionality
      • It can be easier to implement HCC by utilizing the existing CLI driver that will make it very simple to switch back and forth between HCC and sending the CFG file in one project.
    • The setup of the IWR device and CLI has the following simplified flow.
      PcountDemo3D_initTask --> Pcount3DDemo_CLIInit --> CLI_open
      • General initialization task calls the CLIInit function. At the end of this CLIInit function, the CLI is opened to receive commands.
      • However, at this point there are still other initializations that need to happen before the device is ready to start. So the cfg parameters cannot be set directly after this CLIInit function, instead they should be added to the CLI_task() in cli.c (C:\ti\mmwave_sdk_VER\packages\ti\utils\cli\src)
    • In cli.c
      • Define the HCC option
        • Add "#define USE_HARD_CODED_CONFIG" to the top of the file. (You can use any macro name you like)
      • Add a char array of all the config parameters as they would appear in the .cfg file. Use '#ifdef USE_HARD_CODED_CONFIG' to enable turning off HCC functionality in the future if desired. Include an integer variable for looping through the cfg paramerters.

    #ifdef USE_HARD_CODED_CONFIG

     

    int32_t hardCodedConfigIndex;

     

    char * hardCodedConfigCommands[] =

    {

    "sensorStop ",

     "flushCfg ",

    "dfeDataOutputMode 1 ",

     …

     …

    "!!!END_OF_HARD_CODED_COMMANDS"

    };

     

    #endif

    • Include an identifier to signal the end of the commands inside the array with a '!' or other character not used in the cfg parameters.
      • e.g. "!!!END_OF_HARD_CODED_COMMANDS"
    • Inside CLI_task()
      • Before the while(1) loop
        • add a section to pause the task for further system initialization. Include some UART prints for clarity if desired.

    #ifdef USE_HARD_CODED_CONFIG

        hardCodedConfigIndex = 0;

        CLI_write ("Wait some time for system to initialize...\n");

        Task_sleep(100);

        CLI_write ("Performing hard-coded config\n");

    #endif

    • Inside the while(1) loop
      • Add the loop to read in the cha array of cfg parameters added at the top of the file. This replaces the UART_read line that would get the cfg parameter from the UART connection. Bypass this with a #ifdef/#else to revert to the UART communication if HCC is turned off.
         

    #ifdef USE_HARD_CODED_CONFIG

            /* Run hard-coded commands, one at a time until '!!!END_OF_HARD_CODED_COMMANDS' is reached: */

            if (hardCodedConfigCommands[hardCodedConfigIndex][0] != '!')

            {

                //CLI_write (hardCodedConfigCommands[hardCodedConfigIndex]);

                CLI_write ("Command\n");

                memcpy((void *)&cmdString[0], (void *)hardCodedConfigCommands[hardCodedConfigIndex],   

    strlen(hardCodedConfigCommands[hardCodedConfigIndex]));

                hardCodedConfigIndex++;

            }

            /* Accept commands from UART after all hard-coded commands done: */

            else

            {

                /* Read the command message from the UART: */

                UART_read (gCLI.cfg.cliUartHandle, &cmdString[0], (sizeof(cmdString) - 1));

            }

     

    #else

            /* Read the command message from the UART: */

            UART_read (gCLI.cfg.cliUartHandle, &cmdString[0], (sizeof(cmdString) - 1));

    #endif

    • Recompile the cli driver in the SDK using the instructions in the SDK user's guide
    • Rebuild the CSS project you are using and reflash the binary generated (or run in debug mode) onto the IWR device. On powerup, the device should start up and begin outputting data on the UART lines (or whichever output was configured in the HCC section) without waiting for user input from a GUI or otherwise.
    • If you do not wish to modify the SDK cli.c file (if you are using the SDK for multiple different projects or configurations) you can copy this file into the CCS project folder and include it in the project to build a local version overwriting the SDK file.
      • Copy files from the SDK CLI path above and place in the common src folder for the desired toolbox project. (Probably this is cli.c and cli_mmwave.c)
        "C:\ti\mmwave_industrial_toolbox_VER\labs\lab_folder\68xx_lab\src\common" (the version and specific lab should be updated to whichever lab you are modifying)