AnsweredAssumed Answered

SPI read communication with AD7124

Question asked by simonriskjaer on Mar 2, 2016
Latest reply on Mar 7, 2016 by JellenieR



I'm using the EVAL-AD7124-8SDZ board for prototyping a new product for the company i'm interning at.

I've managed to successfully communicate to the ADC, and control the state of it's onboard GPIO pins.


I am using a MSP430G2553 MCU as master, and the ADC as slave. The ADC is set to continuous conversion mode.

However, i am having difficulties reading from the device. As of now, my comm. pattern looks like this.



ADC Setup



// Comm register -> Channel 1 register - 0x09
spiWrite(ADC, 0b00001001, 0b10000000, 0b00000001, NA, NA); // Channel 1 register -> Channel enabled, Setup 000, Positive input is AIN0, Negative input is AIN1
// Comm register -> Channel 2 register - 0x0A

spiWrite(ADC, 0b00001010, 0b10000000, 0b01000011, NA, NA); // Channel 2 register -> Channel enabled, Setup 000, Positive input is AIN2, Negative input is AIN3

// Set up config for channels
// Comm register -> Configuration register 0 - 0x19
spiWrite(ADC, 0b00011001, 0b00000001, 0b11110000, NA, NA); // Configuration register -> Unipolar, No burnout current source, All inputs buffered, ref is internal ref, gain is 1



// Set up filter register
// Comm register -> Filter register 0 - 0x21
spiWrite(ADC, 0b00100001, 0b00010000, 0b00000011, 0b11101000, NA);



// Set up error register (CRC checks etc. )
// Comm register -> Error enable register - 0x07
spiWrite(ADC, 0b00000111, 0b00000000, 0b00000000, 0b01011000, NA, NA); // Error enable register



// Set up ADC control register
// Comm register -> ADC control register - 0x01
spiWrite(ADC, 0b00000001, 0b00011111, 0b11000000, NA, NA, NA); // ADC control register



Read from ADC


// Select ADC

  digitalWrite(ADC_CS_PORT, ADC_CS_PIN, LOW);


  while (cnt < bytes)


  // Make sure USCI_A0 TX buffer is ready

  while  (!(IFG2 &   UCA0TXIFG));


  // Transmit dummy byte

  UCA0TXBUF  =  dummyByte;


  // Wait for dummy bytes to be sent

  while  (!(IFG2 &   UCA0TXIFG));


  // Load UCA0RX buffer into rx array

  rxArray[cnt] = UCA0RXBUF;




  // Deselect ADC

  digitalWrite(ADC_CS_PORT, ADC_CS_PIN, HIGH);


Needless to say, it is not working as intended. Is this the correct flow, or do i need to make changes?