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.

ADS1259 SPI

Other Parts Discussed in Thread: MSP430F5508, ADS1259

Hi,

I'm trying to program ADS1259 with MSP430f5508 through SPI.

Is there any application note or example code how to do this in CCS5?

Regards David.

  • Hi David,

    There are some C Code examples for the MSP430F5508 using SPI communication here: http://www.ti.com/litv/zip/slac394c.

    We don't have much example code specifically for the ADS1259. You can try seaching the E2E forums for some examples. These threads have some links to related code examples:

    http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/217076.aspx
    http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/p/197313/704459.aspx

    Regards,
    Chris

  • Hi,

    I'm trying to get ads1259 to work but it won't work I don't know where is the problem.

    What is the best method to check if the SPI is working?

    My code :

    #include <msp430.h>
    #include "gpio.h"


    int main(void)
    {
    volatile unsigned int i;
    volatile unsigned char junk;

    WDTCTL = WDTPW+WDTHOLD; // Stop WDT

    GPIO_setOutputHighOnPin(
    GPIO_PORT_P4,
    GPIO_PIN3
    ); // CS chip select
    P4DIR |= 0x08; // Set P4.3 to output direction
    P4SEL |= BIT0+BIT4+BIT5; // P4.0,4,5 option select

    UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
    UCA1CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
    // Clock polarity high, MSB
    UCA1CTL1 |= UCSSEL_2; // SMCLK
    UCA1BR0 = 0x02; // /2
    UCA1BR1 = 0; //
    UCA1MCTL = 0; // No modulation
    UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt

    P4OUT &= ~0x08; // CS low
    for(i=50000;i>0;i--);

    //stop continnus mode

    UCA1IFG &= ~UCRXIFG;
    /* Send the byte */
    UCA1TXBUF = 0x11;
    /* Wait for the byte to be sent */
    while ((UCA1IFG & UCRXIFG) == 0) { }

    //read register - adress

    UCA1IFG &= ~UCRXIFG;
    /* Send the byte */
    UCA1TXBUF = 0x21;
    /* Wait for the byte to be sent */
    while ((UCA1IFG & UCRXIFG) == 0) { }

    //read register second optcode num of reg, and wait to recive data

    UCA1IFG &= ~UCRXIFG;
    /* Send the byte */
    UCA1TXBUF = 0x00;
    /* Wait for the byte to be received */
    while ((UCA1IFG & UCRXIFG) == 0) { }
    junk = UCA1RXBUF; // data reg config1 ads1259

    #pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    {
    switch(__even_in_range(UCA1IV,4))
    {
    case 0:break; // Vector 0 - no interrupt
    case 2: // Vector 2 - RXIFG
    //while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
    //UCA0TXBUF = UCA0RXBUF;
    break;
    case 4:break; // Vector 4 - TXIFG
    default: break;
    }
    }

  • Hi David,

    What "symptoms" are you seeing, are you reading data back? Are you able to take any oscilloscope screenshots of the SPI communication?

    One of my colleagues took a brief look at your code and noticed that the clock polarity is set HIGH, when it should be low:

    David V said:
    UCA1CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
    // Clock polarity high, MSB

    Regards,
    Chris

  • Hi Christopher,

    I changed it to low as you said.

    1st problem was : I replaced by accident CS and CLK line on the chip :)

    Now it the transmit data ok , I checked it with OSCOPE

    code for transmit

    transmitData = 0x20;
    //USCI_A0 TX buffer ready?
    while (!USCI_A_SPI_getInterruptStatus(USCI_A1_BASE,
    USCI_A_SPI_TRANSMIT_INTERRUPT)) ;
    USCI_A_SPI_transmitData(USCI_A1_BASE, transmitData);

    But i'm trying to read the config0 and 1 register that means to read confing0 register I must send

    first 0x20 and then 0x00 and then the rxbuf=b10xx0101.

    But I always different  byte.

    I don't know what is the problem.

    Regards David.