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.

CC2650STK: SPI communication does not work

Part Number: CC2650STK
Other Parts Discussed in Thread: CC2650

I have a CC2650 with RHB package, I want to use the SPI module to commuinicate (read and write) with AD4683 (ADC).

The problem is that  the transactions are not working every time.

This is the code I used for my "Spi_Controller".

---------------------------------------------------
#ifndef ADC_CONFIG_PARAMS_DATA_SIZE
#define ADC_CONFIG_PARAMS_DATA_SIZE 16
#endif

#ifndef ADC_DATA_SIZE_32
#define ADC_DATA_SIZE_32 32
#endif

static SPI_Transaction spiTransaction;

static SPI_Params adcParams1;

static SPI_Params adcConfigParams;

static void setup_ADC() {

spiHandle = SPI_open(Board_SPI0, &adcConfigParams);
// Set configuration2 register
uint32_t txData = 0xA1FF;
spiTransaction.txBuf = &txData;
spiTransaction.count = 1;
SPI_transfer(spiHandle, &spiTransaction);
Task_sleep(10000);
// Set configuration2 register
txData = 0xA13C;
spiTransaction.txBuf = &txData;
spiTransaction.count = 1;
SPI_transfer(spiHandle, &spiTransaction);
Task_sleep(10000);
// Set configuration1 register
txData = 0x92C2;
spiTransaction.txBuf = &txData;
spiTransaction.count = 1;
res = SPI_transfer(spiHandle, &spiTransaction);
SPI_close(spiHandle);
}

uint32_t SPI_CONTROLLER_readADC(){
uint32_t txData = 0x70007000;
uint32_t rxData;
SPI_Transaction spiT;
spiT.txBuf = &txData;
spiT.rxBuf = &rxData;
spiT.count = 1;
spiHandle = SPI_open(Board_SPI0, &adcParams1);
SPI_transfer(spiHandle, &spiT);
SPI_close(spiHandle);
return rxData;
}


static void Spi_Controller_init(void)
{
SPI_init();

...

SPI_Params_init(&adcParams1);
adcParams1.dataSize = ADC_DATA_SIZE_32;
adcParams1.frameFormat = SPI_POL1_PHA0;
adcParams1.bitRate = 500000;

SPI_Params_init(&adcConfigParams);
adcConfigParams.frameFormat = SPI_POL1_PHA0;
adcConfigParams.dataSize = ADC_CONFIG_PARAMS_DATA_SIZE;
adcConfigParams.bitRate = 500000;

spiTransaction.rxBuf = NULL;
}

static void Spi_taskFxn(UArg a0, UArg a1)
{
Spi_Controller_init();

...
setup_ADC();
while(1){
Task_sleep(100000);
// setup_ADC();
SPI_CONTROLLER_readADC1();
}

}

--------------------------------------------

When I make transactions using the setup_adc function everything works fine, I validated the results using an external oscilloscope.

When I want to read data from the adc I have to send 32 bits of data (0x70007000) but when I check with the oscilloscope, the data sent is always the same and wrong. It sends 17 bits instead of 32 and always with the same content, the clock phase and polarity are not affected by the SPI_Params and I don't know why it does not work.