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.

ADS127L01: can not read registers through SPI

Part Number: ADS127L01
Other Parts Discussed in Thread: LAUNCHXL-CC26X2R1,

Hi all,

I want to connect one ADS127L01 to my LAUNCHXL-CC26X2R1 through SPI. At first, I want just read registers in ADS127L01 to test SPI connection. (ID register at address 00h)

I wrote my code based on spimaster example on SDK.

here is my code.

#define THREADSTACKSIZE (1024)

#define SPI_MSG_LENGTH  (1) 

static Display_Handle display;

uint16_t masterRxBuffer[SPI_MSG_LENGTH];
uint16_t masterTxBuffer[SPI_MSG_LENGTH]; //unsigned char
uint32_t        i;

 *  ======== masterThread ========
 *  Master SPI sends a message to slave while simultaneously receiving a
 *  message from the slave.
void *masterThread(void *arg0)
    SPI_Handle      masterSpi;
    SPI_Params      spiParams;
    SPI_Transaction transaction;
  //  uint32_t        i;
    bool            transferOK;
    int32_t         status;

    /* Open SPI as master (default) */
    spiParams.frameFormat = SPI_POL0_PHA1;
    spiParams.bitRate = 200000; 
    spiParams.dataSize = 8;
    spiParams.mode = SPI_MASTER; 

    masterSpi = SPI_open(CONFIG_SPI_MASTER, &spiParams);
    if (masterSpi == NULL) {
        Display_printf(display, 0, 0, "Error initializing master SPI\n");
        while (1);
    else {
        Display_printf(display, 0, 0, "Master SPI initialized\n");

    /* Copy message to transmit buffer */

    for (i = 0; i < 100000; i++) {

        /* Initialize master SPI transaction structure */
            masterTxBuffer[0] = 0x2000;
        transaction.count = SPI_MSG_LENGTH;
        transaction.txBuf = (void *) masterTxBuffer;
        transaction.rxBuf = (void *) masterRxBuffer;

        /* Perform SPI transfer */
        transferOK = SPI_transfer(masterSpi, &transaction);
        if (transferOK) {
            Display_printf(display, 0, 0, "Master received: %d ",masterRxBuffer[0]);
        else {
            Display_printf(display, 0, 0, "Unsuccessful master SPI transfer");

        /* Sleep for a bit before starting the next SPI transfer  */


    Display_printf(display, 0, 0, "\nDone");

    return (NULL);

 *  ======== mainThread ========
void *mainThread(void *arg0)
    pthread_t           thread0;
    pthread_attr_t      attrs;
    struct sched_param  priParam;
    int                 retc;
    int                 detachState;

    /* Call driver init functions. */

    /* Open the display for output */
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
        /* Failed to open display driver */
        while (1);

    Display_printf(display, 0, 0, "Starting the SPI master example");
    Display_printf(display, 0, 0, "This example requires external wires to be "
        "connected to the header pins. Please see the Board.html for details.\n");

    /* Create application threads */

    /* Set priority and stack size attributes */
    retc = pthread_attr_setdetachstate(&attrs, detachState);
    if (retc != 0) {
        /* pthread_attr_setdetachstate() failed */
        while (1);

    retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
    if (retc != 0) {
        /* pthread_attr_setstacksize() failed */
        while (1);

    /* Create master thread */
    priParam.sched_priority = 1;
    pthread_attr_setschedparam(&attrs, &priParam);

    retc = pthread_create(&thread0, &attrs, masterThread, NULL);
    if (retc != 0) {
        /* pthread_create() failed */
        while (1);

    return (NULL);

But masterRxBuffer is not as expected (x3h as mentioned in datasheet). 

I connected 4 pins ( SCLK, MOSI, MISO, CS) from ADS127L01 to LAUNCHXL-CC26X2R1 and  START to 1 and  FORMAT to 0. what else should I do? 

SDK version for spimaster  example : SimpleLink CC13x2 26x2 SDK (

code composer studio version :

Thanks in advance

  • Hello Kim,

    For SPI mode, both FORMAT and FSMODE pins should be set 0.

    Also, looking at your code, it looks like you have the SPI setup for 8b wide.  When writing or reading registers, the SPI frame length is 24b when reading/writing a single register.  The frame length is defined by the /CS pin, and must remain low for the entire frame.  My guess is that /CS is going high between bytes during the read/write commands, in which case the ADS127L01 will not recognize this as a valid command.

    Please use a scope or logic analyzer and record SCLK, MOSI, MISO, CS pins to verify proper operation, especially for the /CS pin.  If you can share those results, I will verify that they are correct.

    Below is an example for reading 3 registers, which results in a frame size of 40b.  /CS should be low during this entire frame.

    Keith Nicholas
    Precision ADC Applications

  • Hello Keith,

    Thank you for your response,

    I changed frame size. actually I changed the transaction.count  to 3. I had another problem with CLK pin too. I fixed them and now I can read registers.

    Now I want to read data. Should frame size be set to 32 bit? 

    Best regards.

  • Hello Kim,

    Yes, you can set frame size to 32 bit.  This will result in two register values (2x 8b ) being read back.  The command should be:

    0x2r010000h, where 'r' is the starting address for the first register that you want to read.  If 'r' is set to 0h, then you will read back the ID and CONFIG registers.


  • Hello Keith,

    I meant  frame size for read data by command(RDATA) which first byte should be (0x12). 

    In this case we need 8 bit for command and 24 bit for data, am I right? 

    Best regards,

  • Hello Kim,

    My apologies; I misunderstood your question.

    Yes, you need a 32b SPI frame to read conversion data using the RDATA command.

    You would send 0x12000000h, and in the same SPI frame, receive the conversion result starting on the 9th SCLK.


  • Hello Keith,

    Thank you for your response, I can now read data.

    Best regards,