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.

reference code to interface ADS1130 ADS1230 with MSP430FXX

Other Parts Discussed in Thread: ADS1130, ADS1230, MSP430F449

Hi

I was looking for a reference code to interface the ADS1130/ADS1230 with the MSP430 microcontrollers.

Kind Regards

Suchitra

  • Hi Suchitra,

     

    The source code for our ADS1230REF evaluation board is available here: ftp://ftp.ti.com/pub/data_acquisition/ADS123xREF/ADS123x_CDROM/ MSP430F449.  So reviewing the source code for that should give you a good reference of how to interface the ADS1230 with the MSP430.

     

    Rudye

     

  • Hi

    I have written a small code to read conversion values from ADS1130.  Can you please check if the code is ok. I am not getting consistency in readings. Just wanted to check if my code to read the ADC is right, since its just 3 days I have been using this component.

    Kind Regards

     

    Suchitra

    ///==========================================================================================================================

    // C O D E STARTS

    ///==========================================================================================================================

    //=========================================================================
    #include  <msp430x20x3.h>
    #define  LOAD_CELL_ENABLE       0x10;
    #define  ADC_ENABLE             0x80;
    #define  DELAY_20_MS            40000;
    #define  DATA_READY             (0x08) //p1.3    
    #define  SCLK                            (0x02) // p1.1
    //=========================================================================
    // used to count number of samples taken
    //static unsigned int SampleValue = 0;

    // Indicates max number of samples
    //static unsigned int SampleNum = 512;

    // Used to store current ADCValue
    long int CurrentADCValue, ADCValue;

    //static unsigned int ADCOffset;

    // Used to store previous ADC value
    //..static unsigned long int LastADCValue;
    //static unsigned int VoltageSettleCtr;
    //static unsigned int int_val_adc = 0;
    //static unsigned int ReadTemperature;

    // Used along with the delay set this to the desired delay
    static unsigned long int DelayVal;

    //=========================================================================
    // function prototypes
    //=========================================================================
    void InitializeDevice(void) ;
    void delay (void);
    void GetNewValues(void);
    void ReadADCData(void);
    //=========================================================================
    //                M A I N  P R O G R A M
    //=========================================================================
    void main(void) {
      // Device initialisation   
      InitializeDevice();
    while (1) {   
      GetNewValues();
    }
      // GO to low power mode
     // _BIS_SR(LPM0_bits + GIE);
     //
     }
    //==========================================================================
    // This function polls for the new conversion values avaliable. And reads the
    // values into the variables
    //==========================================================================
    void GetNewValues(void) {
      unsigned int adcDataCnt = 0;
      // Enable the load Cells
      P1OUT |= LOAD_CELL_ENABLE;

      // Enable the ADC
      P2OUT |= ADC_ENABLE;

      // Wait for the voltage to get settled
      DelayVal = DELAY_20_MS;
      delay();

      ADCValue = 0;
      for (adcDataCnt = 0; adcDataCnt <60; adcDataCnt++) {
        ReadADCData();
      // discard first 11 values
        if (adcDataCnt > 9) {
        //  CurrentADCValue = 500;
          ADCValue = ADCValue + CurrentADCValue;
        }
      }
      ADCValue = ADCValue/50;
      // Disable the load cells and ADC
      P1OUT &= LOAD_CELL_ENABLE;

      // Enable the ADC
      P2OUT &= ADC_ENABLE;
    }
    //==========================================================================
    //ReadADCData
    //==========================================================================
    void ReadADCData(void) {
      unsigned int temp_adc_val = 0;
      unsigned int clk_count = 0;   
      // Wait for data Ready
      CurrentADCValue = 0;
      while (P1IN & DATA_READY) {
        _NOP();     
      }
      // Toggle clock and get the ADC value in CurrentADCValue;
      for (clk_count = 0; clk_count <23; clk_count++) {
        P1OUT ^= SCLK;
        _NOP();
       
        // Valid ADC bits are only 18 rest clocks are applied to force the drdy high
        if (clk_count < 18) {
          temp_adc_val = (P1IN & DATA_READY);
          temp_adc_val = (temp_adc_val/8);
         
          // Move the data right once
          CurrentADCValue =  CurrentADCValue << 1;
          CurrentADCValue |= temp_adc_val;
        } 
        P1OUT ^= SCLK;
        _NOP();
      } 
    }
    //===========================================================================
    // This function configurations
    // PORT
    // WDT
    // clock  selection
    // Initialise local variables
    //
    //
    //===========================================================================
    void InitializeDevice(void) {
    //===========================================================================
    // Program port directions
    //===========================================================================
    // o = Input 1 = output
    //
      P2SEL = 0;
      P1SEL = 0;
      P1DIR = 0xB2;
      P2DIR = 0xC0;
      P1OUT = 0;
      P2OUT = 0;
     
    //disable the WDT + enable nmi
      WDTCTL = WDTPW + WDTHOLD + WDTNMI + WDTNMIES;
    // Select VLO as clock source for ACLK
      BCSCTL3 |= LFXT1S_2;
     
      // reference voltage work around
      asm(" MOV.B # 0x61, & 0xbf");     
    // Initialize variables
    //  SampleValue = 0;
      //ADCOffset = 000;
      //SampleNum = 512;
      //LastADCValue = 0;
      //VoltageSettleCtr = 0;
      ADCValue = 0;
      //ReadTemperature = 1;
      P2OUT &= ADC_ENABLE;
    }
    //================================================================================
    //================================================================================
    void delay (void)
    //===========================================================================
    {
      volatile unsigned long int tmp_delay;
      tmp_delay = DelayVal;
      while (tmp_delay > 0) {
          tmp_delay --;
         ;
      }
    }

    ///==========================================================================================================================

    // Code Ends

    ///==========================================================================================================================

  • Hi

    the problem I find here is after the 24 clocks are applied in the ReadADCData() the DRDY/DOUT pin should go high. Which is not happening. So How do I know if I am starting a the right point for the next value.

    Kind regards

    Suchitra

  • Hi Suchitra,

    I looked through your 'ReadADCData' function and don't immediately see any reason why it wouldn't work.  If you use an oscilloscope on the DRDY/DOUT pin, do you see it going high?

    Are you using an ADS1130 or an ADS1230?  The original post subject mentions both.  Also, it would really be helpful to have a scope trace of both the DRDY/DOUT and the SCLK lines.  That way, we can review the timing.  I'm not sure how fast your digital lines are running by just reviewing the code.  Can you provide these?

    Regards,

    Rudye

     

  • Hi Rudye

    I am using ADS1130. Unfortunately I don't have a scope to send you the trace of the signals. If I enable the ADC with proper AVDD and Vss connections and keep the PDWN high. I should see the DRDY/DOUT pin toggeling every tconv time. Is my understanding right?

    Kind Regards

    Suchitra

  • Suchitra,

    Your basic understanding is correct, but you must have all pins connected.  That means you must have DVDD and DGND connected to the DVDD supply, as should be the digital input pins, and the analog reference pins.  The reference can be connected to AVDD.  You can pull the digital input pins low.  If you pull the SPEED pin low, you should see the DRDY/DOUT pin pulse low to high to low every 10th of a second with no SCLK (pin low and the PDWN pulled high.

    Best regards,

    Bob B.