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.

AM62L: IWRL6432 radar module SPI communication issue

Part Number: AM62L
Other Parts Discussed in Thread: IWRL6432, SYSCONFIG

Hi, 

I am using the AM62Lx board with part number XAM62L32B0GHAANB.
I have connected the IWRL6432 (V-LD3 radar module) to the AM62Lx via the UART interface, and it is working correctly. 
Now, I would like to test and validate the SPI interface

Using the SysConfig tool, I have configured the required MCSPI pin settings
Screenshot 2025-12-29 160647.png

I have attached my sample application code that communicates with the radar over SPI. 

#include <stdio.h>
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"


#include <drivers/i2c/v0/i2c.h>
#include <stdint.h>
#include <drivers/mcspi.h>

/* Function to check I2C interface is working or not */
void test_p(){
    int32_t status; 

    /* Initialize new transaction struct; controller mode enabled by default */
    I2C_Transaction i2cTransaction;
    I2C_Transaction_init(&i2cTransaction);

    DebugP_log("I2C_Transaction_init function is completed\n");

    /* Configure write buffer */
    uint8_t txBuffer[10] = {0x00};
    txBuffer[0] = 0x6A;
    i2cTransaction.writeBuf   = txBuffer;
    i2cTransaction.writeCount = 1;

    DebugP_log("tx_Buffer is written\n");

    /* Configure read buffer */
    uint8_t rxBuffer[10] = {0x5A};    
    i2cTransaction.readBuf   = rxBuffer;
    i2cTransaction.readCount = 1;

    DebugP_log("rx_Buffer is written\n");

    /* Configure device to target mode */
    i2cTransaction.controllerMode = 0; 
    i2cTransaction.timeout = 100000;

    DebugP_log("controller mode & timeout is written\n");

    while(true)
    {
        /* Blocking Mode: Halt program until message received from controller 
        Callback Mode: Trigger interrupt callback upon message received from controller */
        status = I2C_transfer(gI2cHandle[0], &i2cTransaction);

        DebugP_log("I2C_transfer is completed \n");

        if(status != SystemP_SUCCESS)
        {
            DebugP_log("I2C transfer failed\r\n");
            DebugP_assert(FALSE); 
        }
        else
        {
            DebugP_log("I2C read OK: 0x%02x\r\n", rxBuffer[0]);
        }
        ClockP_usleep(10000);
    }
}

/* Function: To check SPI node working or not */
void testMcspiProbe(void)
{
    int32_t     status;
    MCSPI_Handle handle = gMcspiHandle[0];  // SysConfig-generated handle (CONFIG_MCSPI0)

    /* Fixed response pattern sent back to master (AM62Lx) */
    uint8_t txBuf[32] = {
        0xA5, 0x5A, 0xA5, 0x5A, 0xA5, 0x5A, 0xA5, 0x5A,
        0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };

    uint8_t rxBuf[32] = {0};

    DebugP_log("Radar SPI slave ready - waiting for master commands...\r\n");

    while (true)
    {
        MCSPI_Transaction transaction;
        MCSPI_Transaction_init(&transaction);

        transaction.channel   = 0U;                 /* Channel 0 */
        transaction.csDisable = TRUE;               /* De-assert CS at end of transfer */
        transaction.dataSize  = 8U;                 /* 8-bit frames */
        transaction.count     = 32U;                /* Transfer 32 bytes */
        transaction.txBuf     = txBuf;              /* Fixed data sent to master */
        transaction.rxBuf     = rxBuf;              /* Capture data from master */
        transaction.args      = NULL;

        /* In peripheral/slave mode, this call BLOCKS until master initiates a transfer */
        status = MCSPI_transfer(handle, &transaction);

        if (status == SystemP_SUCCESS && transaction.status == MCSPI_TRANSFER_COMPLETED)
        {
            DebugP_log("Transfer complete! Received from master: ");
            for (int i = 0; i < 32; i++)
            {
                DebugP_log("%02X ", rxBuf[i]);
            }
            DebugP_log("\r\nSent response: A5 5A A5 5A ... EF\r\n");
        }
        else
        {
            DebugP_log("MCSPI transfer failed (status %d, transaction status %d)\r\n",
                       status, transaction.status);
        }
    }
}

void hello_world_main(void *args)
{
    /* Open drivers to open the UART driver for console */
    Drivers_open();
    Board_driversOpen();

    DebugP_log("Demo test of radar\n");

    testMcspiProbe();
    //test_p();

    DebugP_log("Hello World!\r\n");

    Board_driversClose();
    Drivers_close();
}

 

