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/ADS8684: Constant response from spi

Part Number: ADS8684
Other Parts Discussed in Thread: MSP430F5132

Tool/software: Code Composer Studio

Hello,

I couldnt make my ADS8684 work on my custom circuit.

Here is the logic analyzer output:

uart output:

ADS8684 circuit:

MSP430F5132 codes:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>main.c<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "driverlib.h"
#include "msp430_spi.h"


char charArray[20],charArrayID[6],cbuf1[1],cbuf2[1],cbuf3[1],cbuf4[1],cbuf5[1],cbuf6[1],cbuf7[1],cbuf8[1],cbuf9[1],cbuf10[1],cbuf11[1],cbuf12[1],cbuf13[1],cbuf14[1],cbuf15[1],cbuf16[1];
volatile int i,c=0;
uint8_t receivedData = 0x00,buf1,buf2,buf3,buf4,buf5,buf6,buf7,buf8,buf9,buf10,buf11,buf12,buf13,buf14,buf15,buf16;
//uint8_t buf[16];


void main (void)
{
    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //STATUS1 STATUS2 output
    GPIO_setAsOutputPin(GPIO_PORT_P3,GPIO_PIN0 + GPIO_PIN1);
    //STATUS1 STATUS2 low
    GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN0 + GPIO_PIN1);

    //rs485 de re
    GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
    //re de low
    GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);

    //uart - rs485
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1 + GPIO_PIN2);

    //spi - ste = p1.0
    spi_init();
    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);// + GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5);
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);// + GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5);
    //GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);



    //Baudrate = 9600, clock freq = 1.048MHz
    //UCBRx = 109, UCBRFx = 0, UCBRSx = 2, UCOS16 = 0  --> Copied from MSP430F5529 example
    USCI_A_UART_initParam param = {0};
    param.selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK;
    param.clockPrescalar = 109;
    param.firstModReg = 0;
    param.secondModReg = 2;
    param.parity = USCI_A_UART_NO_PARITY;
    param.msborLsbFirst = USCI_A_UART_LSB_FIRST;
    param.numberofStopBits = USCI_A_UART_ONE_STOP_BIT;
    param.uartMode = USCI_A_UART_MODE;
    param.overSampling = USCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;

    if(STATUS_FAIL == USCI_A_UART_init(USCI_A0_BASE, &param))
    {
        return;
    }

    //Enable UART module for operation
    USCI_A_UART_enable(USCI_A0_BASE);

    //Enable Receive Interrupt
    USCI_A_UART_clearInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT);
    USCI_A_UART_enableInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT);


    //CIHAZ ID
    charArrayID[0] = '4';
    charArrayID[1] = '6';
    charArrayID[2] = '0';
    charArrayID[3] = '7';
    charArrayID[4] = '5';
    charArrayID[5] = '1';



    //ads8684 ayarlar
    ///reset
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0x8500);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);

    //AUTO_SEQ_EN
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);
    spi_transfer16(0x01FF);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);


    //CHANNEL POWER DOWN -> ALL UP
    /*GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);
    spi_transfer16(0x0200);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);*/


    //channel 1 2.5xVref
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0x0505);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);

    //channel 2 2.5xVref
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0x0605);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);

    //channel 3 2.5xVref
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0x0705);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);

    //channel 4 2.5xVref
    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0x0805);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);

    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
    //__delay_cycles(1000);
    spi_transfer16(0xA000);
    spi_transfer16(0x0000);
    GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(1000);




    __enable_interrupt();

    while(1){
        GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN0);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN1);
        __delay_cycles(105000);
        GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN1);
        GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN0);
        __delay_cycles(105000);

        __disable_interrupt();



        //CH1
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        //__delay_cycles(10000);
        buf1 = spi_transfer(0x00);
        buf2 = spi_transfer(0x00);
        buf3 = spi_transfer(0x00);
        buf4 = spi_transfer(0x00);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(10000);
        //CH2
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        //__delay_cycles(10000);
        buf5 = spi_transfer(0x00);
        buf6 = spi_transfer(0x00);
        buf7 = spi_transfer(0x00);
        buf8 = spi_transfer(0x00);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(10000);
        //CH3
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        //__delay_cycles(10000);
        buf9 = spi_transfer(0x00);
        buf10 = spi_transfer(0x00);
        buf11 = spi_transfer(0x00);
        buf12 = spi_transfer(0x00);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(10000);
        //CH4
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        //__delay_cycles(10000);
        buf13 = spi_transfer(0x00);
        buf14 = spi_transfer(0x00);
        buf15 = spi_transfer(0x00);
        buf16 = spi_transfer(0x00);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(10000);

        ltoa(buf1, cbuf1);
        ltoa(buf2, cbuf2);
        ltoa(buf3, cbuf3);
        ltoa(buf4, cbuf4);
        ltoa(buf5, cbuf5);
        ltoa(buf6, cbuf6);
        ltoa(buf7, cbuf7);
        ltoa(buf8, cbuf8);
        ltoa(buf9, cbuf9);
        ltoa(buf10, cbuf10);
        ltoa(buf11, cbuf11);
        ltoa(buf12, cbuf12);
        ltoa(buf13, cbuf13);
        ltoa(buf14, cbuf14);
        ltoa(buf15, cbuf15);
        ltoa(buf16, cbuf16);

        buf1 = 0;
        buf2 = 0;
        buf3 = 0;
        buf4 = 0;
        buf5 = 0;
        buf6 = 0;
        buf7 = 0;
        buf8 = 0;
        buf9 = 0;
        buf10 = 0;
        buf11 = 0;
        buf12 = 0;
        buf13 = 0;
        buf14 = 0;
        buf15 = 0;
        buf16 = 0;




        GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
        __delay_cycles(18000);

        USCI_A_UART_transmitData(USCI_A0_BASE, 'A');
        USCI_A_UART_transmitData(USCI_A0_BASE, 'C');
        USCI_A_UART_transmitData(USCI_A0_BASE, 'K');
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[1]);
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[2]);
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[3]);
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[4]);
        USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[5]);
        USCI_A_UART_transmitData(USCI_A0_BASE, '#');
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf1[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf2[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf3[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf4[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, '#');
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf5[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf6[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf7[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf8[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, '#');
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf9[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf10[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf11[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf12[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, '#');
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf13[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf14[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf15[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, cbuf16[0]);
        USCI_A_UART_transmitData(USCI_A0_BASE, '\n');



        __delay_cycles(18000);
        GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
        __enable_interrupt();
    }
}

//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(USCI_A0_VECTOR)))
#endif
void USCI_A0_ISR(void)
{
    switch(__even_in_range(UCA0IV,4))
    {
    //Vector 2 - RXIFG
    case 2:
        receivedData = USCI_A_UART_receiveData(USCI_A0_BASE);

        /*if(receivedData != '#')                       // Check value
        {
            if((c == 0 && receivedData == '4') || (c == 1 && receivedData == '6') || (c == 2 && receivedData == '0') || (c >= 3 && c < 13) )
            {
                charArray[c] = receivedData;
                c++;
                charReceived = 0;
            }else
            {
                c = 0;
                charReceived = 0;
            }
        }else{
            //c = 0;
            //GPIO_toggleOutputOnPin(GPIO_PORT_P7, GPIO_PIN1);
            charReceived = 1;
        }*/
        break;
    default: break;
    }
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>msp430_spi.c<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#if defined(__MSP430_HAS_USCI_B0__) && defined(SPI_DRIVER_USCI_B)
void spi_init()
{
    /* Configure ports on MSP430 device for USCI_B */
    #ifdef __MSP430F5172
    P1SEL |= BIT3 | BIT4 | BIT5;
    #endif
    #ifdef __MSP430F5529
    P3SEL |= BIT0 | BIT1 | BIT2;
    #endif
    #ifdef __MSP430F5132
    P1SEL |= BIT3 | BIT4 | BIT5;
    #endif

    /* USCI-B specific SPI setup */

    UCB0CTL1 |= UCSWRST;
    UCB0CTL0 = UCCKPH | UCMSB | UCMST | UCMODE_0 | UCSYNC;  // SPI mode 0, master
    UCB0BR0 = 0x01;  // SPI clocked at same speed as SMCLK
    UCB0BR1 = 0x00;
    UCB0CTL1 = UCSSEL_2;  // Clock = SMCLK, clear UCSWRST and enables USCI_B module.


}

uint8_t spi_transfer(uint8_t inb)
{
    UCB0TXBUF = inb;
    while ( !(UCB0IFG & UCRXIFG) )  // Wait for RXIFG indicating remote byte received via SOMI
        ;
    return UCB0RXBUF;
}

uint16_t spi_transfer16(uint16_t inw)
{
    uint16_t retw;
    uint8_t *retw8 = (uint8_t *)&retw, *inw8 = (uint8_t *)&inw;

    UCB0TXBUF = inw8[1];
    while ( !(UCB0IFG & UCRXIFG) )
        ;
    retw8[1] = UCB0RXBUF;
    UCB0TXBUF = inw8[0];
    while ( !(UCB0IFG & UCRXIFG) )
        ;
    retw8[0] = UCB0RXBUF;
    return retw;
}

UART always prints the same output. Could you please help on that?

Best regards,

Onur

  • Hello,

    Your schematic looks good from what I can see.

    Please also look at page 34 of the datasheet for a data acquisition example.

    The timing diagram on page 11 will also prove to be helpful, the most common issue is timing requirements not being met.

    It is good practice to keep the clock as a steady sequence of pulses and not break them up within a CS pulse.

    I would suggest the following to debug your software issues

    -After programing the registers, read them to make sure that they are being programmed correctly; page 46 of the datasheet will help to do this

    -Use a known DC input and convert, this will narrow down the issue.

    Regards,

    Cynthia

  • Thank you very much for the response. I will work on some bit bang spi function tomorrow and I will give information to you.
  • I wrote my own functions to make my custom SPI communication.

    Here is the code:

    //R&D Robotics - Onur YILDIRIM
    //ANALOG INPUT MODULU - 07.02.2018
    
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "driverlib.h"
    //#include "msp430_spi.h"
    
    
    #define STE     GPIO_PIN0
    #define CLK     GPIO_PIN3
    #define MOSI    GPIO_PIN4
    #define MISO    GPIO_PIN5
    
    
    char charArray[20],charArrayID[6],cbuf1[1],cbuf2[1],cbuf3[1],cbuf4[1],cbuf5[1],cbuf6[1],cbuf7[1],cbuf8[1],cbuf9[1],cbuf10[1],cbuf11[1],cbuf12[1],cbuf13[1],cbuf14[1],cbuf15[1],cbuf16[1];
    volatile int i,c=0;
    uint8_t receivedData = 0x00, tempInput;//,buf1,buf2,buf3,buf4,buf5,buf6,buf7,buf8,buf9,buf10,buf11,buf12,buf13,buf14,buf15,buf16;
    uint16_t tempWord, result, buf1, buf2, buf3, buf4;
    
    void spitransferCommandWrite(uint16_t cmd)
    {
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, STE);//ste low
        for(i=0;i<16;i++)
        {
            cmd = cmd << 1;
            tempWord = cmd & 0x0001;
            if(tempWord == 0x0000)
            {
                GPIO_setOutputLowOnPin(GPIO_PORT_P1, MOSI);
            }
            else
            {
                GPIO_setOutputHighOnPin(GPIO_PORT_P1, MOSI);
            }
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, CLK);
            GPIO_setOutputLowOnPin(GPIO_PORT_P1, CLK);
    
        }
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, STE);//ste high
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, MOSI);
    }
    
    void spitransferCommandRead(uint16_t adr)
    {
    
    }
    
    uint16_t spitransferMeasurementRead(uint16_t cmdR, uint16_t valR)
    {
        result = 0x0000;
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, STE);//ste low
            for(i=0;i<32;i++)
            {
                if(i<16){
                    cmdR = cmdR << 1;
                    tempWord = cmdR & 0x0001;
                }else{
                    valR = valR << 1;
                    tempWord = valR & 0x0001;
                }
                if(tempWord == 0x0001)
                {
                    GPIO_setOutputHighOnPin(GPIO_PORT_P1, MOSI);
                }
                else
                {
                    GPIO_setOutputLowOnPin(GPIO_PORT_P1, MOSI);
                }
                GPIO_setOutputHighOnPin(GPIO_PORT_P1, CLK);
                GPIO_setOutputLowOnPin(GPIO_PORT_P1, CLK);
                if(i>15){
                    tempInput = GPIO_getInputPinValue(GPIO_PORT_P1, MISO);
                    result = result >> 1;
                    if(tempInput == GPIO_INPUT_PIN_HIGH)
                    {
                        result = result | 0x0001;
                    }
                    else
                    {
                        result = result | 0x0000;
                    }
                }
    
            }
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, STE);//ste high
            return result;
    }
    
    
    void main (void)
    {
        //Stop WDT
        WDT_A_hold(WDT_A_BASE);
    
        //STATUS1 STATUS2 output
        GPIO_setAsOutputPin(GPIO_PORT_P3,GPIO_PIN0 + GPIO_PIN1);
        //STATUS1 STATUS2 low
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN0 + GPIO_PIN1);
    
        //rs485 de re
        GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
        //re de low
        GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
    
        //uart - rs485
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1 + GPIO_PIN2);
    
        //spi - ste = p1.0
        //spi_init();
        GPIO_setAsOutputPin(GPIO_PORT_P1, STE);//ste
        GPIO_setAsOutputPin(GPIO_PORT_P1, CLK);//clk
        GPIO_setAsOutputPin(GPIO_PORT_P1, MOSI);//mosi
        GPIO_setAsInputPin(GPIO_PORT_P1, MISO);//miso
        //GPIO_setOutputLowOnPin(GPIO_PORT_P1, STE + MOSI);//ste mosi low
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, STE);//ste high
    
    
    
        //Baudrate = 9600, clock freq = 1.048MHz
        //UCBRx = 109, UCBRFx = 0, UCBRSx = 2, UCOS16 = 0  --> Copied from MSP430F5529 example
        USCI_A_UART_initParam param = {0};
        param.selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK;
        param.clockPrescalar = 109;
        param.firstModReg = 0;
        param.secondModReg = 2;
        param.parity = USCI_A_UART_NO_PARITY;
        param.msborLsbFirst = USCI_A_UART_LSB_FIRST;
        param.numberofStopBits = USCI_A_UART_ONE_STOP_BIT;
        param.uartMode = USCI_A_UART_MODE;
        param.overSampling = USCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;
    
        if(STATUS_FAIL == USCI_A_UART_init(USCI_A0_BASE, &param))
        {
            return;
        }
    
        //Enable UART module for operation
        USCI_A_UART_enable(USCI_A0_BASE);
    
        //Enable Receive Interrupt
        USCI_A_UART_clearInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT);
        USCI_A_UART_enableInterrupt(USCI_A0_BASE,USCI_A_UART_RECEIVE_INTERRUPT);
    
    
        //CIHAZ ID
        charArrayID[0] = '4';
        charArrayID[1] = '6';
        charArrayID[2] = '0';
        charArrayID[3] = '7';
        charArrayID[4] = '5';
        charArrayID[5] = '1';
    
    
    
        //ads8684 ayarlar
        ///reset
    
        spitransferCommandWrite(0x8500);
        __delay_cycles(10000);
    
        //AUTO_SEQ_EN
        spitransferCommandWrite(0x01FF);
        __delay_cycles(10000);
    
    
        //CHANNEL POWER DOWN -> ALL UP
        /*GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(1000);
        spi_transfer16(0x0200);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(1000);*/
    
    
        //channel 1 2.5xVref
        spitransferCommandWrite(0x0505);
        __delay_cycles(10000);
    
        //channel 2 2.5xVref
        spitransferCommandWrite(0x0605);
        __delay_cycles(10000);
    
        //channel 3 2.5xVref
        spitransferCommandWrite(0x0705);
        __delay_cycles(10000);
    
        //channel 4 2.5xVref
        spitransferCommandWrite(0x0805);
        __delay_cycles(10000);
    
        /*
        GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        //__delay_cycles(1000);
        spi_transfer16(0xA000);
        spi_transfer16(0x0000);
        GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
        __delay_cycles(1000);*/
    
    
    
    
        __enable_interrupt();
    
        while(1){
            GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN0);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN1);
            __delay_cycles(105000);
            GPIO_setOutputLowOnPin(GPIO_PORT_P3, GPIO_PIN1);
            GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN0);
            __delay_cycles(105000);
    
            __disable_interrupt();
    
    
            buf1 = spitransferMeasurementRead(0xA000,0x0000);
            __delay_cycles(10000);
            buf2 = spitransferMeasurementRead(0x0000,0x0000);
            __delay_cycles(10000);
            buf3 = spitransferMeasurementRead(0x0000,0x0000);
            __delay_cycles(10000);
            buf4 = spitransferMeasurementRead(0x0000,0x0000);
    
            /*
            //CH1
            GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
            //__delay_cycles(10000);
            buf1 = spi_transfer(0x00);
            buf2 = spi_transfer(0x00);
            buf3 = spi_transfer(0x00);
            buf4 = spi_transfer(0x00);
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
            __delay_cycles(10000);
            //CH2
            GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
            //__delay_cycles(10000);
            buf5 = spi_transfer(0x00);
            buf6 = spi_transfer(0x00);
            buf7 = spi_transfer(0x00);
            buf8 = spi_transfer(0x00);
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
            __delay_cycles(10000);
            //CH3
            GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
            //__delay_cycles(10000);
            buf9 = spi_transfer(0x00);
            buf10 = spi_transfer(0x00);
            buf11 = spi_transfer(0x00);
            buf12 = spi_transfer(0x00);
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
            __delay_cycles(10000);
            //CH4
            GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
            //__delay_cycles(10000);
            buf13 = spi_transfer(0x00);
            buf14 = spi_transfer(0x00);
            buf15 = spi_transfer(0x00);
            buf16 = spi_transfer(0x00);
            GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
            __delay_cycles(10000);
            */
    
            ltoa(buf1, cbuf1);
            ltoa(buf2, cbuf2);
            ltoa(buf3, cbuf3);
            ltoa(buf4, cbuf4);
    
    
            buf1 = 0;
            buf2 = 0;
            buf3 = 0;
            buf4 = 0;
    
    
    
    
    
            GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
            __delay_cycles(18000);
    
            USCI_A_UART_transmitData(USCI_A0_BASE, 'A');
            USCI_A_UART_transmitData(USCI_A0_BASE, 'C');
            USCI_A_UART_transmitData(USCI_A0_BASE, 'K');
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[1]);
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[2]);
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[3]);
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[4]);
            USCI_A_UART_transmitData(USCI_A0_BASE, charArrayID[5]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf1[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf2[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf3[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf4[0]);
            /*USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf5[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf6[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf7[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf8[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf9[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf10[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf11[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf12[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, '#');
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf13[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf14[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf15[0]);
            USCI_A_UART_transmitData(USCI_A0_BASE, cbuf16[0]);*/
            USCI_A_UART_transmitData(USCI_A0_BASE, '\n');
    
    
    
            __delay_cycles(18000);
            GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0 + GPIO_PIN1);
            __enable_interrupt();
        }
    }
    
    //******************************************************************************
    //
    //This is the USCI_A0 interrupt vector service routine.
    //
    //******************************************************************************
    
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(USCI_A0_VECTOR)))
    #endif
    void USCI_A0_ISR(void)
    {
        switch(__even_in_range(UCA0IV,4))
        {
        //Vector 2 - RXIFG
        case 2:
            receivedData = USCI_A_UART_receiveData(USCI_A0_BASE);
    
            /*if(receivedData != '#')                       // Check value
            {
                if((c == 0 && receivedData == '4') || (c == 1 && receivedData == '6') || (c == 2 && receivedData == '0') || (c >= 3 && c < 13) )
                {
                    charArray[c] = receivedData;
                    c++;
                    charReceived = 0;
                }else
                {
                    c = 0;
                    charReceived = 0;
                }
            }else{
                //c = 0;
                //GPIO_toggleOutputOnPin(GPIO_PORT_P7, GPIO_PIN1);
                charReceived = 1;
            }*/
            break;
        default: break;
        }
    }
    

    But MISO line is ALWAYS LOW?!

    SPI command 16bits:

    SPI transfer for reading measurements:

    Any ideas whe MISO is always low?

    Thank you,

    Onur

  • Hello,

    I fixed up my SPI bit bang functions and now mcu communicates with ADS8684. 

    But when applying a 5V to channels, there is no life, no higher value. It always returns like 4, 20, 16, 25 from channels.

    I solved my issue. But now, I have a new issue about registers I think. If you have any ideas, please answer the post.

    Thank you,

    Onur

  • I am glad you were able to fix your initial issue. I would agree that this is probably a register issue, perhaps you have the channels programmed to different input ranges. Do you see the same issue with a different input value, at lower or higher than 5V? Page 47 of datasheet can help with the input range selection.
    Try writing to the registers, after read the registers you just programmed to make sure that they were done correctly.
    After making sure you are programming the registers correctly, and continue to have issues, one way to debug this would be to look at one channel at a time. You can do a manual channel selection, this will help you understand the timing requirements and where the conversion is going wrong. If each channel individually works correctly, then you can apply the scan or auto features, if you now see the wrong values then the problem area is further narrowed down.
    Regards
    Cynthia