Other Parts Discussed in Thread: CC1310
您好:
目前我在使用CC1310的SPI Master模式,需求是SPI MASTER模式下可以一次发送256个字节, 按照API中的例程,可以正常发送Hello World,但是将需要发送的数组赋值为100个字节运行后,发现只能打出前28个字节。
按照API说明:SPI的TX每次最多可以发送1024个字节:
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 cancelled 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.
代码如下:
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(¶ms); 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, ¶ms); while(1) { for(x=0;x<100;x++) { txBufdata[x]=x; } SPI_transfer(handle, &transaction); } }
麻烦您看下或者提供下可用例程,谢谢!