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.

AFE4490: Averaging ADC samples produces no output change in signal (CONTROL1 register)

Part Number: AFE4490

Hello,

I built a PCB with an AFE4490 that is sending data through bluetooth to a phone app. On the app, I collect and plot the data. The problem is that I believe I optimized my script, yet I only get about 40 hz signal on the phone side. My sample shows a "stair case" pattern, and I'd like my signal smoother. 

To do this, I want to take advantage of averaging my ADC samples on the AFE4490 prior to having my micro controller (ATmega32u4) send the data through bluetooth (RN42 bluetooth module) to my android application. I've changed my Pulse Repetition Frequency to 250 hz (~277hz for a 4ms pulse repetition period). I've did this on the AFE44x0SPO2EVM GUI to ensure my other registers (PRPCOUNT, etc) also updated appropriately (and I do get lots more than 40 hz on the EVM board using the GUI). I then change my CONTROL1 in my firmware to account for 16 samples (0b10001111, or 0x0010F in hex).  When I average 16 ADC samples, however, my signal looks exactly the same as if I averaged only 1.  How can I change CONTROL1 (or other relevant registers) to average more samples on the AFE4490 prior to sending data from my micro controller?

I'm writing the firmware in Arduino, and programming using an AVR MKII. Android app written in Android Studio. 

Microcontroller sends data to app in 8 bits (2 start, 3 for red LED, 3 for IR LED).

Thanks,

Morris

Arduino Code obtaining values. I tried averaging multiple samples on the micro controller at first, but I want to average on the AFE4490 directly, hence the samples=1 line below (since the sample obtained should already be 16 samples averages by the AFE4490)

void SPIReadRedIR() {
  // Read the value of a register as a byte, send through serial1
  byte byteArray[8];
  int samples = 1;  //Number of samples to average
  float IRSum = 0.f; // running sum to average, so as not to read twice
  float RedSum = 0.f;
  uint32_t IRAverage = 0;
  uint32_t RedAverage = 0;

  //SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

  for (int i=0; i<samples; i++){
    byte regAddress=LED2MINUSALED2VAL;
    // set address, and then get bytes 1, 2, and 3, get final value in uint32_t format
    SPI.transfer(regAddress);   // SPI.tranfer simultaneously sends and receives
    //delay(10);
    byteArray[0] = 0xEE; //first start bit
    byteArray[1] = 0xCC; //second start bit
    byteArray[2] = SPI.transfer(0x00);
    byteArray[3] = SPI.transfer(0x00);
    byteArray[4] = SPI.transfer(0x00);
    IRAverage = IRAverage + ((byteArray[4] << 16) | (byteArray[3] << 8) | byteArray[2]);
    
    regAddress=LED1MINUSALED1VAL;
    // set address, and then get bytes 1, 2, and 3, get final value in uint32_t format
    SPI.transfer(regAddress);   // SPI.tranfer simultaneously sends and receives
    byteArray[5] = SPI.transfer(0x00);
    byteArray[6] = SPI.transfer(0x00);
    byteArray[7] = SPI.transfer(0x00);
    RedAverage = RedAverage + ((byteArray[7] << 16) | (byteArray[6] << 8) | byteArray[5]);

    //Serial1.write(byteArray, 8);
  }

//  IRAverage = IRSum/samples;
//  RedAverage = RedSum/samples;
  
  byteArray[2] = IRAverage;
  byteArray[3] = (IRAverage >> 8);
  byteArray[4] = (IRAverage >> 16);
  byteArray[5] = RedAverage;
  byteArray[6] = (RedAverage >> 8);
  byteArray[7] = (RedAverage >> 16);

  Serial1.write(byteArray, 8);
  // Release slave; disable reading from registers
  //digitalWrite(chipSelectPin, HIGH);
  //SPIDisableRead();
  //SPI.endTransaction();
}

 

My register values inside an AFEinit() function.

