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.

Using the ADS8354 with the MSP432P401R : Problem

Other Parts Discussed in Thread: ADS8354

Hi,

I am trying to interface the ADS8354 with the MSP432P401R and read the digital output through the SPI channel present in the MSP432 Launchpad. My problem is that what ever analog input I give to the adc, I just read the same output which is all 1's. I use the 32-CLK Single SDO mode and read the output of both the channels from one pin of the ADC which I send it to the MSP432 Launchpad.-Here is my code which I wrote in Code composer studio:
(I have also described my Pin assignments too below the code).

Here is the pin connections of the ADC to the MSP432 Launchpad:

ADS Pin : MSP432 Pin

AVDD(pin16) : +5V
GND(pin15) : GND
Data Output for serial communication for ch. A & ch. B(pin13) : P1.7 SPI MISO
SCLK (pin12) : P1.5 CLK
CS(Active Low)(pin11) : P5.2 SPI CS(Other)
SDI (pin10) : P1.6 SPI MOSI
DVDD (pin9) : +3.3V

+ve analog input - ch.A (pin1) : gave a input of 2V
-ve analog input - ch.A (pin2) : gave a input of 1V
Reference Voltage I/O, Ch. A(pin3) : NC (No connection)
Reference GND Potential A(pin4) : GND
Reference GND Potential B(pin5) : GND
Reference Voltage I/O, Ch. B(pin6) : NC (No Connection)
-ve analog input - ch.B (pin7) : gave a input of 1V
+ve analog input - ch.B (pin8) : gave a input of 2V

/*
 * P5.2 -> SPI CS   -> CS - active low
 * P1.5 -> SPI CLK  -> SCLK
 * P1.6 -> SPI SIMO -> SDI
 * P1.7 <- SPI SOMI <- SDO_A
 */

#include "driverlib.h"
#include <stdint.h>
#include <stdbool.h>
#include "printf.h"

static volatile uint8_t rxAHigher = 0, rxALower = 0, rxBHigher = 0, rxBLower = 0;
static uint8_t txCH = 0x84, tx = 0;
static int rxA = 0, rxB = 0;

const eUSCI_SPI_MasterConfig spiMasterConfig =
{
        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
        3000000,
        500000,
        EUSCI_B_SPI_MSB_FIRST,
        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,
        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,
        EUSCI_B_SPI_3PIN
};

const eUSCI_UART_Config uartConfig =
{
        EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        78,
        2,
        0,
        EUSCI_A_UART_NO_PARITY,
        EUSCI_A_UART_LSB_FIRST,
        EUSCI_A_UART_ONE_STOP_BIT,
        EUSCI_A_UART_MODE,
        EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION
};

int main(void)
{
        uint32_t i = 0;

        WDT_A_holdTimer();

        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);

        // Set CS high
        P5OUT |= BIT2;

        P5DIR |= BIT2;

        P5OUT |= BIT2;

        // Initialize and enable SPI
        SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);

        SPI_enableModule(EUSCI_B0_BASE);

        SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);

        // Initialize and enable UART

        CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);

        MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);

        MAP_UART_enableModule(EUSCI_A0_BASE);

        MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);

        for(i = 0; i < 3000; i++);

        // Set up ADS8354 to operate in 32CLK - Single SDO mode.

        /*P5OUT &= (~BIT2);

        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
        SPI_transmitData(EUSCI_B0_BASE, txCH);
        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
        SPI_transmitData(EUSCI_B0_BASE, tx);
        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
        SPI_transmitData(EUSCI_B0_BASE, tx);
        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
        SPI_transmitData(EUSCI_B0_BASE, tx);*/

        //P5OUT |= BIT2;

        while(1) {

            // Read ADS8354 channel A and B data
            P5OUT &= (~BIT2);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, txCH);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, tx);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, tx);
            rxAHigher = SPI_receiveData(EUSCI_B0_BASE);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, tx);
            rxALower = SPI_receiveData(EUSCI_B0_BASE);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, tx);
            rxBHigher = SPI_receiveData(EUSCI_B0_BASE);

            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
            SPI_transmitData(EUSCI_B0_BASE, tx);
            rxBLower = SPI_receiveData(EUSCI_B0_BASE);

            P5OUT |= BIT2;

            // Combine higher and lower bytes to get 16bit ADC value

            rxA = rxA | rxAHigher;
            rxA = rxA << 8;
            rxA = rxA | rxALower;

            rxB = rxA | rxBHigher;
            rxB = rxB << 8;
            rxB = rxB | rxBLower;

            // Print to serial port

            printf(EUSCI_A0_BASE, "Channel A : %i\r\n", rxA);
            printf(EUSCI_A0_BASE, "Channel B : %i\r\n", rxB);

            for(i = 0; i < 3000; i++);

        }

}