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.

Running an ADS1248 with a MSP430F5438

Other Parts Discussed in Thread: MSP430F5438, ADS1248, ADS1148

Hi, I'm trying to  run an ADS1248 with a MSP430F5438 for my university project, but I'm having some problems. I've done the initialization functions with the TI examples and an ADS1248 application code that I've found in the forum. Here is my code:

Here are my files:

5554.ads1248.c
/*
 * ads1248.c
 */

#include "msp430x54x.h"
#include "ads1248.h"

// Global variables

unsigned char regreadads[15]; //Tabla con los registros de control del AD
unsigned char regwriteads[15]; //Tabla con los registros de control del AD


// Functions

void ADS1248AssertCS(int fAssert)
{
   if (fAssert)
      P9OUT &= !(ADS1248_CS);
   else
      P9OUT |=  ADS1248_CS;
}

int ADS1248SendResetCommand(void)
{

  char dummy;

   // assert CS to start transfer
   ADS1248AssertCS(1); // CS goes low

   // send the command byte
    while(!(UCB2IFG & UCTXIFG));
    UCB2TXBUF = ADS1248_CMD_RESET;
    while(!(UCB2IFG & UCRXIFG));
    dummy = UCB2RXBUF;

   // de-assert CS
   ADS1248AssertCS(0); // CS goes high

   __delay_cycles(48000); //0.6ms pause -> oscF*0.6ms=8Mhz*0.6ms = 128000 (as specified in datasheet)

   return 0;
}

//Lee u
void ADS1248ReadData(int* dato)
{
  char dummy;

  // assert CS to start transfer
  ADS1248AssertCS(1); // CS goes low

  //Waiting for DRDY low
  while(P9IN & ADS1248_DRDY);

  //RDATA command is sent
  while(!(UCB2IFG & UCTXIFG));
  UCB2TXBUF = ADS1248_CMD_RDATA;
  while(!(UCB2IFG & UCRXIFG));
  dummy = UCB2RXBUF;
  __delay_cycles(20); //Pause

  //Read 24 bits data
  UCB2TXBUF = 0xff;
  while(!(UCB2IFG & UCRXIFG));
  *dato = UCB2RXBUF; //MSB


  UCB2TXBUF = 0xff;
  while(!(UCB2IFG & UCRXIFG));
  *(dato++) = UCB2RXBUF; //Mid-Byte

  UCB2TXBUF = 0xff;
  while(!(UCB2IFG & UCRXIFG));
  *(dato++) = UCB2RXBUF; //LSB

  ADS1248AssertCS(0); // CS goes high
}


int initSPIads1248(void)
{
  //Configuraci�n del puerto 9:
  //P9.1 UCB2SIMO -> Master Output
  //P9.2 UCB2SOMI -> Master Input
  //P9.3 UCB2CLK -> Clock
  //P9.0 O -> ADS1248_CS, activate at low level
  //P9.6 O -> ADS1248_START
  //P9.7 I <- ADS1248_DRDY
  P9SEL |= 0x0E;
  P9DIR |= 0x41;

  //P8.7 O -> ADS1248_RESET, activate at low level
  P8SEL |= 0x00;
  P8DIR |= 0x80;

  //8 bit, MSB first, synchronous
  UCB2CTL0 |= UCMST + UCSYNC;
  //Clock source SMCLK
  UCB2CTL1 |= UCSSEL_2;  // SMCLK
  //SMCLK/4 = 8Mhz/4
  UCB2BR0 = 0x04; // /4
  UCB2BR1 = 0;    //

  UCB2CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

  //Power-On sequence
  ADS1248AssertCS(0);
  P9OUT |= ADS1248_START; //Start High
  P8OUT &= !(ADS1248_RESET); //Reset High
  __delay_cycles(128000); //0.6ms pause -> oscF*0.6ms=8Mhz*0.6ms = 128000 (as specified in datasheet)
  ADS1248AssertCS(1);

  return 0;
}

/* stop collecting data */
void ADS1248Stop(void)
{
      unsigned char dummy;

      // Reset SPI
      ADS1248AssertCS(0); // CS goes high
      __delay_cycles(30); //Pausa
      ADS1248AssertCS(1); // CS goes low

      // Command to stop taking continous readings

      //Waiting for DRDY low
      while(P9IN & ADS1248_DRDY);

      while(!(UCB2IFG & UCTXIFG));
              UCB2TXBUF = ADS1248_CMD_SDATAC;
      while(!(UCB2IFG & UCRXIFG));
              dummy = UCB2RXBUF;
      __delay_cycles(20); Pause

      ADS1248AssertCS(0); // CS goes high

}

