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.

CCS/ADS8881: CCS/ADS8881

Part Number: ADS8881
Other Parts Discussed in Thread: CC2650

Tool/software: Code Composer Studio

Hi, I'm trying to read via SPI the ADS8881 with the CC2650 Launchpad. I am receiving data but I think is wrong, and sometimes frames are missing

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>

/* Board Header files */
#include "Board.h"

#define delay_ms(i)     Task_sleep( ((i) * 1000) / Clock_tickPeriod )
#define TASKSTACKSIZE   516

Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];

//static SPI_Handle spiHandle = NULL;
SPI_Handle spiHandle = NULL;
//static SPI_Params spiParams;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
uint16_t wbuf[2] = {(uint16_t) 0b1};
uint16_t rbuf[2] = {0};
int ret = 0;
uint16_t buffer[40] = {0};
aux = 0;

UInt32 sleepTickCount;

//---------------------

static PIN_Handle hFlashPin = NULL;
static PIN_State flashPinState;
static PIN_Config BoardFlashPinTable[] = {
Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL
                                                   | PIN_DRVSTR_MIN, // Ext. flash chip select
        PIN_TERMINATE };

Void taskFxn(UArg arg0, UArg arg1)
{
    System_printf("Start SPI task\n");

    SPI_Params_init(&spiParams);
    spiParams.dataSize = 9;
    spiParams.mode = SPI_MASTER;
    spiParams.bitRate = 4000000;
    spiParams.frameFormat = SPI_POL0_PHA0;
    spiHandle = SPI_open(Board_SPI0, &spiParams);
    if (spiHandle == NULL)
    {
        while (1);
        System_printf("Start SPI failed"); // SPI_open() failed
    }

    while (1)
    {

        delay_ms(100);
        SPI_Transaction masterTransaction;
        masterTransaction.count = 2;
        masterTransaction.txBuf = wbuf;
        masterTransaction.rxBuf = rbuf;
        ret = SPI_transfer(spiHandle, &masterTransaction);
        buffer[aux] = rbuf[1];
        buffer[aux+1] = rbuf[0];
        aux = aux +2;
        if (aux == 40){
            aux = 0;
        }
    }

    //SPI_close(spiHandle);
}

/*
 *  ======== main ========
 */
int main(void)

{
    Task_Params taskParams;

    /* Call board init functions */
    Board_initGeneral();
    Board_initSPI();

    /* Construct Task  thread */
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr) taskFxn, &taskParams, NULL);

    sleepTickCount = 500000 / Clock_tickPeriod;

    hFlashPin = PIN_open(&flashPinState, BoardFlashPinTable);
    if (!hFlashPin)
    {
        System_abort("Error initializing flash pin\n");
    }

    /* Start BIOS */
    BIOS_start();

    return (0);
}

I'm filling an arrangement to see the values