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.

ADS1242 connexion with msp430f4281

Other Parts Discussed in Thread: ADS1242, MSP430F2481, ADS1243

Hello;

I wanted your opinion to connect an ms430f2481 to ADS1242 :

MSP.MCLK.p1.4  ==> ADS.XIN

MSP.SIMO.p5.1 ==> ADS.PDI

MSP.SOMI.p5.2 <== ADS.PDO

MSP.CLK.p5.3  ==>  ADS.PCLK

MSP.p4.3  ==> ADS.PDWN

MSP.p4.4  ==> ADS.DRDY

MSP.p4.5  ==>  ADS.CS

and Vref is 1.25v and Vdd is 3.3v

Thank you

  • Hi Hamdi,

    Your connections should work except for the your connection for DRDY as this is an external interrupt to the processor for alerting when a conversion has finished.  So, ADS.DRDY should be an input to the processor, and if you want it to be used as an interrupt (instead of polling the pin), which is what I would suggest, you need to connect the pin to one of the P1 or P2 port pins that have interrupt capability.

    Best regards,

    Bob B

  • Hi Bob;

    i have a problem to generate a clock with 2,4576 MHZ or 4,9152  required by the ADS1243 because I wired the P1.4(SMCLK) of my msp430f2481 to XIN of ADS1243. And i don't have a FLL in my msp430.

    Have you any idea how to generate a clock at 2,4576 Mhz from my msp430?

    Or should be used an external clock?

    have you a code example for the ADS1243?

    Thank you.

  • Hi Hamdi,

    You could add an external crystal, or external crystal oscillator to the ADS1243.  However, you should be able to set the DCO frequency of the MSP430 to something higher than what is needed for the ADS1243 (9.83 MHz for example) and then divide it down.  The MSP430 forum should be able to help you get something close and then you can divide by 2 or 4.  I'm not that familiar with this particular MSP430, but you may be able to connect a 9.8304MHz crystal to the MSP430 directly as use for MCLK and use MCLK divided by 2 or 4 for the ADS1243.

    Keep in mind that the filter notches will depend on the actual frequency of the clock, so if you need filtering for 50/60Hz then you will require a more precise clock for the ADS1243.

    Best regards,

    Bob B

  • I have had problems with incorrect readings.

    Has anyone else experienced problems like this? And if so how did you solve them? 

    Thank you

    /**************************************************************************//**
    * @brief spi_init used to read ADS1243 device
    *****************************************************************************/
    void spi_ads1243_init(void)
    {
    u16 i;

    gpio_mux_and_ads_init();

    for (i = 0; i < 0xfffe; i++); // Delay for XTAL stabilization
    DCOCTL = 0x9E;   // 4.9 MHZ
    BCSCTL1 = 0xBB;    
    P1DIR |= 0x10; // P1.4 output
    P1SEL |= 0x10; // P1.4 SMCLK output

    UCB1CTL1 |= UCSWRST; // Reset USCI0 Module
    P5SEL |= 0x0E; //P5.1 P5.2 P5.3 for
    UCB1CTL0 |= UCMST+UCSYNC+UCMSB+UCCKPH; //UCCKPH UCCKPL+
    UCB1CTL1 = 0xC0;
    UCB1STAT = 0; // clear all error bits
    UCB1BR0 = 0x02; // MCLK/2 for baud rate
    UCB1BR1 = 0x00;
    // MCLK/2 for baud rate
    UCB1CTL1 &= ~UCSWRST; /* Reset USCI0 Module */
    }

    /**************************************************************************//**
    * @brief spi send byte to ADS1243 device
    *****************************************************************************/
    u16 spi_ads1243_send_byte(u8 data)
    {
    // Waits until SPI registers empty
    UCB1TXBUF = data;
    while(UCB1STAT & UCBUSY); // Waits until SPI registers empty

    return SUCCESS;


    }
    /**************************************************************************//**
    * @brief spi receive byte from ADS1243 device
    *****************************************************************************/
    u8 spi_ads1243_recv_byte(void)
    {
    spi_ads1243_send_byte(0); /* sends dummy data to generate CLK */
    return UCB1RXBUF;
    }
    /**************************************************************************//**
    * @brief assert chip select
    *****************************************************************************/
    void ADS1243AssertCS(u16 fAssert)
    {
    if (fAssert)
    P4OUT &= ~ADS1243_CS;
    else
    P4OUT |= ADS1243_CS;
    }

    /**************************************************************************//**
    * @brief read data from ADS1243
    *****************************************************************************/
    u32 ADS1243ReadData(u16 fWaitForDataReady)
    {
    u32 Data;
    Data = 0;

    // assert CS to start transfer
    ADS1243AssertCS(1);

    // send the command byte
    spi_ads1243_send_byte(ADS1243_CMD_RDATA);

    delay_ticks(2); // wait 200ms

    Data = spi_ads1243_recv_byte();
    Data = (Data << 8) | spi_ads1243_recv_byte();
    Data = (Data << 8) | spi_ads1243_recv_byte();


    // sign extend data
    if (Data & 0x800000)
    Data |= 0xff000000;

    // de-assert CS
    ADS1243AssertCS(0);
    return Data;
    }

    float read_pt100_sensor()
    {
    int chan = 0;
    unsigned ACRVal;
    u8 i;
    u32 Data = 0;

    //1-a) reset command
    ADS1243SendResetCommand();
    //1-b) write setup register
    ADS1243SetGain(ADS1243_GAIN_1);
    //1-c) set cjannel
    ADS1243SetChannel(chan | ADS1243_MUXP_AIN0 | ADS1243_MUXP_AIN1 | ADS1243_MUXP_AIN2 | ADS1243_MUXP_AIN3 | ADS1243_MUXP_AIN4 | ADS1243_MUXP_AIN5 | ADS1243_MUXN_AIN6);
    // 1-d) write ACR register data rate = 15Hz (4.91MHz, SPEED = 1)
    ACRVal = SPEED_BIT;   //0x20
    ADS1243WriteRegister(ADS1243_ACR_REGISTER, 1, &ACRVal);
    //selfcal command
    ADS1243AssertCS(1);
    spi_ads1243_send_byte(ADS1243_CMD_SELFCAL);
    ADS1243AssertCS(0);
    //dsync command write
    ADS1243AssertCS(3);
    spi_ads1243_send_byte(ADS1243_CMD_DSYNC);
    ADS1243AssertCS(0);

    DATA = ADS1243ReadData(1);

    }

  • Hi Hamdi,

    You really haven't stated the problem.  You have incorrect readings, but you have not stated what the readings are and what you expect to see.  What do you have connected to the inputs?

    A couple of things that are not clear is whether or not you assert CS when the commands are given, such as in ADS1243Setgain() or ADS1243WriteRegister() functions.  Another thing that is not clear to me is why you wait 200ms after giving the RDATA command before reading the data.  I'm not sure how the device state machine will handle this amount of delay.  Typically the delay period is slightly greater than the minimum of 50 tosc periods which would be slightly more than 10us for 4.9152MHz crystal.  The conversion period is about 67ms.  This may be part of the problem you are seeing.

    Best regards,

    Bob B

  • Hi Bob,

    Thank you for your reply.

    I am using ADS1242 in the attached Pt100 measurement circuit.

    I have three differential input, one for PT100 and 2 to calibration with resistence to 0 ohm and 130ohm

    1)AIN0 101mv and AIN1 44mv (for resistence to 130ohm) MUX 0x01

    2)AIN6 44mv and AIN7 44mv (for resistence to 0 ohm) MUX 0x67

    1)AIN4 48mv and AIN5 92mv (for PT100) MUX 0x45

    A current of 440µA is sent to the Pt100 resistance.

    writing and reading registers works well.

    I changed the configuration, i wait 100ms after config and 10us after sendig READ command.

    value received

    1) 16777033

    1) 381797

    1) 16777067

    I must have 0 for the first case. 

    how to convert mv? Vmv= (value received/ 2^24) vcc?

    Thank you.

  • Hi Hamdi,

    I don't think your schematic attached properly.  I'm a little confused too by the last post saying you are using the ADS1242, but all your code is for the ADS1243.

    It appears there is something wrong with your sign extension or the declaration is incorrect. 16777033 is very close to zero, but in the negative direction.  Are you using a signed value?  After looking at the declaration it appears that you are using unsigned 32 instead of signed 32.

    Best regards,

    Bob B