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.

ADS1248 connecting to MSP430

Other Parts Discussed in Thread: ADS1248, MSP430F449, MSP430F2274

Hello,

i am trying to program my MSP430 with ADS1248 via SPI.

Can someone post me some example codes?

 

Best regards,

Patrick B.

 

 

  • Patrick,

    I've attached part of the code we use for the ADS1248EVM firmware.  This portion of code includes the set-up of the SPI for the MSP430F449 called 'ads_init()'.  There is also the ISR called 'ads_isr()'.  You may also find that the read and write register routines are helpful.  One thing to note, the code we use runs with freeRTOS.  Trying to decipher how and why some of the code works the way it does can be confusing.

    Best regards,

    Bob B

  • Hi Bob,

     

    thanks a lot for your help!

     

    Best regards,

    Patrick B.

  • Dear,

     

    i have some trouble by reading the register from the ADS1248.

    I wrote a Test code to verify my SPI connection and i can't get the values of the registers.
    Maybe i missapply.
    Can someone  have a look on my code, pleas.

    i use the MSP430f2274...

    #define WAKEUP        0x00
    #define SLEEP        0x02
    #define SYNC        0x04
    #define RESET        0x06
    #define    NOP            0xFF
    #define RDATA        0x12
    #define RDATAC        0x14
    #define SDATAC        0x16
    #define RREG        0x20            
    #define WREG        0x40   
    #define SYSOCAL        0x60
    #define SYSGCAL        0x61
    #define SELFOCAL    0x62   


    #define sec  150

    #define CS      0x01        //Px.0  Port 3 MSP430f2274
    #define MR      0x02        //Px.1    Port 2
    #define Start    0x01        //Px.0    Port 2
    #define DRDY    0x04        //Px.2    Port 2
    #define PWRSEL  0x08        //Px.3    Port 2

    void UART_Init()
    {

      P3SEL = 0x3A;                
      P3DIR = 0x05;
      DCOCTL = CALDCO_8MHZ;        
      BCSCTL1 = CALBC1_8MHZ;        
      UCA0CTL1 = UCSSEL_2;           
      UCA0BR0 = 0x41;               
      UCA0BR1 = 0x3;               
      UCA0MCTL = UCBRS_2;           

     //SPI
      UCB0CTL0 = UCSYNC+UCMST+UCMSB;           
      UCB0CTL1 = UCSSEL_2;
      UCB0BR0 = 0x04;                
      UCB0BR1 = 0x00;               
      UCA0CTL1 &= ~UCSWRST;        
    __bis_SR_register(GIE);
    }

    int read(int *data)
    {
       
        P3DIR = 0x01;                        //P3.0 OUT
       
       
        P3OUT &= ~CS;                       // CS LOW

             UCB0TXBUF=NOP;          // dummy
           *data = UCB0RXBUF;
            while(!(IFG2&UCB0TXIFG));
           
         wait(sec);
        P3OUT = CS;                        // CS High
                                     
         return *data;
    }

    void main(void){
        volatile long temp;
        int data=0;
       
       
        WDTCTL = WDTPW + WDTHOLD; // Stop WDT
        UART_Init();

        command(WAKEUP);
        command(RREG); //Command1 Reg 0 =MUX0
        command(0x01); //Command2
        temp=read(&data);
       

    }

     

    Best regards,
    Patrick B.

  • Patrick,

    I wonder about your command() function.  Chip select must be low through the whole sequence including the read().  In other words, the two commands sent and the read must be done with the CS line low the whole time.  If the CS toggles, then the SPI communication is reset.

    You might also want to verify the data being written to the ADS1248 is correct.  You can do this with an oscilloscope.

    Best regards,

    Bob B