int ADS1248CargaInicial(void)
{
  int i;
  int resultado;

  initSPIads1248();

  ADS1248SendResetCommand();

  ADS1248Stop();

  //We read all the records from AD to store records that are modified 
  //and then we can compare all records
  ADS1248ReadRegister();

  //We copy log records read table to table to write records
  for(i=0;i<15;i++)
    regwriteads[i] = regreadads[i];

  //We configured the first four records
  /* MUX0 = 00 Burnout current off
            000 AIN0 is positive
            001 AIN1 is negative
            = 0x01 */
  regwriteads[ADS1248_MUX0_REGISTER] = 0x01;

  /* VBIAS = 0x00 No se aplica Vbias */
  regwriteads[ADS1248_VBIAS_REGISTER] = 0x00;

  /* MUX1 = 0 Internal osclilator
            01 internal reference always ON (Necesary for IDAC)
            00 REF0 external Rbias is used
            000 Normal Operation
          = 0x20 */
 regwriteads[ADS1248_MUX1_REGISTER] = 0x20;

  /*SYS0 = 0 Always is 0
           000 Gain is 1
           0011 40SPS
         = 0x03
  */
  regwriteads[ADS1248_SYS0_REGISTER] = 0x03;

  //We write the first four registers
  ADS1248WriteRegister(ADS1248_MUX0_REGISTER , 4);

  //IDAC0 ad IDAC1 configuration
  /*IDAC0 = 0000 Always is 0 0
            0 DOUT//DRDY pin functions only as Data Out
            110 IDAC = 1ma
          = 0x06*/
  regwriteads[ADS1248_IDAC0_REGISTER] = 0x06;
  /*IDAC1 = 0000 first current source in AIN0
            0001 second current source in AIN1
          = 0x01*/
  regwriteads[ADS1248_IDAC1_REGISTER] = 0x01;
  //We write the register
  ADS1248WriteRegister(ADS1248_IDAC0_REGISTER , 2);

  //We read registers to verify that writing was successful
  ADS1248ReadRegister();

  //we compare registers
  resultado = 0;
  for(i=0;i<15;i++)
  {
    if (regwriteads[i] != regreadads[i])
      resultado = 1;
  }

  __delay_cycles(10000); //Pausa

  return resultado;
}


/*It writes the control parameters in the registers*/
int ADS1248WriteRegister(int StartAddress, int NumRegs)
{
  int i;
  unsigned char dummy;
  unsigned char reg[15]; //Tabla que datos a escribir

  //Copy data from general table to transmision table
  for (i=0;i<NumRegs;++i)
  {
    reg[i] = regwriteads[StartAddress + i];
  }

  ADS1248Stop(); //Stop collecting data

  // assert CS to start transfer
  ADS1248AssertCS(1); // CS goes low

  //First command: direction of the first writting register 
  while(!(UCB2IFG & UCTXIFG));
  UCB2TXBUF = ADS1248_CMD_WREG + StartAddress;

  //second command: number of writting registers
  while(!(UCB2IFG & UCRXIFG));
  dummy = UCB2RXBUF;
  while(!(UCB2IFG & UCTXIFG));
  UCB2TXBUF = NumRegs - 1;

  //Data bytes: Data of the writting registers
  while(!(UCB2IFG & UCRXIFG));
  dummy=UCB2RXBUF;
  for (i=0;i<NumRegs;++i)
  {
    while(!(UCB2IFG & UCTXIFG));
    UCB2TXBUF = reg[i];
    while(!(UCB2IFG & UCRXIFG));
    dummy = UCB2RXBUF;
  }

  __delay_cycles(1000); //Pausa

  ADS1248AssertCS(0); // CS goes high

  return 0;


}

