Other Parts Discussed in Thread: CC3220S, CC3220SF
I am trying to create a loopback, connecting a physical wire between MOSI and MISO pins using SPII. I'm also trying to read the MOSI and CLK signal with an oscilloscope, but they only show a flat line. The UART loopback example code works fine. There really isn't any example code for SPI on the CC3220S, but it doesn't seem like something like this should be too hard. My code is this:
#define MSGSIZE 20
SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
uint8_t transmitBuffer[MSGSIZE];
uint8_t receiveBuffer[MSGSIZE];
bool transferOK;
SPI_Params_init(&spiParams); // Initialize SPI parameters
//default parameters
spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.transferTimeout = SPI_WAIT_FOREVER;
spiParams.transferCallbackFxn = NULL;
spiParams.mode = SPI_MASTER;
spiParams.bitRate = 1000000;
spiParams.dataSize = 8; // 8-bit data size
spiParams.frameFormat = SPI_POL0_PHA0;
spiParams.custom = NULL;
spi = SPI_open(Board_SPI0, &spiParams);
if (spi == NULL) {
while (1); // SPI_open() failed
}
for(i = 0; i < MSGSIZE; i++){
transmitBuffer[i] = i;
receiveBuffer[i] = 0;
}
// Fill in transmitBuffer
spiTransaction.count = MSGSIZE;
spiTransaction.txBuf = transmitBuffer;
spiTransaction.rxBuf = receiveBuffer;
while(1){
transferOK = SPI_transfer(spi, &spiTransaction);
if (!transferOK) {
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
// Error in SPI or transfer already in progress.
}
}
I turn a LED off if there is a transfer problem, but the LED never turns off. I have P05 as CLK, P06 as MISO, P07 as MOSI, and P08 as CS. I'm measuring CLK and MOSI on the oscilloscope, and MOSI and MISO are also physically connected by a wire.
Any help as to why SPI is not producing any bitsream or a nudge in the right direction would be appreciated. Thanks.