Post Go back to editing

measuring voltage across reference electrode and sensing electrode

Category: Hardware
Product Number: EVAL-AD5940

Hi, I'm using EVAL-AD5940 with ADICUP3029 in cyclic voltammetry. How do I get the voltage (Vse-Vre) corresponding to the measured current in iar workbench so i can plot CV response like in Sensorpal.

Parents
  • You may measure Vse  and Vre w.r.t. Vzero each by setting these as inputs in ADC mux in the code:

    AD5940_ADCMuxCfgS(ADCMUXP_VRE0, ADCMUXN_VZERO0);

    AD5940_ADCMuxCfgS(ADCMUXP_VSE0, ADCMUXN_VZERO0);

     

  • Thank you for your reply, Akila, but I'm still confused with MUX and Data structure. I have further questions?

    1. Can we measure VRE, VSE and current simultaneously?
    2. How can we store the measurement results in pBuff and show these results through uart? 

    An example code for these questions would be great. 

  • Hi,

    You may refer to the examples here:ad5940-examples/examples at master · analogdevicesinc/ad5940-examples · GitHub

    example code snippet for measuring VRE0:

    AD5940_ADCMuxCfgS(ADCMUXP_VRE0, ADCMUXN_VZERO0);
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
    AD5940_Delay10us(16*25);
    AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE); /* Start ADC convert*/
    AD5940_Delay10us(WaitClks);
    timeout = 0;
    while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) {
    AD5940_Delay10us(1);
    if (++timeout > AD5940_FLAG_TIMEOUT) {
    AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
    AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
    return bFALSE;
    }
    }

    AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
    afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_ADCCNV|AFECTRL_SINC2NOTCH, bFALSE); /* Stop ADC */
    VREVoltageValue = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1, 1.82);

    printf("\n VRE0 Voltage : %d V\n", VREVoltageValue);

Reply
  • Hi,

    You may refer to the examples here:ad5940-examples/examples at master · analogdevicesinc/ad5940-examples · GitHub

    example code snippet for measuring VRE0:

    AD5940_ADCMuxCfgS(ADCMUXP_VRE0, ADCMUXN_VZERO0);
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
    AD5940_Delay10us(16*25);
    AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE); /* Start ADC convert*/
    AD5940_Delay10us(WaitClks);
    timeout = 0;
    while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) {
    AD5940_Delay10us(1);
    if (++timeout > AD5940_FLAG_TIMEOUT) {
    AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
    AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
    return bFALSE;
    }
    }

    AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
    afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
    AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_ADCCNV|AFECTRL_SINC2NOTCH, bFALSE); /* Stop ADC */
    VREVoltageValue = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1, 1.82);

    printf("\n VRE0 Voltage : %d V\n", VREVoltageValue);