/*It reads the control parameters of the registers*/
void ADS1248ReadRegister()
{
  unsigned char dummy;
  unsigned char reg[15];
  int i=0;

  ADS1248Stop(); //Stop collecting data
  __delay_cycles(40); //Pause

  // Reset SPI
  ADS1248AssertCS(0); // CS goes high
  __delay_cycles(10); //Pause
  ADS1248AssertCS(1); // CS goes low

  while(!(UCB2IFG & UCTXIFG));
  UCB2TXBUF = ADS1248_CMD_RREG;	// Command for register read
  while(!(UCB2IFG & UCRXIFG));
  dummy = UCB2RXBUF;


  while(!(UCB2IFG & UCTXIFG));
  UCB2TXBUF = 0x0E;		// Command for number of registers to read
  while(!(UCB2IFG & UCRXIFG));
  dummy = UCB2RXBUF;

  while(i<15)
  {
	  UCB2TXBUF = 0xff;
	  while(!(UCB2IFG & UCRXIFG));
	  reg[i] = UCB2RXBUF;           // read register data
	  i++;
  }

  //Copy read table to general table
  for(i=0;i<15;i++)
    regreadads[i] = reg[i];

  ADS1248AssertCS(0); // CS goes high
}


5305.main.c
/*
 * main.c
 */

#include "msp430x54x.h"
#include "ads1248.h"

void init(void)
{
	WDTCTL = WDTPW + WDTHOLD;				// Stop WDT
	
	// Initialize LFXT1
	P7SEL |= 0x03;                            // Select XT1
	UCSCTL6 &= ~(XT1OFF);                     // XT1 On
	UCSCTL6 |= XCAP_3;                        // Internal load cap C=12.0pF

	// Loop until XT1 fault flag is cleared
	do
	{
	  UCSCTL7 &= ~XT1LFOFFG;                  // Clear XT1 fault flags
	}while (UCSCTL7&XT1LFOFFG);               // Test XT1 fault flag

	// Initialize DCO to 2.45MHz
	__bis_SR_register(SCG0);                  // Disable the FLL control loop
	UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
	UCSCTL1 = DCORSEL_6;                      // Set RSELx for DCO = 4.9 MHz
	UCSCTL2 = FLLD_1 + 243;                   // Set DCO Multiplier for 2.45MHz
	                                          // (N + 1) * FLLRef = Fdco
	                                          // (243 + 1) * 32768 = ___ MHz

	                                          // Set FLL Div = fDCOCLK/2
	__bic_SR_register(SCG0);                  // Enable the FLL control loop

	  // Worst-case settling time for the DCO when the DCO range bits have been
	  // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
	  // UG for optimization.
	  // 32 x 32 x 8 MHz / 32,768 Hz = 249856 = MCLK cycles for DCO to settle
	__delay_cycles(249856);

}

void initRS232(void)
{
	P3SEL = 0x30;                           // P3.4,5 = USCI_A0 TXD/RXD

	UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
	UCA0CTL1 |= UCSSEL_2;                     // CLK = DCO

	UCA0BR0 = 0x41;                           // ~8MHz/9600=833 (see User's Guide)
	UCA0BR1 = 0x03;                           //
	//UCA0MCTL = UCBRS_2+UCBRF_0;               // Modulation UCBRSx=2, UCBRFx=0
	UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
	//UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
}

void enviaRS232(int Code)
{
	while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
	UCA0TXBUF = Code;
}

void main(void)
{
	int valor[3];

	init();
	initRS232();
	ADS1248CargaInicial();

	while(1)
	{
		ADS1248ReadData(valor);
		enviaRS232(valor[0]);
		__delay_cycles(20);
		enviaRS232(valor[1]);
		__delay_cycles(20);
		enviaRS232(valor[2]);
		__delay_cycles(20);
	}
}

3073.ads1248.h

The program always stops at the ADS1248Stop functiong, waiting to the DRDY ads1248 pin to goes low (the line says: while(P9IN & ADS1248_DRDY);)

I don't know if it is a programming error or a hardware error. I've connected this pins between the ADS and the MSP:

ADS pin 1: 5V

ADS pin 2: gnd

ADS pin 3: gnd

ADS pin 4: MPS pin 67

ADS pin 11 and 12: function generator with sinusoidal waveform

ADS pin 23: MPS pin 74

ADS pin 24: MPS pin 68

ADS pin 25: MPS pin 75

ADS pin 26: MPS pin 70 

ADS pin 27: MPS pin 69

ADS pin 28: MPS pin 71

