Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Interfacing SPI to ADC

$
0
0

I am trying to communicate with an Analog to Digital Converter via the SPI protocol and am having some issues getting it to work. The ADC I am using is the ADS1220 made by TI,a link to the datasheet is: here. I am also using the MSP430G2553 micro controller on the value line Launchpad.

 

On page 45 of the ADS1220 datasheet there is a high level code example of how to configure the ADC to start converting in continuous conversion mode as well as read and write to some registers. I am currently trying to send it the command to start continuous conversion mode, which according to the datasheet is 0000 100X,  but am not getting and data out of either the MOSI pin or the SCK pin from the Launchpad. I also have the MOSI pin connected to the DIN pin of the ADC and the MISO connected to the DOUT/DRDY pin.

 

I am running the ADC off of a 5V supply for both analog and digital power and have grounded the negative supplies for both analog and digital. I am also using a 2.5V reference voltage as the reference signal.

 

Here is my code in Energia that I have right now:

#include <SPI.h>
bye StartAddress = B0000;
byte Start = B1000;
int Reset = 0x06;
//Try pin 8 for CS
void setup()
{
  SPI.begin(); //SCK, MOSI set to LOW
  SPI.setDataMode(1); //SPI mode 1 config
  pinMode(10, OUTPUT); //CS Output
  pinMode(5, INPUT); //DRDY Input
  pinMode(2, OUTPUT); //LED for indicator
  //attachInterrupt(5, DataReady, LOW); //DRDY Low Interrupt
  digitalWrite(10, LOW); //Bring CS LOW
  delay(500);
  SPI.transfer(Reset);
  delay(1000);
  SPI.transfer(StartAddress);
  SPI.transfer(Start); //Start Continuous Mode Conversion
  delay(500);
  digitalWrite(10, HIGH); //CS high to reset serial interface
}

void loop()
{
  if(digitalRead(5) == LOW) //Check if DRDY is low
  {
    digitalWrite(2, HIGH);
    DataReady();
  }
  
  else //Blink LED if DRDY is high
  {
    digitalWrite(2, HIGH);
    delay(500);
    digitalWrite(2, LOW);
    delay(500);
    SPI.transfer(0x05);
  }
}

void DataReady() //DataReady (DRDY) has been set low
{
  digitalWrite(10, LOW); //Take CS LOW
  delay(500);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  delay(200);
  digitalWrite(10, HIGH); //CS HIGH
  
} 

 I have attached a scope to the SCK pin, MOSI pin, and MISO pin and observed the output after numerous resets, but I never see any data signals, only noise. The SCK pin is especially noisy.

 

Any help debugging this problem would be much appreciated.


Viewing all articles
Browse latest Browse all 2077

Trending Articles