SPIWriteReg(CONTROL0, 0x000000);
SPIWriteReg(LED2STC, 0x002A9E);
SPIWriteReg(LED2ENDC, 0x003866);
SPIWriteReg(LED2LEDSTC, 0x002A4E);
SPIWriteReg(LED2LEDENDC, 0x003867);
SPIWriteReg(ALED2STC, 0x000050);
SPIWriteReg(ALED2ENDC, 0x000E18);
SPIWriteReg(LED1STC, 0x000E6A);
SPIWriteReg(LED1ENDC, 0x001C32);
SPIWriteReg(LED1LEDSTC, 0x000E1A);
SPIWriteReg(LED1LEDENDC, 0x001C33);
SPIWriteReg(ALED1STC, 0x001C84);
SPIWriteReg(ALED1ENDC, 0x002A4C);
SPIWriteReg(LED2CONVST, 0x000006);
SPIWriteReg(LED2CONVEND, 0x000E19);
SPIWriteReg(ALED2CONVST, 0x000E20);
SPIWriteReg(ALED2CONVEND, 0x001C33);
SPIWriteReg(LED1CONVST, 0x001C3A);
SPIWriteReg(LED1CONVEND, 0x002A4D);
SPIWriteReg(ALED1CONVST, 0x002A54);
SPIWriteReg(ALED1CONVEND, 0x003867);
SPIWriteReg(ADCRSTSTCT0, 0x000000);
SPIWriteReg(ADCRSTENDCT0, 0x000005);
SPIWriteReg(ADCRSTSTCT1, 0x000E1A);
SPIWriteReg(ADCRSTENDCT1, 0x000E1F);
SPIWriteReg(ADCRSTSTCT2, 0x001C34);
SPIWriteReg(ADCRSTENDCT2, 0x001C39);
SPIWriteReg(ADCRSTSTCT3, 0x002A4E);
SPIWriteReg(ADCRSTENDCT3, 0x002A53);
SPIWriteReg(PRPCOUNT, 0x003867);
SPIWriteReg(CONTROL1, 0x00010F);  // 
SPIWriteReg(SPARE1, 0x000000);
SPIWriteReg(TIAGAIN, 0x000000);
SPIWriteReg(TIA_AMB_GAIN, 0x000000);
SPIWriteReg(LEDCNTRL, 0x01FF80);
SPIWriteReg(CONTROL2, 0x020100);
SPIWriteReg(SPARE2, 0x000000);
SPIWriteReg(SPARE3, 0x000000);
SPIWriteReg(SPARE4, 0x000000);
SPIWriteReg(RESERVED1, 0x000000);
SPIWriteReg(RESERVED2, 0x000000);
SPIWriteReg(ALARM, 0x000000);
SPIWriteReg(LED2VAL, 0x000000);
SPIWriteReg(ALED2VAL, 0x000000);
SPIWriteReg(LED1VAL, 0x000000);
SPIWriteReg(ALED1VAL, 0x000000);
SPIWriteReg(LED2MINUSALED2VAL, 0x000000);
SPIWriteReg(LED1MINUSALED1VAL, 0x000000);
SPIWriteReg(DIAG, 0x000000);

My register addresses

#define CONTROL0 0x00
#define CONTROL1 0x1E
#define CONTROL2 0x23
#define PRPCOUNT 0x1D
#define LEDCNTRL 0x22
#define LED1LEDSTC 0x09
#define LED1LEDENDC 0x0A
#define LED2LEDSTC 0x03
#define LED2LEDENDC 0x04
#define LED2STC 0x01 // h for hexa
#define ALED2STC 0x05
#define TIAGAIN 0x20
#define TIA_AMB_GAIN 0x21
#define LED2ENDC        0x02
#define ALED2ENDC       0x06
#define LED1STC         0x07
#define LED1ENDC        0x08
#define ALED1STC        0x0b
#define ALED1ENDC       0x0c
#define LED2CONVST      0x0d
#define LED2CONVEND     0x0e
#define ALED2CONVST     0x0f
#define ALED2CONVEND    0x10
#define LED1CONVST      0x11
#define LED1CONVEND     0x12
#define ALED1CONVST     0x13
#define ALED1CONVEND    0x14
#define ADCRSTSTCT0     0x15
#define ADCRSTENDCT0    0x16
#define ADCRSTSTCT1     0x17
#define ADCRSTENDCT1    0x18
#define ADCRSTSTCT2     0x19
#define ADCRSTENDCT2    0x1a
#define ADCRSTSTCT3     0x1b
#define ADCRSTENDCT3    0x1c
#define SPARE1          0x1f
#define SPARE2          0x24
#define SPARE3          0x25
#define SPARE4          0x26
#define RESERVED1       0x27
#define RESERVED2       0x28
#define ALARM           0x29
#define DIAG            0x30
#define LED2VAL   0x2A
#define ALED2VAL  0x2b
#define LED1VAL   0x2C
#define ALED1VAL 0x2D
#define LED2MINUSALED2VAL   0x2e
#define LED1MINUSALED1VAL   0x2f