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.

ADS 1258 reading registers issue

Other Parts Discussed in Thread: ADS1258, MSP430F5438

Hi,

I have ADS1258EVM with me. I have connected DIN,DOUT,SCLK,Reset,CS,ST of EVM to my MSP430.

Connections are as follows.

P3.1(SIMO)----------> DIN

P3.2(MOSI)---------->DOUT

P3.3(SCLK)--------->SCK

P2.0-------------------->LED

P2.1-------------------->Reset

P2.2-------------------->CS

P2.3-------------------->ST

 

I am reading register by sending 0x49 on DIN but i am receiving null in receive register.

 

Code is as follows.

 

#include <msp430x54x.h>

 

unsigned char MST_Data,SLV_Data;

 

void main(void)

{

  volatile unsigned int i;

 

  WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer

 

  P2OUT |= 0x02;                            // Set P2.0 for LED

                                            // Set P2.1 for slave reset

  P2DIR |= 0x0F;                            // Set P2.0-3 to output direction

  P3SEL |= 0x31;                            // P3.5,4,0 option select

 

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

  UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB;    // 3-pin, 8-bit SPI master

                                            // Clock polarity high, MSB

  UCA0CTL1 |= UCSSEL_2;                     // SMCLK

  UCA0BR0 = 0x02;                           // /2

  UCA0BR1 = 0;                              //

  UCA0MCTL = 0;                             // No modulation

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

  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

 

  P2OUT |= 0x06;

  __delay_cycles(4096);

  P2OUT |= 0x04;

  //P2OUT &= ~0x08;

  P2OUT &= ~0x02;                          

  P2OUT |= 0x02;                            // reset slave

 

  for(i=50;i>0;i--);                        // Wait for slave to initialize

 

  MST_Data = 0x49;                         // Initialize data values

  SLV_Data = 0x8B;                         //

 

  while (!(UCA0IFG&UCTXIFG));               // USCI_A0 TX buffer ready?

  UCA0TXBUF = MST_Data;                     // Transmit first character

 

  for(i=500;i>0;i--);

  __bis_SR_register(LPM0_bits + GIE);       // CPU off, enable interrupts

}

 

#pragma vector=USCI_A0_VECTOR

__interrupt void USCIA0_ISR (void)

{

  volatile unsigned int i;

 

  if (UCA0RXBUF==SLV_Data)                  // Test for correct character RX'd

    P2OUT |= 0x01;                          // If correct, light LED

  else

    P2OUT &= ~0x01;                         // If incorrect, clear LED

 

  for(i=30;i>0;i--);                        // Add time between transmissions to

}                                           // make sure slave can keep up

Can any one please suggest what i am missing in my code?
Regards,
Pallav.

  • Hi Pallav,

    Without going through all your code - can you tell us if you have an actual SCLK applied to the ADS1258?  I ask because you say you are using P3, 2 and 1 for the SPI interface but you are setting up P3 for use with the wrong pins (P3SEL |= 0x31; // P3.5,4,0 option select).  Which MSP430 are you using?

  • Hi TOM,

    Thanks for your reply.I am using MSP430F5438.You are right i configured wrong pins,now i have changed it to 0x0E(p3.1-3).

    But still i am not getting anything on SPI.

    Could you please suggest me what should be the algorithm to read the register.

     

    Regards,

    Pallav.

  • Hi Pallav,

    On the MSP430F5438, Port 3 pins 1-3 control UCBxxxx.  After changing your P3SEL option, did you also configure the UCB port in your main()?

  • yes i did that also.

    regards,

    Pallav

  • OK!  So, one thing to try is to set your SCLK polarity to 0 and ensure that you have valid data on the rising SCLK edge.  You can modify your original code in the USC control options like this:

    UCB0CTL0 |= UCMST+UCSYNC+UCCKPH+UCMSB;  //Set PH instead of PL so SCLK dwells low, data is valid on the rising clock.

    The next thing would be to add a second transfer of 0x00 after you send the register read, address nine command - if you take a look at the data sheet for the ADS1258, page 31, Figure 58 (Register and Channel Data Read) you should notice that at least 16 clocks are required to 1.) send the command and 2.) read data.  Since the MSP430F5438 needs something placed in the transmit buffer to generate the SCLK, you could simply send first the 0x49 (your Master_Data) and follow that with 0x00.  The ID register contents should be output with the second set of eight clocks.