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.

TMS320F28379D: LTC2348-18 SPI Communication

Part Number: TMS320F28379D

In order to read all 8 channels of the LTC2348-18 ADC over SPI, 8x24 bits must be transmitted.  I figured 12 bit data words would evenly split the most and least significant parts of the 24 bits of data for each channel.  With a total bit count of 8*24 = 192 and splitting this into 12 bit data words (192 / 12), that requires 16 spots in the SPI FIFO, which it has. 

Here's my configuration code.

//
// Function to configure SPI A in FIFO mode.
//
void initSPI()
{


    //
        // GPIO59 is the SPISOMIA.
        //
        GPIO_setMasterCore(59, GPIO_CORE_CPU1);
        GPIO_setPinConfig(GPIO_59_SPISOMIA);
        GPIO_setPadConfig(59, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);

        //
        // GPIO58 is the SPISIMOA clock pin.
        //
        GPIO_setMasterCore(58, GPIO_CORE_CPU1);
        GPIO_setPinConfig(GPIO_58_SPISIMOA);
        GPIO_setPadConfig(58, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);

        //
        // GPIO61 is the SPISTEA.
        //
        GPIO_setMasterCore(61, GPIO_CORE_CPU1);
        GPIO_setPinConfig(GPIO_61_SPISTEA);
        GPIO_setPadConfig(61, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(61, GPIO_QUAL_ASYNC);

        //
        // GPIO60 is the SPICLKA.
        //
        GPIO_setMasterCore(60, GPIO_CORE_CPU1);
        GPIO_setPinConfig(GPIO_60_SPICLKA);
        GPIO_setPadConfig(60, GPIO_PIN_TYPE_PULLUP);
        GPIO_setQualificationMode(60, GPIO_QUAL_ASYNC);


    //
    // Must put SPI into reset before configuring it
    //
    SPI_disableModule(SPIA_BASE);

    //
    // SPI configuration. Use a 500 kHz SPICLK and 12-bit word size.
    //
    SPI_setConfig(SPIA_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
                  SPI_MODE_MASTER, 500000, 12);
    SPI_disableLoopback(SPIA_BASE);
    SPI_setEmulationMode(SPIA_BASE, SPI_EMULATION_FREE_RUN);

    SPI_enableFIFO(SPIA_BASE);
    SPI_clearInterruptStatus(SPIA_BASE, SPI_INT_TXFF);
    SPI_setFIFOInterruptLevel(SPIA_BASE, SPI_FIFO_TX16, SPI_FIFO_RX16);
    SPI_enableInterrupt(SPIA_BASE, SPI_INT_TXFF | SPI_INT_RXFF );

    //
    // Configuration complete. Enable the module.
    //
    SPI_enableModule(SPIA_BASE);


}

And here is how I'm doing the transfer.  ARRAY_SIZE is defined as 16.

uint16_t i = 0, j = 0;
    uint32_t hi, lo;
    while(1)
    {
        // Transmit data
        for (i = 0; i < ARRAY_SIZE; i++)
        {
            SPI_writeDataBlockingFIFO(SPIA_BASE, 0xFFFF);
//            rData[i] = SPI_readDataBlockingFIFO(SPIA_BASE) & 0x0FFF;
        }

        // Block until data is received and then return it

        for (i = 0; i < ARRAY_SIZE; i++)
        {
            rData[i] = SPI_readDataBlockingFIFO(SPIA_BASE) & 0x0FFF;
        }


        for(i = 0, j = 0; i < (ARRAY_SIZE / 2); i++)
            {


                hi = (uint32_t) rData[j++];
                lo = (uint32_t) rData[j++];

                hi = hi << 12;
                lo = (lo & 0x0FFF);


                rawData[i] = (uint32_t) (hi | lo);

            }

        for (i = 0; i < ARRAY_SIZE / 2; i++)
        {
            values[i] = ((int32_t) ((rawData[i] >> 6) << 14)) >> 14;


        }



    }

Is this the proper way to handle reading 192 bits at a time?

Thanks!

  • Curtis,

    It is not clear from your post whether your code worked? Can you please clarify?

    Regards,
    Manoj
  • Manoj,

    My apologies!  I'm able to get data from the ADC, and the data reacts to changes in ADC input.  I have the ADC's MOSI line tied to 3V3 to keep the SoftSpan at +/- 10.24 V.  The results should have all ones in the 3 least significant bits because of this.  Instead, I'm getting this when 5V is applied to channels 0-6:

    Here's an example of what's actually happening on the SPI line.

    The next three LSb's should increase sequentially as each channel is read.  It looks like this is done here if the LSb of 0 is ignored.  However, when connect to 0V, the output is as follows:

  • I found that the Launchpad is providing an inconsistent clock as shown here.  On some of the rising edges, an extra rising edge occurs shortly afterwards.  I'm not sure how it's caused or what its effect is on the data being received.

  • There's a pin on the evaluation board that I'm using (DC2094), VCCIO. It was set to the 3.3V position. The datasheet has this to say: JP2
    –VCCIO sets the output levels at P1 to either 3.3V or 2.5V. Use 2.5V to interface to the DC890, which is the default setting. Use 3.3V to interface to the DC2026.

    I was not using either of these devices to interface with the ADC, but placing the pin in the 2.5V position seems to have resolved the issue.
  • Thanks for letting us know