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.

LAUNCHXL-CC1310: SPI Master transfer

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Hi Team,

At present, I am using the SPI Master mode of CC1310. What I need is that 256 bytes can be sent at a time in SPI MASTER mode. According to the routine in the API, Hello World can be sent normally. However, after I assigned 100 bytes to the array that needs to be sent and ran it, I found that only the first 28 bytes could be printed.

According to the API description, SPI TX can send up to 1024 bytes each time.

At present, I suspect that the timeout period has not been set properly. Might this be the cause of the issue?

Transfer Size Limit

The UDMA controller only supports data transfers of up to 1024 data frames. A transfer with more than 1024 frames will be transmitted/received in multiple 1024 sized portions until all data has been transmitted/received. A data frame can be 4 to 16 bits in length.

Timeout
Timeout can occur in SPI_MODE_BLOCKING, there's no timeout in SPI_MODE_CALLBACK. When in SPI_MODE_CALLBACK, the transfer must be canceled by calling SPI_transferCancel().
If a timeout happens in either SPI_SLAVE or SPI_MASTER mode, the receive buffer will contain the bytes received up until the timeout occurred. The SPI transaction status will be set to SPI_TRANSFER_FAILED. The SPI transaction count will be set to the number of bytes sent/received before timeout. The remaining bytes will be flushed from the TX FIFO so that the subsequent transfer can be executed correctly. Note that specifying a timeout prevents the driver from performing a polling transfer when in slave mode.

The code is as follows.

void *mainThread(void *arg0)
{
    GPIO_init();
    SPI_init();
    uint8_t x;
    SPI_Handle handle;
    SPI_Params params;
    SPI_Transaction transaction;
    uint8_t txBufdata[100];
    uint8_t rxBuf[11];
    SPI_Params_init(&params);
    params.bitRate     = 4000000;
    params.frameFormat = SPI_POL1_PHA1;
    params.mode        = SPI_MASTER;
    transaction.count = sizeof(txBufdata);
    transaction.txBuf = txBufdata;
    transaction.rxBuf = rxBuf;
    handle = SPI_open(Board_SPI_MASTER, &params);
    while(1)
    {
    for(x=0;x<100;x++)
       {
        txBufdata[x]=x;
       }
        SPI_transfer(handle, &transaction);
    }
}

 Could you have a look at my issue or provide any routine available? Thank you in advance.

Kind regards,

Katherine

  • You say you want to transmit 256 bytes, but have a tx buffer of 100 bytes???

    I tested the following and did not have any problems transmitting 256 bytes:

    #define THREADSTACKSIZE (2048)
    #define SPI_MSG_LENGTH  (256)
    
    unsigned char masterTxBuffer[SPI_MSG_LENGTH];
    
    void *masterThread(void *arg0)
    {
        SPI_Handle      masterSpi;
        SPI_Params      spiParams;
        SPI_Transaction transaction;
        uint16_t        i;
    
        SPI_Params_init(&spiParams);
        spiParams.frameFormat = SPI_POL0_PHA1;
        spiParams.bitRate = 4000000;
        masterSpi = SPI_open(Board_SPI_MASTER, &spiParams);
    
        for(i = 0; i <= 255; i++)
        {
            masterTxBuffer[i] = i;
        }
    
        transaction.count = SPI_MSG_LENGTH;
        transaction.txBuf = (void *) masterTxBuffer;
        transaction.rxBuf = NULL;
    
        SPI_transfer(masterSpi, &transaction);
    
        while(1);
    }

    Siri