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.

CC2640R2F: Unable to interface ads1220 using SPI

Part Number: CC2640R2F
Other Parts Discussed in Thread: ADS1220, CC2640

Hi,

I have been trying top interface ADS1220 with CC2640 by modifying Simple BLE Peripheral with help of SPI Master example.

But It seems I am unable to initialize SPI and connect to ADS1220 as DIO8, DIO9, DIO10 shows no signal in DSO. 

static void SimplePeripheral_performPeriodicTask(void)
{

SPI_Handle handle;
SPI_Params params;
SPI_Transaction transaction;
uint8_t txBuf[] = {0xA1, 0xC0, 0xC0, 0x00} ; // Transmit buffer
uint8_t rxBuf[20]; // Receive buffer

// memset(txBuf, 0xFF, sizeof(txBuf));
// memset(rxBuf, 0xFF, sizeof(rxBuf));

// Init SPI and specify non-default parameters
SPI_Params_init(&params);
params.bitRate = 1000000;
params.frameFormat = SPI_POL1_PHA1;
params.mode = SPI_MASTER;

// Configure the transaction
transaction.count = sizeof(txBuf);
transaction.txBuf = txBuf;
transaction.rxBuf = rxBuf;

// Open the SPI and initiate the first transfer
handle = SPI_open(Board_SPI_MASTER, &params);
SPI_transfer(handle, &transaction);

SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
&rxBuf);

SPI_close(handle);

}

  • Hi,

    I can't see that you setup the DIOs (DIO8, DIO9 and DIO10) in your code. Do you do that somewhere else?

    Best Regards,
    R.M
  • I have used Board_SPI_Master which is linked to CC2640R2_LAUNCHXL_SPI0 which defines (DIO8, DIO9, DIO10) as MISO, MOSI, Clk.
  • Hi,

    You say that you are not able to initialize SPI, does that mean that the SPI_open() fails (returns NULL)?

    Do you initialize the SPI module with SPI_init();  first?

    Best Regards,

    R.M

  • Hi

    I think SPI_Transfer was failing, to check i modified my code, also included SPI_init(). Now SPI_Transfer is not failing but instead i am getting 0x00 as output.

    SPI_init();

    SPI_Handle handle;
    SPI_Params params;
    SPI_Transaction transaction;
    uint8_t txBuf[] = {0xA1, 0xC0, 0x00, 0x00} ; // Transmit buffer
    uint8_t rxBuf[10]; // Receive buffer

    // Init SPI and specify non-default parameters
    SPI_Params_init(&params);
    params.bitRate = 1000000;
    params.frameFormat = SPI_POL1_PHA1;
    params.mode = SPI_MASTER;

    // Configure the transaction
    transaction.count = sizeof(txBuf);
    transaction.txBuf = txBuf;
    transaction.rxBuf = rxBuf;

    // Open the SPI and initiate the first transfer
    handle = SPI_open(Board_SPI_MASTER, &params);


    if(SPI_transfer(handle, &transaction))
    {
    for(int i =0 ; i<10; i++)

    {
    uint8 adc = rxBuf[i];
    SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
    &adc);
    }

    }

    SPI_close(handle);
  • Hi,

    I recommend that you start with the SPI Master example first and make that work before merging it into the Simple BLE Peripheral project.

    Best Regards,
    R.M