AD7794 library function doesn't execute

I’m using the following library on Electron running 0.7.0:
[https://github.com/jjuliano77/JJ_AD7794]

Following his 6 channel example, when I issue this command:

double junk = adc.read(0);

the electron fails to advance beyond

This is the code it calls:

//Experiment with reading all active channels, this may be the way I go in the future UNTESTED
void AD7794::read(float *buf, uint8_t bufSize)
{
  uint8_t readingCnt = 0 ;

  for(int i = 0;  i < CHANNEL_COUNT; i++){
    if(Channel[i].isEnabled){
      if(readingCnt < bufSize){
        buf[readingCnt] = read(i);
      }else{
        //buffer too small!
        //Maybe return an error code?
      }
      readingCnt++;
    }
  }
}

/* read - The single channel version
   Gets reading from a single channel. Right now it
   is in volts (default scailing), but I may have it use
   a scaling setting stored for each channel. I might also
   just save that for a higher level hardware abstraction class.
*/
float AD7794::read(uint8_t ch)
{
  //Lets the conversion result
  uint32_t adcRaw = getReadingRaw(ch);
  //Serial.print(adcRaw);
  //Serial.print(' ');
  float result;

  if(ch == 6){ //Channel 6 is temperature, handle it differently 1.17 V internal Ref
    return (((float)adcRaw / ADC_MAX_BP - 1) * 1.17); //Bipolar, not sure what mode for temp sensor
  }

  //And convert to Volts, note: no error checking
  if(Channel[currentCh].isUnipolar){
    result = (adcRaw * vRef) / (ADC_MAX_UP * Channel[currentCh].gain);            //Unipolar formula
    //Serial.print("unipolar");
  }
  else{
    result = (((float)adcRaw / ADC_MAX_BP - 1) * vRef) / Channel[currentCh].gain; //Bipolar formula    
    //Serial.print("bipolar");
  }

  return result - Channel[currentCh].offset;
}

I know nothing about code :confused: so I don’t know what the issue might be.

Any help is much appreciated.

As an aside, I’m really interested in learning more about C++. My background is in hardware, but I’d like to be able to write firmware too. How can i get a crash course?

Suggest you start with hardware first and ensure that is all correct. Can you post a picture of how you have wired this up. Do you have pullup resistors on the SPI bus lines? Next, have you had any SPI bus device working with your Electron? The likely scenario with the code stopping at the adc.read(0) statement is that the SPI bus has not been correctly setup. The library on Github will require porting to Particle - I had a look and there is no community library. I would suggest posting the code here for other to look at.

Thanks for the help. The AD7794 is on the same SPI bus as a W25X40CL Flash IC. The connections to Electron are on A5-A2. The nets are: A5->DIN, A4->DOUT, A3->SCLK, A2->CS. I verified the AD7794 is getting 3.3V power on DVDD and AVDD. There are no pull-ups on any of these lines. The W25X40CL uses B0->CS, which I think is correctly set in my code. This carrier board design has worked fine in the past in the hands of someone skilled at writing code - not me! Haha!