The other pins aren't connected.

Thanks in advance

  • Hello.

    You're wrong the connection to SPI and DRDY.  See it on the datasheet http://www.ti.com/lit/ds/symlink/ads1248.pdf.

    I do not know what kind of package microcontroller you use, so I can not give an example of the connection.

    Without reference to the microcontroller, can be found in my post. ADS1148 and ADS1248 case identical.

    http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/232388.aspx

  • Tell me please what information do you need. WHat do you mean when you say that I'm not connecting well the SPI DRDYs connection?

    Thanks anyway!

  • According to the datasheet for ADS1248

    SPI:

    CS - 24 pin
    DOUT - 26 pin
    DIN - 27 pin
    SCLK - 28 pin

    +

    DRDY - 25 pin

    START - 23 pin

    + necessary

    AVDD - 22 pin on positive

    AVSS - 21 pin on negative

    Information about package microcontroller not need. I have not read the datasheet carefully. Sorry )

  • Now I understand you, I'm sorry that was my mistake, I'm connecting the ADS SPI as you say, now I'm going to edit the first post. So that isn't the problem :(

  • Maybe you will attach scheme? It would be easier to understand.

  • Santiago,

    It is not clear if you have the DVDD supply connected.  Also, START pin must be in high state or device will be in powerdown.  As Pavel mentioned a complete schematic of how all the pins and supplies are connected and where they are sourced would be helpful.  For example, how are you supplying the reference voltage? Do you have the required cap on VREFOUT?

    Also, if connecting a signal generator to the analog inputs you must take care that the signal source does not go below AVSS.

    Best regards,

    Bob B

  • Hi Bob,

    Yes the DVDD supply is connected to 5V. Now I see that I'm missing thigs to connect. Tomorrow I will post a complete schematic of the connections.

    I don't have the required cap on VREFOUT, do you remember something else that could be missing?

    Thanks!

  • Hi Santiago,

    You should also have bypass caps near the pins from the supply pins (AVDD to AVSS and DVDD to GND) of a value around 0.1uF.

    Best regards,

    Bob B

  • Hi, here I have the schematic of the project. I have put the bypass capacitor and the capacitor between the VREFOUT and VREFCOM, but the program stops in this command line, inside the ADS1248Stop():

    while(P9IN & ADS1248_DRDY);

    2843.PCB_Project1 (1).pdf

  • Santiago,

    VREFCOM should also connect to DVSS.  You should place bypass caps at each device power input pins too.  Have you measured the voltages to make sure that they are what they should be?  Especially the digital control pins like RESET and START?  Do you have an oscilloscope so that you can actually probe the DRDY pin?  If you do not read any data from the device, you should see the DRDY dwell low and periodically pulse high and then low at the specified data rate.  Are you able to see this?

    Best regards,

    Bob B

  • Hello, I have to say that I have solved all the hardware problems. Now the application is running, but it isn't giving me the results I want.

    I've connected a sinusoidal waveform (the voltages doesn't go below AVSS) of low frequency and I'm sending with RS232 throw the MSP to the PC and seeing the result in a Labview application. I think that maybe I'm making some mistake in the configuration functions that I'm using in the file ads1248.c. Here I attach the files, can you say me if the initialization and configurations is correct?

    8030.ads1248.c
    /*
     * ads1248.c
     */
    
    #include "msp430x54x.h"
    #include "ads1248.h"
    
    // Global variables
    
    unsigned char regreadads[15]; //Tabla con los registros de control del AD
    unsigned char regwriteads[15]; //Tabla con los registros de control del AD
    
    
    // Functions
    
    void ADS1248AssertCS(int fAssert)
    {
       if (fAssert)
          P9OUT &= ~(ADS1248_CS);
       else
          P9OUT |=  ADS1248_CS;
    }
    
    int ADS1248SendResetCommand(void)
    {
    
      char dummy;
    
       // assert CS to start transfer
       ADS1248AssertCS(1); // CS goes low
    
       // send the command byte
        while(!(UCB2IFG & UCTXIFG));
        UCB2TXBUF = ADS1248_CMD_RESET;
        while(!(UCB2IFG & UCRXIFG));
        dummy = UCB2RXBUF;
    
       // de-assert CS
       ADS1248AssertCS(0); // CS goes high
    
       __delay_cycles(48000); //0.6ms pause -> oscF*0.6ms=8Mhz*0.6ms = 128000 (as specified in datasheet)
    
       return 0;
    }
    
    //Lee u
    void ADS1248ReadData(int* dato)
    {
      char dummy;
    
      // assert CS to start transfer
      ADS1248AssertCS(1); // CS goes low
    
      //Waiting for DRDY low
      while(P9IN & ADS1248_DRDY);
    
      //RDATA command is sent
      while(!(UCB2IFG & UCTXIFG));
      UCB2TXBUF = ADS1248_CMD_RDATA;
      while(!(UCB2IFG & UCRXIFG));
      dummy = UCB2RXBUF;
      __delay_cycles(20); //Pause
    
      //Read 24 bits data
      UCB2TXBUF = 0xff;
      while(!(UCB2IFG & UCRXIFG));
      *dato = UCB2RXBUF; //MSB
    
    
      UCB2TXBUF = 0xff;
      while(!(UCB2IFG & UCRXIFG));
      *(dato++) = UCB2RXBUF; //Mid-Byte
    
      UCB2TXBUF = 0xff;
      while(!(UCB2IFG & UCRXIFG));
      *(dato++) = UCB2RXBUF; //LSB
    
      ADS1248AssertCS(0); // CS goes high
    }
    
    
    int initSPIads1248(void)
    {
      //Configuraci�n del puerto 9:
      //P9.1 UCB2SIMO -> Master Output
      //P9.2 UCB2SOMI -> Master Input
      //P9.3 UCB2CLK -> Clock
      //P9.0 O -> ADS1248_CS, activate at low level
      //P9.6 O -> ADS1248_START
      //P9.7 I <- ADS1248_DRDY
    
      P9DIR &= 0x30;
      P9DIR |= 0x41;
      P9SEL &= 0x30;
      P9SEL |= 0x0E;
    
      //P8.6 O -> ADS1248_RESET, activate at low level
    
      P8SEL &= 0x00;
      P8DIR &= 0x00;
      P8DIR |= 0x40;
    
      //8 bit, MSB first, synchronous
      UCB2CTL0 |= UCMST + UCSYNC;
      //Clock source SMCLK
      UCB2CTL1 |= UCSSEL_2;  // SMCLK
      //SMCLK/4 = 8Mhz/4
      UCB2BR0 = 0x04; // /4
      UCB2BR1 = 0;    //
    
      UCB2CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    
      //Power-On sequence
      ADS1248AssertCS(0);
      P9OUT |= ADS1248_START; //Start High
      P8OUT |= ADS1248_RESET; //Reset High
      __delay_cycles(64000);
      __delay_cycles(64000); //0.6ms pause -> oscF*0.6ms=8Mhz*0.6ms = 128000 (as specified in datasheet)
      ADS1248AssertCS(1);
    
      return 0;
    }
    
    /* stop collecting data */
    void ADS1248Stop(void)
    {
          unsigned char dummy;
    
          // Reset SPI
          ADS1248AssertCS(0); // CS goes high
          __delay_cycles(30); //Pausa
          ADS1248AssertCS(1); // CS goes low
    
          // Command to stop taking continous readings
    
          //Waiting for DRDY low
          while(P9IN & ADS1248_DRDY);
    
          while(!(UCB2IFG & UCTXIFG));
                  UCB2TXBUF = ADS1248_CMD_SDATAC;
          while(!(UCB2IFG & UCRXIFG));
                  dummy = UCB2RXBUF;
          __delay_cycles(20); Pause
    
          ADS1248AssertCS(0); // CS goes high
    
    }
    
    int ADS1248CargaInicial(void)
    {
      int i;
      int resultado;
    
      initSPIads1248();
    
      ADS1248SendResetCommand();
    
      ADS1248Stop();
    
      //We read all the records from AD to store records that are modified 
      //and then we can compare all records
      ADS1248ReadRegister();
    
      //We copy log records read table to table to write records
      for(i=0;i<15;i++)
        regwriteads[i] = regreadads[i];
    
      //We configured the first four records
      /* MUX0 = 00 Burnout current off
                000 AIN0 is positive
                001 AIN1 is negative
                = 0x01 */
      regwriteads[ADS1248_MUX0_REGISTER] = 0x01;
    
      /* VBIAS = 0x00 No se aplica Vbias */
      regwriteads[ADS1248_VBIAS_REGISTER] = 0x00;
    
      /* MUX1 = 0 Internal osclilator
                01 internal reference always ON (Necesary for IDAC)
                00 REF0 external Rbias is used
                000 Normal Operation
              = 0x20 */
     regwriteads[ADS1248_MUX1_REGISTER] = 0x20;
    
      /*SYS0 = 0 Always is 0
               000 Gain is 1
               0011 40SPS
             = 0x03
      */
      regwriteads[ADS1248_SYS0_REGISTER] = 0x03;
    
      //We write the first four registers
      ADS1248WriteRegister(ADS1248_MUX0_REGISTER , 4);
    
      //IDAC0 ad IDAC1 configuration
      /*IDAC0 = 0000 Always is 0 0
                0 DOUT//DRDY pin functions only as Data Out
                110 IDAC = 1ma
              = 0x06*/
      regwriteads[ADS1248_IDAC0_REGISTER] = 0x06;
      /*IDAC1 = 0000 first current source in AIN0
                0001 second current source in AIN1
              = 0x01*/
      regwriteads[ADS1248_IDAC1_REGISTER] = 0x01;
      //We write the register
      ADS1248WriteRegister(ADS1248_IDAC0_REGISTER , 2);
    
      //We read registers to verify that writing was successful
      ADS1248ReadRegister();
    
      //we compare registers
      resultado = 0;
      for(i=0;i<15;i++)
      {
        if (regwriteads[i] != regreadads[i])
          resultado = 1;
      }
    
      __delay_cycles(10000); //Pausa
    
      return resultado;
    }
    
    
    /*It writes the control parameters in the registers*/
    int ADS1248WriteRegister(int StartAddress, int NumRegs)
    {
      int i;
      unsigned char dummy;
      unsigned char reg[15]; //Tabla que datos a escribir
    
      //Copy data from general table to transmision table
      for (i=0;i<NumRegs;++i)
      {
        reg[i] = regwriteads[StartAddress + i];
      }
    
      ADS1248Stop(); //Stop collecting data
    
      // assert CS to start transfer
      ADS1248AssertCS(1); // CS goes low
    
      //First command: direction of the first writting register 
      while(!(UCB2IFG & UCTXIFG));
      UCB2TXBUF = ADS1248_CMD_WREG + StartAddress;
    
      //second command: number of writting registers
      while(!(UCB2IFG & UCRXIFG));
      dummy = UCB2RXBUF;
      while(!(UCB2IFG & UCTXIFG));
      UCB2TXBUF = NumRegs - 1;
    
      //Data bytes: Data of the writting registers
      while(!(UCB2IFG & UCRXIFG));
      dummy=UCB2RXBUF;
      for (i=0;i<NumRegs;++i)
      {
        while(!(UCB2IFG & UCTXIFG));
        UCB2TXBUF = reg[i];
        while(!(UCB2IFG & UCRXIFG));
        dummy = UCB2RXBUF;
      }
    
      __delay_cycles(1000); //Pausa
    
      ADS1248AssertCS(0); // CS goes high
    
      return 0;
    
    
    }
    
    /*It reads the control parameters of the registers*/
    void ADS1248ReadRegister()
    {
      unsigned char dummy;
      unsigned char reg[15];
      int i=0;
    
      ADS1248Stop(); //Stop collecting data
      __delay_cycles(40); //Pause
    
      // Reset SPI
      ADS1248AssertCS(0); // CS goes high
      __delay_cycles(10); //Pause
      ADS1248AssertCS(1); // CS goes low
    
      while(!(UCB2IFG & UCTXIFG));
      UCB2TXBUF = ADS1248_CMD_RREG;	// Command for register read
      while(!(UCB2IFG & UCRXIFG));
      dummy = UCB2RXBUF;
    
    
      while(!(UCB2IFG & UCTXIFG));
      UCB2TXBUF = 0x0E;		// Command for number of registers to read
      while(!(UCB2IFG & UCRXIFG));
      dummy = UCB2RXBUF;
    
      while(i<15)
      {
    	  UCB2TXBUF = 0xff;
    	  while(!(UCB2IFG & UCRXIFG));
    	  reg[i] = UCB2RXBUF;           // read register data
    	  i++;
      }
    
      //Copy read table to general table
      for(i=0;i<15;i++)
        regreadads[i] = reg[i];
    
      ADS1248AssertCS(0); // CS goes high
    }
    
    
    

    2117.main.c
    /*
     * main.c
     */
    
    #include "msp430x54x.h"
    #include "ads1248.h"
    
    void init(void)
    {
    	WDTCTL = WDTPW + WDTHOLD;				// Stop WDT
    	
    	// Initialize LFXT1
    	P7SEL |= 0x03;                            // Select XT1
    	UCSCTL6 &= ~(XT1OFF);                     // XT1 On
    	UCSCTL6 |= XCAP_3;                        // Internal load cap C=12.0pF
    
    	// Loop until XT1 fault flag is cleared
    	do
    	{
    	  UCSCTL7 &= ~XT1LFOFFG;                  // Clear XT1 fault flags
    	}while (UCSCTL7&XT1LFOFFG);               // Test XT1 fault flag
    
    	// Initialize DCO to 2.45MHz
    	__bis_SR_register(SCG0);                  // Disable the FLL control loop
    	UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
    	UCSCTL1 = DCORSEL_6;                      // Set RSELx for DCO = 4.9 MHz
    	UCSCTL2 = FLLD_1 + 243;                   // Set DCO Multiplier for 2.45MHz
    	                                          // (N + 1) * FLLRef = Fdco
    	                                          // (243 + 1) * 32768 = ___ MHz
    
    	                                          // Set FLL Div = fDCOCLK/2
    	__bic_SR_register(SCG0);                  // Enable the FLL control loop
    
    	  // Worst-case settling time for the DCO when the DCO range bits have been
    	  // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
    	  // UG for optimization.
    	  // 32 x 32 x 8 MHz / 32,768 Hz = 249856 = MCLK cycles for DCO to settle
    	__delay_cycles(249856);
    
    }
    
    void initRS232(void)
    {
    	P3SEL = 0x30;                           // P3.4,5 = USCI_A0 TXD/RXD
    
    	UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
    	UCA0CTL1 |= UCSSEL_2;                     // CLK = DCO
    
    	UCA0BR0 = 0x41;                           // ~8MHz/9600=833 (see User's Guide)
    	UCA0BR1 = 0x03;                           //
    	//UCA0MCTL = UCBRS_2+UCBRF_0;               // Modulation UCBRSx=2, UCBRFx=0
    	UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    	//UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
    }
    
    void enviaRS232(int Code)
    {
    	while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    	UCA0TXBUF = Code;
    }
    
    void main(void)
    {
    	int valor[3];
    
    	init();
    	initRS232();
    	ADS1248CargaInicial();
    
    	while(1)
    	{
    		ADS1248ReadData(valor);
    		enviaRS232(valor[0]);
    		__delay_cycles(20);
    		enviaRS232(valor[1]);
    		__delay_cycles(20);
    		enviaRS232(valor[2]);
    		__delay_cycles(20);
    	}
    }
    

    7041.ads1248.h

    Thanks a lot

  • Santiago,

    Before I struggle through the code, what is your input frequency?  What is your input voltage? What is your data rate?  What are you expecting to see?  What do you see?

    Remember that this is a delta-sigma converter, it is very precise, but each conversion will be representative of many samples taken at the modulator rate and then processed by the digital filter.  See the various filter profiles shown on pages 27 and 28 of the datasheet.

    If you've added any analog filtering to the inputs, this must also be considered.

    Best regards,

    Bob B

  • Hi Bob, 

    Finally my application is running well. I've solved all the hardware problems with your indications. I had a software mistake that I've found in the configuration. Now I can see the the sinusoidal waveform in my Labview application. 

    I have one more doubt about the AD1248. Now I'm only acquiring information of channel AIN0-1 (differetial). Can I acquire information of more than one channel? 

    Best regards,

    Santiago

  • Hi Santiago,

    I'm glad to hear that you are making progress.  Yes, you can read from other input channels.  To do this you need to change the settings in the MUX0 register.

    Best regards,

    Bob B

  • Hi Santiago,

    Could you send me your final schematic and code of ADS1248 and MSP430? I'm new member to ADS1248 IC.

    my Email: tranthuy.mta@gmail.com

    Thanks and best regards,