Children
  • Thank you for your reply,Akila, but I don't quite understand the code you gave me. Can you show me the full Ramptest.c file on how to measure and display voltage vs Reference Electrode and the current corresponding to the voltage. I expect the result likes in the picture below.Expected Result

  • Below is the code for reading (VRE -VSE) and current for your reference:

    #include "ad5940.h"
    #include "AD5940.h"
    #include <stdio.h>
    #include "string.h"
    #include "math.h"
    #include "Amperometric.h"
    
    float LFOSCFreq;
    
    AppAMPCfg_Type AppAMPCfg = 
    {
      .bParaChanged = bFALSE,
      .SeqStartAddr = 0,
      .MaxSeqLen = 0,
      
      .SeqStartAddrCal = 0,
      .MaxSeqLenCal = 0,
      .FifoThresh = 5,              /* Number of points for FIFO */
      
      .SysClkFreq = 16000000.0,
      .WuptClkFreq = 32000.0,
      .AdcClkFreq = 16000000.0,
      .AmpODR = 1.0,                /* Sample time in seconds. I.e. every 5 seconds make a measurement */
      .NumOfData = -1,
      .RcalVal = 10000.0,           /* RCAL = 10kOhm */
      .PwrMod = AFEPWR_LP,
      .AMPInited = bFALSE,
      .StopRequired = bFALSE,
      
      /* LPTIA Configure */
      .ExtRtia = bFALSE,            /* Set to true if using external RTIA */
      .LptiaRtiaSel = LPTIARTIA_4K, /* COnfigure RTIA */
      .LpTiaRf = LPTIARF_1M,        /* Configure LPF resistor */
      .LpTiaRl = LPTIARLOAD_100R,
      .ReDoRtiaCal = bTRUE,
      .RtiaCalValue = 0,
    	.ExtRtiaVal = 0,
      
    /*LPDAC Configure */
      .Vzero = 1100,                /* Sets voltage on SE0 and LPTIA */
      .SensorBias = 500,            /* Sets voltage between RE0 and SE0 */
      
    /* ADC Configure*/
      .ADCPgaGain = ADCPGA_1P5,
      .ADCSinc3Osr = ADCSINC3OSR_4,
      .ADCSinc2Osr = ADCSINC2OSR_22,
      .DataFifoSrc = FIFOSRC_SINC2NOTCH,
      .ADCRefVolt = 1.8162,			/* Measure voltage on ADCRefVolt pin and enter here*/
    };
    
    /**
       This function is provided for upper controllers that want to change 
       application parameters specially for user defined parameters.
    */
    AD5940Err AppAMPGetCfg(void *pCfg)
    {
      if(pCfg){
        *(AppAMPCfg_Type**)pCfg = &AppAMPCfg;
        return AD5940ERR_OK;
      }
      return AD5940ERR_PARA;
    }
    
    
    void AD5940AMPStructInit(void)
    {
      AppAMPCfg_Type *pAMPCfg;
      
      AppAMPGetCfg(&pAMPCfg);
    	pAMPCfg->WuptClkFreq = LFOSCFreq;
      /* Configure general parameters */
      pAMPCfg->SeqStartAddr = 0;
      pAMPCfg->MaxSeqLen = 512;     /* @todo add checker in function */  
      pAMPCfg->RcalVal = 10000.0;
      pAMPCfg->NumOfData = -1;      /* Never stop until you stop it manually by AppAMPCtrl() function */	
    	
    	
    	/* Configure measurement parameters */
      pAMPCfg->AmpODR = 1;          	/* Time between samples in seconds */
      pAMPCfg->FifoThresh = 4;      		/* Number of measurements before alerting host microcontroller */
    	
      pAMPCfg->SensorBias = 0;   			/* Sensor bias voltage between reference and sense electrodes*/
    	pAMPCfg->LptiaRtiaSel = LPTIARTIA_1K;
    	pAMPCfg->LpTiaRl = LPTIARLOAD_10R;
    	pAMPCfg->Vzero = 1100;        		/* Vzero voltage. Voltage on Sense electrode. Unit is mV*/
    	
    	pAMPCfg->ADCRefVolt = 1.82;		/* Measure voltage on Vref_1V8 pin */
    }
    
    static AD5940Err AppAMPCfg_(void)
    {
      AD5940Err error = AD5940ERR_OK;
    
      AFERefCfg_Type aferef_cfg;
      LPLoopCfg_Type lp_loop;
      DSPCfg_Type dsp_cfg;
      SWMatrixCfg_Type sw_cfg;
    
      aferef_cfg.HpBandgapEn = bTRUE;
      aferef_cfg.Hp1V1BuffEn = bTRUE;
      aferef_cfg.Hp1V8BuffEn = bTRUE;
      aferef_cfg.Disc1V1Cap = bFALSE;
      aferef_cfg.Disc1V8Cap = bFALSE;
      aferef_cfg.Hp1V8ThemBuff = bFALSE;
      aferef_cfg.Hp1V8Ilimit = bFALSE;
      aferef_cfg.Lp1V1BuffEn = bTRUE;
      aferef_cfg.Lp1V8BuffEn = bTRUE;
      /* LP reference control - turn off them to save power*/
      aferef_cfg.LpBandgapEn = bTRUE;
      aferef_cfg.LpRefBufEn = bTRUE;
      aferef_cfg.LpRefBoostEn = bFALSE;
      AD5940_REFCfgS(&aferef_cfg);	
    
      	lp_loop.LpDacCfg.LpdacSel = LPDAC0;
      lp_loop.LpDacCfg.LpDacSrc = LPDACSRC_MMR;
      lp_loop.LpDacCfg.LpDacSW = LPDACSW_VBIAS2LPPA|LPDACSW_VBIAS2PIN|LPDACSW_VZERO2LPTIA|LPDACSW_VZERO2PIN;
      lp_loop.LpDacCfg.LpDacVzeroMux = LPDACVZERO_6BIT;
      lp_loop.LpDacCfg.LpDacVbiasMux = LPDACVBIAS_12BIT;
      lp_loop.LpDacCfg.LpDacRef = LPDACREF_2P5;
      lp_loop.LpDacCfg.DataRst = bFALSE;
      lp_loop.LpDacCfg.PowerEn = bTRUE;
      lp_loop.LpDacCfg.DacData6Bit = (uint32_t)((AppAMPCfg.Vzero-200)/DAC6BITVOLT_1LSB);
    	lp_loop.LpDacCfg.DacData12Bit =(int32_t)((AppAMPCfg.SensorBias)/DAC12BITVOLT_1LSB) + lp_loop.LpDacCfg.DacData6Bit*64;
    	if(lp_loop.LpDacCfg.DacData12Bit>lp_loop.LpDacCfg.DacData6Bit*64)
    		lp_loop.LpDacCfg.DacData12Bit--;
    	lp_loop.LpAmpCfg.LpAmpSel = LPAMP0;
      lp_loop.LpAmpCfg.LpAmpPwrMod = LPAMPPWR_NORM;
      lp_loop.LpAmpCfg.LpPaPwrEn = bTRUE;
      lp_loop.LpAmpCfg.LpTiaPwrEn = bTRUE;
      lp_loop.LpAmpCfg.LpTiaRf = AppAMPCfg.LpTiaRf;
      lp_loop.LpAmpCfg.LpTiaRload = AppAMPCfg.LpTiaRl;
      if(AppAMPCfg.ExtRtia == bTRUE)
      {
        lp_loop.LpAmpCfg.LpTiaRtia = LPTIARTIA_OPEN;
        lp_loop.LpAmpCfg.LpTiaSW = LPTIASW(9)|LPTIASW(2)|LPTIASW(4)|LPTIASW(5)|LPTIASW(12)|LPTIASW(13); 
      }else
      {
        lp_loop.LpAmpCfg.LpTiaRtia = AppAMPCfg.LptiaRtiaSel;
        lp_loop.LpAmpCfg.LpTiaSW = LPTIASW(5)|LPTIASW(2)|LPTIASW(4)|LPTIASW(12)|LPTIASW(13); 
      }
      AD5940_LPLoopCfgS(&lp_loop);
    
      
      dsp_cfg.ADCBaseCfg.ADCMuxN = ADCMUXN_VZERO0;
      dsp_cfg.ADCBaseCfg.ADCMuxP = ADCMUXP_AIN4;
      dsp_cfg.ADCBaseCfg.ADCPga = AppAMPCfg.ADCPgaGain;
      
      memset(&dsp_cfg.ADCDigCompCfg, 0, sizeof(dsp_cfg.ADCDigCompCfg));
      memset(&dsp_cfg.DftCfg, 0, sizeof(dsp_cfg.DftCfg));
      dsp_cfg.ADCFilterCfg.ADCAvgNum = ADCAVGNUM_16;  /* Don't care because it's disabled */
      dsp_cfg.ADCFilterCfg.ADCRate = ADCRATE_800KHZ;	/* Tell filter block clock rate of ADC*/
      dsp_cfg.ADCFilterCfg.ADCSinc2Osr = AppAMPCfg.ADCSinc2Osr;
      dsp_cfg.ADCFilterCfg.ADCSinc3Osr = AppAMPCfg.ADCSinc3Osr;
      dsp_cfg.ADCFilterCfg.BpSinc3 = bFALSE;
      dsp_cfg.ADCFilterCfg.BpNotch = bFALSE;
      dsp_cfg.ADCFilterCfg.Sinc2NotchEnable = bTRUE;
      
      memset(&dsp_cfg.StatCfg, 0, sizeof(dsp_cfg.StatCfg)); /* Don't care about Statistic */
      AD5940_DSPCfgS(&dsp_cfg);
      
      sw_cfg.Dswitch = 0;
      sw_cfg.Pswitch = 0;
      sw_cfg.Nswitch = 0;
      sw_cfg.Tswitch = 0; 
      AD5940_SWMatrixCfgS(&sw_cfg);
        
      /* Enable all of them. They are automatically turned off during hibernate mode to save power */
      AD5940_AFECtrlS(AFECTRL_HPREFPWR|AFECTRL_SINC2NOTCH, bTRUE);
      AD5940_AFECtrlS(AFECTRL_SINC2NOTCH, bFALSE);
      return AD5940ERR_OK;
    }
    
    static AD5940Err AppAMPMeasure_(void)
    {
      AD5940Err error = AD5940ERR_OK;
    
      uint32_t WaitClks;
      uint32_t timeout, afeResult, cgmVoltageValue, cgmCurrentValue, reVoltage, seVoltage;
      uint32_t AD5940_FLAG_TIMEOUT = 1000000000;
      uint32_t CURRENT_NANO_FACTOR = 0.000000001;
      
      ClksCalInfo_Type clks_cal;
      
      clks_cal.DataType = DATATYPE_SINC2;
      clks_cal.DataCount = 1;
      clks_cal.ADCSinc2Osr = AppAMPCfg.ADCSinc2Osr;
      clks_cal.ADCSinc3Osr = AppAMPCfg.ADCSinc3Osr;
      clks_cal.ADCAvgNum = 0;
      clks_cal.RatioSys2AdcClk = AppAMPCfg.SysClkFreq/AppAMPCfg.AdcClkFreq;
      AD5940_ClksCalculate(&clks_cal, &WaitClks);
    	WaitClks += 15;
    	
    	/*Measure VRE*/
    	AD5940_ADCMuxCfgS(ADCMUXP_VRE0, ADCMUXN_VZERO0);      
      AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
      AD5940_Delay10us(16*25); 
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);   /* Start ADC convert*/
      AD5940_Delay10us(WaitClks); 
       timeout = 0;
        while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) {
            AD5940_Delay10us(1);
            if (++timeout > AD5940_FLAG_TIMEOUT) {
                AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
                AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
                return bFALSE;
            }
        }
        
        AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
        afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
        AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
          
        reVoltage = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1P5, 1.82)*1000.0f;
    	
    	/*Measure VSE*/
    	AD5940_ADCMuxCfgS(ADCMUXP_VSE0, ADCMUXN_VZERO0);      
      AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
      AD5940_Delay10us(16*25); 
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);   /* Start ADC convert*/
      AD5940_Delay10us(WaitClks); 
       timeout = 0;
        while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) {
            AD5940_Delay10us(1);
            if (++timeout > AD5940_FLAG_TIMEOUT) {
                AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
                AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
                return bFALSE;
            }
        }
        
        AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
        afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
        AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
          
        seVoltage = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1P5, 1.82)*1000.0f;
    
    	
    	/*Measure current */
      AD5940_ADCMuxCfgS(ADCMUXP_AIN4, ADCMUXN_VZERO0);      
      AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_SINC2NOTCH, bTRUE);
      AD5940_Delay10us(16*25); 
      AD5940_AFECtrlS(AFECTRL_ADCCNV, bTRUE);   /* Start ADC convert*/
      AD5940_Delay10us(WaitClks); 
       timeout = 0;
        while (!(AD5940_INTCTestFlag(AFEINTC_1, AFEINTSRC_SINC2RDY))) {
            AD5940_Delay10us(1);
            if (++timeout > AD5940_FLAG_TIMEOUT) {
                AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
                AD5940_AFECtrlS(AFECTRL_ADCPWR | AFECTRL_ADCCNV | AFECTRL_SINC2NOTCH, bFALSE);
                return bFALSE;
            }
        }
        
        AD5940_INTCClrFlag(AFEINTSRC_SINC2RDY);
        afeResult = AD5940_ReadAfeResult(AFERESULT_SINC2);
        AD5940_AFECtrlS(AFECTRL_ADCPWR|AFECTRL_ADCCNV|AFECTRL_SINC2NOTCH, bFALSE);  /* Stop ADC */
        cgmVoltageValue = AD5940_ADCCode2Volt(afeResult&0xffff, ADCPGA_1, 1.82);
        cgmCurrentValue = CURRENT_NANO_FACTOR * (cgmVoltageValue / AppAMPCfg.RtiaCalValue.Magnitude);
    
        printf("\n Current : %d uA, Voltage: %d mV\n", cgmCurrentValue, (reVoltage - seVoltage));
    
      AD5940_EnterSleepS();/* Goto hibernate */
    
      return AD5940ERR_OK;
    }
    static AD5940Err AppAMPRtiaCal(void)
    {
    fImpPol_Type RtiaCalValue;  /* Calibration result */
      LPRTIACal_Type lprtia_cal;
      AD5940_StructInit(&lprtia_cal, sizeof(lprtia_cal));
    
      lprtia_cal.bPolarResult = bTRUE;                /* Magnitude + Phase */
      lprtia_cal.AdcClkFreq = AppAMPCfg.AdcClkFreq;
      lprtia_cal.SysClkFreq = AppAMPCfg.SysClkFreq;
      lprtia_cal.ADCSinc3Osr = ADCSINC3OSR_4;
      lprtia_cal.ADCSinc2Osr = ADCSINC2OSR_22;        /* Use SINC2 data as DFT data source */
      lprtia_cal.DftCfg.DftNum = DFTNUM_2048;         /* Maximum DFT number */
      lprtia_cal.DftCfg.DftSrc = DFTSRC_SINC2NOTCH;   /* For frequency under 12Hz, need to optimize DFT source. Use SINC3 data as DFT source */
      lprtia_cal.DftCfg.HanWinEn = bTRUE;
      lprtia_cal.fFreq = AppAMPCfg.AdcClkFreq/4/22/2048*3;  /* Sample 3 period of signal, 13.317Hz here. Do not use DC method, because it needs ADC/PGA calibrated firstly(but it's faster) */
      lprtia_cal.fRcal = AppAMPCfg.RcalVal;
      lprtia_cal.LpTiaRtia = AppAMPCfg.LptiaRtiaSel;
      lprtia_cal.LpAmpPwrMod = LPAMPPWR_NORM;
      lprtia_cal.bWithCtia = bFALSE;
      AD5940_LPRtiaCal(&lprtia_cal, &RtiaCalValue);
      AppAMPCfg.RtiaCalValue = RtiaCalValue;
     
      return AD5940ERR_OK;
    }
    
    /* Initialize AD5940 basic blocks like clock */
    static int32_t AD5940PlatformCfg(void)
    {
      CLKCfg_Type clk_cfg;
      FIFOCfg_Type fifo_cfg;
    	SEQCfg_Type seq_cfg;
      AGPIOCfg_Type gpio_cfg;
    	LFOSCMeasure_Type LfoscMeasure;
      /* Use hardware reset */
      AD5940_HWReset();
      /* Platform configuration */
      AD5940_Initialize();
      /* Step1. Configure clock */
      clk_cfg.HFOSCEn = bTRUE;
      clk_cfg.HFXTALEn = bFALSE;
      clk_cfg.LFOSCEn = bTRUE;
      clk_cfg.HfOSC32MHzMode = bFALSE;
      clk_cfg.SysClkSrc = SYSCLKSRC_HFOSC;
      clk_cfg.SysClkDiv = SYSCLKDIV_1;
      clk_cfg.ADCCLkSrc = ADCCLKSRC_HFOSC;
      clk_cfg.ADCClkDiv = ADCCLKDIV_1;
      AD5940_CLKCfg(&clk_cfg);
      /* Step2. Configure FIFO and Sequencer*/
      fifo_cfg.FIFOEn = bFALSE;
      fifo_cfg.FIFOMode = FIFOMODE_FIFO;
      fifo_cfg.FIFOSize = FIFOSIZE_4KB;                      /* 4kB for FIFO, The reset 2kB for sequencer */
      fifo_cfg.FIFOSrc = FIFOSRC_DFT;
      fifo_cfg.FIFOThresh = 4;      
      AD5940_FIFOCfg(&fifo_cfg);                             /* Disable to reset FIFO. */
    	fifo_cfg.FIFOEn = bTRUE;  
      AD5940_FIFOCfg(&fifo_cfg);                             /* Enable FIFO here */
    	
      /* Step3. Interrupt controller */
      AD5940_INTCCfg(AFEINTC_1, AFEINTSRC_ALLINT, bTRUE);           /* Enable all interrupt in Interrupt Controller 1, so we can check INTC flags */
      AD5940_INTCCfg(AFEINTC_0, AFEINTSRC_DATAFIFOTHRESH, bTRUE);   /* Interrupt Controller 0 will control GP0 to generate interrupt to MCU */
      AD5940_INTCClrFlag(AFEINTSRC_ALLINT);
      /* Step4: Reconfigure GPIO */
      gpio_cfg.FuncSet = GP6_SYNC|GP5_SYNC|GP4_SYNC|GP2_SYNC|GP1_SLEEP|GP0_INT;
      gpio_cfg.InputEnSet = 0;
      gpio_cfg.OutputEnSet = AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin2;
      gpio_cfg.OutVal = 0;
      gpio_cfg.PullEnSet = 0;
      AD5940_AGPIOCfg(&gpio_cfg);
    	
      AD5940_SleepKeyCtrlS(SLPKEY_UNLOCK);  /* Allow AFE to enter sleep mode. */
      /* Measure LFOSC frequency */
      LfoscMeasure.CalDuration = 1000.0;  /* 1000ms used for calibration. */
      LfoscMeasure.CalSeqAddr = 0;
      LfoscMeasure.SystemClkFreq = 16000000.0f; /* 16MHz in this firmware. */
      AD5940_LFOSCMeasure(&LfoscMeasure, &LFOSCFreq);
      printf("Freq:%f\n", LFOSCFreq); 
      return 0;
    }
    
    
    void AD5940_Main(void)
    {
     
      AD5940PlatformCfg();
      AD5940AMPStructInit(); /* Configure your parameters in this function */ 
      while(1)
      {
              if(AD5940_WakeUp(10) > 10)  /* Wakeup AFE by read register, read 10 times at most */
              {
                printf("\n Not waking up \n");
              break;
              }
              AppAMPCfg_();
              AppAMPMeasure_();
      }
      
    }
    

    Ramp excitation LPDAC configuration (from Github) must be added to the above code.