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.

RTOS/TDA2PXEVM: SPI data is a mixture of "RX data" and TX data" in inBuffer

Part Number: TDA2PXEVM

Tool/software: TI-RTOS

Hi TI


I am developing MCSPI on slave side using "GIO_issue and GIO_reclaim" (My master is out of device.)
But, I am facing some problem.
When I check inBuffer after GIO_issue and GIO_reclaim, it seem that the data is a mixture of "RX data" and TX data"
Our master is sending some data that is from 0x1 ~ to 0x14, but Tx data is included in inBuffer as shwon below.


[IPU1-0] 20.797200 s:
[IPU1-0] Rx data = 0x0 ->rx data
[IPU1-0] 20.797261 s:
[IPU1-0] Rx data = 0x1 ->rx data
[IPU1-0] 20.797322 s:
[IPU1-0] Rx data = 0x2 ->rx data
[IPU1-0] 20.797352 s:
[IPU1-0] Rx data = 0x3 ->rx data

[IPU1-0] 20.797413 s:
[IPU1-0] Rx data = 0x0 ->tx data
[IPU1-0] 20.797474 s:
[IPU1-0] Rx data = 0x0 ->tx data
[IPU1-0] 20.797535 s:
[IPU1-0] Rx data = 0x0 ->tx data
[IPU1-0] 20.797596 s:
[IPU1-0] Rx data = 0x0 ->tx data

[IPU1-0] 20.797657 s:
[IPU1-0] Rx data = 0x4 ->rx data
[IPU1-0] 20.797718 s:
[IPU1-0] Rx data = 0x5 ->rx data
[IPU1-0] 20.797779 s:
[IPU1-0] Rx data = 0x6 ->rx data
[IPU1-0] 20.797840 s:
[IPU1-0] Rx data = 0x7 ->rx data

[IPU1-0] 20.797901 s:
[IPU1-0] Rx data = 0x0 ->tx data
[IPU1-0] 20.797932 s:
[IPU1-0] Rx data = 0x0 ->tx data
[IPU1-0] 20.797993 s:
[IPU1-0] Rx data = 0x1 ->tx data
[IPU1-0] 20.798054 s:
[IPU1-0] Rx data = 0x2 ->tx data

[IPU1-0] 20.798115 s:
[IPU1-0] Rx data = 0x8
[IPU1-0] 20.798176 s:
[IPU1-0] Rx data = 0x9
[IPU1-0] 20.798206 s:
[IPU1-0] Rx data = 0xa
[IPU1-0] 20.798267 s:
[IPU1-0] Rx data = 0xb

[IPU1-0] 20.798328 s:
[IPU1-0] Rx data = 0x7
[IPU1-0] 20.798389 s:
[IPU1-0] Rx data = 0x8
[IPU1-0] 20.798420 s:
[IPU1-0] Rx data = 0x9
[IPU1-0] 20.798481 s:
[IPU1-0] Rx data = 0xa

[IPU1-0] 20.798542 s:
[IPU1-0] Rx data = 0xc
[IPU1-0] 20.798603 s:
[IPU1-0] Rx data = 0xd
[IPU1-0] 20.798664 s:
[IPU1-0] Rx data = 0xe
[IPU1-0] 20.798725 s:
[IPU1-0] Rx data = 0xf

[IPU1-0] 20.798786 s:
[IPU1-0] Rx data = 0xf
[IPU1-0] 20.798847 s:
[IPU1-0] Rx data = 0x10
[IPU1-0] 20.798908 s:
[IPU1-0] Rx data = 0x11
[IPU1-0] 20.798938 s:
[IPU1-0] Rx data = 0x12

[IPU1-0] 20.798999 s:
[IPU1-0] Rx data = 0x10
[IPU1-0] 20.799060 s:
[IPU1-0] Rx data = 0x11
[IPU1-0] 20.799121 s:
[IPU1-0] Rx data = 0x12
[IPU1-0] 20.799182 s:
[IPU1-0] Rx data = 0x13

[IPU1-0] 20.799243 s:
[IPU1-0] Rx data = 0x17
[IPU1-0] 20.799274 s:
[IPU1-0] Rx data = 0x18
[IPU1-0] 20.799335 s:
[IPU1-0] Rx data = 0x19
[IPU1-0] 20.799396 s:
[IPU1-0] Rx data = 0x1a

[IPU1-0] 20.799457 s:
[IPU1-0] Rx data = 0x14
[IPU1-0] 20.799518 s:
[IPU1-0] Rx data = 0x0
[IPU1-0] 20.799548 s:
[IPU1-0] Rx data = 0x1
[IPU1-0] 20.799640 s:
[IPU1-0] Rx data = 0x2

