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-CC2650: How to use SPI in CC2650 when CS is PIN_UNASSIGNED

Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: CC2650, SIMPLELINK-CC13X0-SDK

Dear Engineer,

I am trying to let two CC2650 launchpad communicate with each other using SPI. In "CC2650_LAUNCHXL.h", the PIN defination is 

"

/* SPI Board */
#define Board_SPI0_MISO IOID_8 /* RF1.20 */
#define Board_SPI0_MOSI IOID_9 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN PIN_UNASSIGNED
#define Board_SPI1_MISO PIN_UNASSIGNED
#define Board_SPI1_MOSI PIN_UNASSIGNED
#define Board_SPI1_CLK PIN_UNASSIGNED
#define Board_SPI1_CSN PIN_UNASSIGNED

"

The CS is PIN_UNASSIGNED, I don't know how to deal with this unsignment, so that the slave can be select. As I learned that only CS=0, the slave is selected.

I used Board_SPI0 and write program as follows.

For master:

"

SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
uint8_t transmitBuffer[MSGSIZE];
uint8_t receiveBuffer[MSGSIZE];
bool transferOK;
SPI_init(); // Initialize the SPI driver
SPI_Params_init(&spiParams); // Initialize SPI parameters
spiParams.dataSize = 8; // 8-bit data size
spi = SPI_open(Board_SPI0, &spiParams);
if (spi == NULL) {
while (1); // SPI_open() failed
}
// Fill in transmitBuffer
spiTransaction.count = MSGSIZE;
spiTransaction.txBuf = transmitBuffer;
spiTransaction.rxBuf = receiveBuffer;

transmitBuffer[2]=2;

transferOK = SPI_transfer(spi, &spiTransaction);
if (transferOK) {
uartTxBufferOffset = System_sprintf(uartTxBuffer,
"\r\n aaa \r\n");
uartTxBuffer[uartTxBufferOffset] = '\n';
UART_write(uart, uartTxBuffer, uartTxBufferOffset + 1);
}else{
uartTxBufferOffset = System_sprintf(uartTxBuffer,
"\r\n bbb \r\n");
uartTxBuffer[uartTxBufferOffset] = '\n';
UART_write(uart, uartTxBuffer, uartTxBufferOffset + 1);
}

"

For slaver,

"

SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
uint8_t transmitBuffer[MSGSIZE];
uint8_t receiveBuffer[MSGSIZE];
bool transferOK;
SPI_init(); // Initialize the SPI driver
SPI_Params_init(&spiParams); // Initialize SPI parameters
spiParams.dataSize = 8; // 8-bit data size
spiParams.mode=SPI_SLAVE;
spi = SPI_open(Board_SPI0, &spiParams);
if (spi == NULL) {
while (1); // SPI_open() failed
}
// Fill in transmitBuffer
spiTransaction.count = MSGSIZE;
spiTransaction.txBuf = transmitBuffer;
spiTransaction.rxBuf = receiveBuffer;
transferOK = SPI_transfer(spi, &spiTransaction);
if (transferOK) {
uartTxBufferOffset = System_sprintf(uartTxBuffer,
"\r\n aaa:%d \r\n",receiveBuffer[2]);
uartTxBuffer[uartTxBufferOffset] = '\n';
UART_write(uart, uartTxBuffer, uartTxBufferOffset + 1);
}else{
uartTxBufferOffset = System_sprintf(uartTxBuffer,
"\r\n bbb \r\n");
uartTxBuffer[uartTxBufferOffset] = '\n';
UART_write(uart, uartTxBuffer, uartTxBufferOffset + 1);
}

"

and the master print aaa, but slave print nothing.

I connect two boards as follows.

  • Hello myc,

    Please share a common GND between the two boards, and note the following from the SPI TI Driver documentation:

    • The driver operates transparent from the chip select. Some SPI controllers feature a hardware chip select to assert SPI slave peripherals. See the specific peripheral implementations on chip select requirements.
    • The SPI protocol does not account for a built-in handshaking mechanism and neither does this SPI driver. Therefore, when operating in SPI_SLAVE mode, the application must provide such a mechanism to ensure that the SPI slave is ready for the SPI master. The SPI slave must call SPI_transfer() before the SPI master starts transmitting. Some example application mechanisms could include:
      • Timed delays on the SPI master to guarantee the SPI slave is be ready for a SPI transaction.
      • A form of GPIO flow control from the slave to the SPI master to notify the master when ready.

    You can also reference relevant E2E threads.

    Regards,
    Ryan

  • Is it OK for TIRTOS that no chip select signal is used?

  • The TRM chapter covering the SSI peripheral implies that a chip select is necessary.  Built-in handshaking is also preferred.  Please refer to spimaster/spislave code from the SIMPLELINK-CC13X0-SDK to further understand how to accomplish this.

    Regards,
    Ryan