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 主设备传输

Guru**** 2484615 points
Other Parts Discussed in Thread: CC1310

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1199936/launchxl-cc1310-spi-master-transfer

器件型号:LAUNCHXL-CC1310
主题中讨论的其他器件:CC1310

大家好、

目前、我使用的是 CC1310的 SPI 主模式。  我需要的是 、在 SPI 主控模式下、一次可以发送256字节。 根据 API 中的例程、可以正常发送 Hello World。 但是、在我为需要发送 并运行的阵列分配了100个字节后、 我发现只能打印前28个字节。

根据 API 说明、SPI TX 每次最多可发送1024字节。

目前 ,我怀疑超时期限没有适当设置。 这可能是问题的原因吗?

传输大小限制

UDMA 控制器仅支持多达1024个数据帧的数据传输。 超过1024帧的传输将在1024大小的多个部分中发送/接收、直到发送/接收完所有数据。 数据帧的长度可以是4到16位。

超时
超时可能发生在 SPI_MODE_BLOCKING 中、在 SPI_MODE_CALLING 中没有超时。 当处于 SPI_MODE_CALLACK 中时、传输必须通过调用 SPI_TRANSACancel()来取消。
如果在 SPI_SLAVE 或 SPI_MASTER 模式下发生超时、接收缓冲区将包含接收到的字节、直到超时发生。 SPI 事务状态将设置为 SPI_TRANSFER_FAILED。 SPI 事务计数将设置为超时前发送/接收的字节数。 剩余的字节将从 TX FIFO 中清空、以便后续的传输可以正确执行。 请注意、指定超时会阻止驱动程序在从模式下执行轮询传输。

代码 如下所示。

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);
    }
}

 您能否查看我的问题或提供任何可用的例程? 提前感谢您。

此致、

凯瑟琳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您说要传输256字节、但 TX 缓冲区为100字节???

    我测试了以下内容、在传输256字节时没有任何问题:

    #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