I want to get only RX data in inBuffer.
Please check my work and help me~
Thank you.

  • My code is as shown below...



    Mcspi_DataParam myissueDataParam[NUM_BUFS];
    Mcspi_DataParam *dataparam = {0};




    IHeap_Handle iheap;

    Error_Block eb;


    iheap = HeapMem_Handle_to_xdc_runtime_IHeap(myHeap);
    Error_init(&eb);

    /* Allocate buffers for the GIO buffer exchanges for McSPI1 */
    for (count = 0; count < (NUM_BUFS); count++)
    {
    rxbuf[count] = (Ptr) Memory_calloc(iheap, BUFLEN, BUFALIGN, &eb);
    if (NULL == rxbuf[count])
    {
    Vps_printf("\r\nMEM_calloc failed.\r\n");
    }

    txbuf[count] = (Ptr) Memory_calloc(iheap, BUFLEN, BUFALIGN, &eb);
    if (NULL == txbuf[count])
    {
    Vps_printf("\r\nMEM_calloc failed.\r\n");
    }
    }

    for (count = 0; count < (NUM_BUFS); count++)
    {
    for(tempcount = 0; tempcount < (BUFLEN); tempcount++)
    ((Uint8 *)txbuf[count])[tempcount] = tempcount;

    }



    for (count = 0; count < NUM_BUFS; count++)
    {
    myissueDataParam[count].bufLen = BUFLEN;
    //myissueDataParam[count].inBuffer = (UInt8 *) rxbuf[count];
    //myissueDataParam[count].outBuffer = (UInt8 *) txbuf[count];
    myissueDataParam[count].inBuffer = rxbuf[count];
    myissueDataParam[count].outBuffer = txbuf[count];
    //myissueDataParam[count].outBuffer = NULL;

    size = myissueDataParam[count].bufLen;

    /* Issue the first & second empty buffers to the input stream */
    status = GIO_issue(mcspiHandle, &myissueDataParam[count], size, NULL);
    Vps_printf("\r\n GIO_issue status %d \r\n", status);

    if (status != IOM_PENDING && status != IOM_COMPLETED)
    {
    Vps_printf("\r\nFailed to issue empty buffer to stream\r\n");
    }
    else
    {
    Vps_printf("\r\nsuccess to stream\r\n");
    }

    }


    for (count = 0; count < NUM_BUFS; count++)
    {
    dataparam = NULL;
    status = GIO_reclaim((GIO_Object *) mcspiHandle, (Ptr *) &dataparam, NULL, NULL);
    Vps_printf("\r\n stauts = %d \r\n", status);
    if (IOM_COMPLETED != status)
    {
    Vps_printf("KTKT Iteration Error!!");
    break;
    }
    for (tempcount = 0; tempcount < BUFLEN;)
    {
    Vps_printf("\r\n Rx data = 0x%x \r\n",dataparam->inBuffer[tempcount]);
    //Vps_printf("\r\n Tx data = 0x%x \r\n",dataparam->outBuffer[tempcount]);
    tempcount++;

    }
    }
  • Hi TI~

    GiO_issue`s return status is "IOOM_PENDING" but, I called GIO_reclaim.
    Is it possible to cause my problem?

    Thank you
  • Hi TI

    Please help me~

    Thank you

  • Hi Kim,

    Can you check the SPI pin direction settings done in your application and the actual connection in your evm?

    For the driver the data direction is set as part of the init function called when creating the driver instance.
    Check the settings of mcspi0Prms.spiHWCfgData.configChfmt[0].spiDat0Dir and mcspi0Prms.spiHWCfgData.configChfmt[0].spiDat1Dir.

    For the GIO_issue return value, if you are using the interrupt or dma modes, the GIO_issue returns with the "IOM_PENDING" immediately.
    The GIO_reclaim is the blocking call which returns after completion of the transfer.

    Regards,
    Prasad
  • HI Prasad~

    I am uisng MCSPI4 as slave mode and setting all physical channel(0 ~3) is same

    Our dataline is same as below.
    - data line 0 = MCSPI_OUT
    - data line 1 = MCSPI_IN

    I checked that data line set is sent to mcspiChannelConf() in bsp_mcspi.c and dataLineCommMode is MCSPI_DATA_LINE_COMM_MODE_6

    #define MCSPI_DATA_LINE_COMM_MODE_6 (((uint32_t) MCSPI_CH0CONF_IS_LINE1 << \
    MCSPI_CH0CONF_IS_SHIFT) | \
    ((uint32_t) MCSPI_CH0CONF_DPE1_DISABLED \
    << MCSPI_CH0CONF_DPE1_SHIFT) | \
    ((uint32_t) MCSPI_CH0CONF_DPE0_ENABLED << \
    MCSPI_CH0CONF_DPE0_SHIFT))


    Our tx buffer (outBuffer) is no problem and only rx buffer (inBuffer) includes rx data and tx data.
    Also, in driver(bsp_mcspi.c), when I get rxBuffer, tx data is gradually included to rxBuffer.

    Why is it? and what other points do I check?
     
    Thank you.

  • Slave is receving 4byte data from master device. and It includes 4byte of rx data and 4byte tx data sequentially.

    If master sends 5byte data, slave inBuffer includes 5byte of rx data and 3byte tx data sequentially.

    Isn`t it possible that it is from shift register timming...?

    Thank you

  • Sorry ~ Prasad~

    Our MCU is not senidg data well.
    So, slave data has some problems.


    Thank you