AD7794 test produces no serial output

Hi, I’m untrained and inexperienced writing code but I’m trying to get my Electron running 0.7.0 OS to talk to an AD7794 via Serial Port 0. The f/w flashes fine but on Reset I get nothing on the terminal. When I flash Tinker or Blink an LED it works fine. I’m guessing the issue is with my code. Is there something obvious I’m missing. I’m using a Library I found on Github [https://github.com/jjuliano77/JJ_AD7794] and i modeled my code after their example. Thanks!


#include "JJ_AD7794.h"

#define AD7794_CS A2
#define SENSOR_EXCITATION A0
#define SPI_RATE 1000000
#define ADC_CHANNELS 6
#define REF_VOLTAGE 3.30

AD7794 adc(AD7794_CS, SPI_RATE, REF_VOLTAGE);

float readings[6]; // 6 channels

void setup() {
    
    Serial.begin(115200);

    pinMode(SENSOR_EXCITATION, OUTPUT);
    digitalWrite(SENSOR_EXCITATION, LOW); // Excitation Off
    
    adc.begin();
    delay(100);
    
    adc.setUpdateRate(470);
    
    for(int i=0; i < ADC_CHANNELS; i++){
        adc.setBipolar(i, true);
        adc.setGain(i, 128);
        adc.setEnabled(i, true);
    }
    
    delay(100);
    
    double junk = adc.read(0);
    delay (10); 
    
    adc.zero();
    
    Serial.println("AD7794");
    Serial.println("time [ms] , Channel, AD7794 value");

}

void loop() {
    
    digitalWrite(SENSOR_EXCITATION, HIGH);
    delay(1000); //mic94063 needs 800 uS to settle
    adc.read(readings, ADC_CHANNELS);
    digitalWrite(SENSOR_EXCITATION, LOW);
    
    Serial.printf("%lu, 1, %i\n\r", millis(), readings[0]);
    Serial.printf("%lu, 2, %i\n\r", millis(), readings[1]);
    Serial.printf("%lu, 3, %i\n\r", millis(), readings[2]);
    Serial.printf("%lu, 4, %i\n\r", millis(), readings[3]);
    Serial.printf("%lu, 5, %i\n\r", millis(), readings[4]);
    Serial.printf("%lu, 6, %i\n\r", millis(), readings[5]);

}

What do you mean with "Serial Port 0"?
How have you wired the AD7794?

In your AD7794::begin() function you call SPI.begin() without providing the CS pin. When using A2 as CS this won't make a lot of difference, but when opting for an alternative, that won't work since CS won't be set as OUTPUT then.

The AD7794 is connected to Electron on A5-A2 (I called it SPI 0 - better to call it the default SPI). The nets are: A5->DIN, A4->DOUT, A3->SCLK, A2->CS. I verified the AD7794 is getting 3.3V power on DVDD and AVDD.

I realized the SPI bus the AD7794 is on is shared with another IC (a flash memory chip). I did not set that CS pin state in my code (it is on B0). I’m guessing that is a mistake. Should I set that pin as Output, High?