I have also attached:

  • The radar hardware schematics and photos for reference


   

  • The SPI node details from the AM62Lx DTS file, shown below:

&main_spi0 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&radar_pins_default>;

        #address-cells = <1>;
        #size-cells = <0>;

        radar_spidev: spidev@0 {
                compatible = "rohm,dh2228fv";
                //compatible = "linux,spidev";
                reg = <0>;                  /* CS0 */
                spi-max-frequency = <1000000>;  /* Matches your radar SysConfig 1MHz */
                /* Mode 0 (CPOL=0, CPHA=0) and CS active low are defaults - no need to set */
        };
};
 radar_pins_default: radar-default-pins {
                pinctrl-single,pins = <
                        AM62LX_IOPAD(0x01a8, PIN_OUTPUT, 0) /* (E13) SPI0_CLK */
                        AM62LX_IOPAD(0x01ac, PIN_OUTPUT, 0) /* (E12) SPI0_D0 */
                        AM62LX_IOPAD(0x01b0, PIN_INPUT, 0) /* (B12) SPI0_D1 */
                        AM62LX_IOPAD(0x01a0, PIN_OUTPUT, 0) /* (E11) SPI0_CS0 */
                >;
        };


I also wrote a Linux user-space test application that transfers data from the MPU (AM62Lx) to the radar and reads the response back.

  • I am able to send data from the MPU, and it is received correctly on the radar side

  • However, when the radar sends data back, the MPU always receives all zeros

Example output:

$ ./radar_spi_test
Sent to radar:     01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
                  11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Received from radar: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Linux SPI Test Application (MPU Side):

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
#include <stdint.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

int main(void)
{
    const char *device = "/dev/spidev0.0";  // CHANGE if yours is different (e.g., spidev1.0)
    int fd = open(device, O_RDWR);
    if (fd < 0) {
        perror("Can't open spidev device");
        return 1;
    }

    // Configure SPI mode, bits, speed (matches radar: Mode 0, 8-bit, 1MHz)
    uint8_t mode = SPI_MODE_0;
    uint8_t bits = 8;
    uint32_t speed = 1000000;  // 1 MHz

    ioctl(fd, SPI_IOC_WR_MODE, &mode);
    ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
    ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);

    // Test pattern to send (32 bytes - matches your radar code)
    uint8_t tx[] = {
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
        0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
        0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20
    };

    uint8_t rx[ARRAY_SIZE(tx)] = {0};

    struct spi_ioc_transfer tr = {
        .tx_buf = (unsigned long)tx,
        .rx_buf = (unsigned long)rx,
        .len = ARRAY_SIZE(tx),
        .speed_hz = speed,
        .bits_per_word = bits,
    };

    int ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
    if (ret < 1) {
        perror("SPI transfer failed");
        close(fd);
        return 1;
    }

    printf("Sent to radar:     ");
    for (int i = 0; i < ARRAY_SIZE(tx); i++) printf("%02X ", tx[i]);
    printf("\n");

    printf("Received from radar: ");
    for (int i = 0; i < ARRAY_SIZE(rx); i++) printf("%02X ", rx[i]);
    printf("\n");

    // Expected receive: A5 5A A5 5A A5 5A A5 5A 12 34 56 78 90 AB CD EF 00 00 ...

    close(fd);
    return 0;
}


Regards,
Parv

  • Hello Parv,

    Just to clarify, the AM62x side of code is written in MCU+ SDK? Or it is written in Linux SDK?

    The code which I am talking about is AM62x MCSPI configured as a Controller.

    Looking forward to your response.

    Thanks,

    Vaibhav

  • Hello Vaibhav,

    The AM62Lx-side code is developed on Linux.
    The Linux SPI test application (MPU side) is written in C and cross-compiled for the board to verify whether the SPI communication is working correctly.

    The sample application code is generated using the radar firmware SysConfig tool, and it has been flashed onto radar module.

    Thanks,
    Parv


  • Hi Parv,

    Thanks for the confirmation.

    I would have this routed to another expert, who can help you answer better on the Linux front.

    Please expect delayed responses as the concerned expert is currently out of office.

    Thanks,

    Vaibhav

  • Additionally,

    Could you set PIN_INPUT to both CLK and D1 lines, and then PIN_OUTPUT to D0 and CS0 lines?

    If the above does not work try PIN_INPUT for all CLK, D0, D1 and CS0 lines.

    Let me know if this works.