/*! ***************************************************************************** @file: AD5940Main.c @author: Neo Xu @brief: Electrochemical impedance spectroscopy based on example AD5940_Impedance This project is optomized for 3-lead electrochemical sensors that typically have an impedance <200ohm. For optimum performance RCAL should be close to impedance of the sensor. ----------------------------------------------------------------------------- Copyright (c) 2017-2019 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement. *****************************************************************************/ #include "Impedance.h" #define APPBUFF_SIZE 512 uint32_t AppBuff[APPBUFF_SIZE]; int32_t ImpedanceShowResult(uint32_t *pData, uint32_t DataCount) { float freq; fImpPol_Type *pImp = (fImpPol_Type*)pData; AppIMPCtrl(IMPCTRL_GETFREQ, &freq); printf("Freq:%.2f ", freq); /*Process data*/ for(int i=0;iSeqStartAddr = 0; pImpedanceCfg->MaxSeqLen = 512; /* @todo add checker in function */ pImpedanceCfg->RcalVal = 200.0; pImpedanceCfg->FifoThresh = 6; pImpedanceCfg->SinFreq = 1000.0; /* Configure Excitation Waveform * * Output waveform = DacVoltPP * ExcitBufGain * HsDacGain * * = 300 * 0.25 * 0.2 = 15mV pk-pk * */ pImpedanceCfg->DacVoltPP = 300; /* Maximum value is 600mV*/ pImpedanceCfg->ExcitBufGain = EXCITBUFGAIN_0P25; pImpedanceCfg->HsDacGain = HSDACGAIN_0P2; /* Set switch matrix to onboard(EVAL-AD5940ELECZ) gas sensor. */ pImpedanceCfg->DswitchSel = SWD_CE0; pImpedanceCfg->PswitchSel = SWP_RE0; pImpedanceCfg->NswitchSel = SWN_SE0LOAD; pImpedanceCfg->TswitchSel = SWT_SE0LOAD; /* The dummy sensor is as low as 5kOhm. We need to make sure RTIA is small enough that HSTIA won't be saturated. */ pImpedanceCfg->HstiaRtiaSel = HSTIARTIA_200; pImpedanceCfg->BiasVolt = 0.0; /* Configure the sweep function. */ pImpedanceCfg->SweepCfg.SweepEn = bFALSE; pImpedanceCfg->SweepCfg.SweepStart = 100.0f; /* Start from 1kHz */ pImpedanceCfg->SweepCfg.SweepStop = 100e3f; /* Stop at 100kHz */ pImpedanceCfg->SweepCfg.SweepPoints = 101; /* Points is 101 */ pImpedanceCfg->SweepCfg.SweepLog = bTRUE; /* Configure Power Mode. Use HP mode if frequency is higher than 80kHz. */ pImpedanceCfg->PwrMod = AFEPWR_LP; /* Configure filters if necessary */ pImpedanceCfg->ADCSinc3Osr = ADCSINC3OSR_4; /* Sample rate is 800kSPS/2 = 400kSPS */ pImpedanceCfg->DftNum = DFTNUM_16384; pImpedanceCfg->DftSrc = DFTSRC_SINC3; } void AD5940_Main(void) { uint32_t temp; AD5940PlatformCfg(); AD5940ImpedanceStructInit(); AppIMPInit(AppBuff, APPBUFF_SIZE); /* Initialize IMP application. Provide a buffer, which is used to store sequencer commands */ AppIMPCtrl(IMPCTRL_START, 0); /* Control IMP measurement to start. Second parameter has no meaning with this command. */ while(1) { if(AD5940_GetMCUIntFlag()) { AD5940_ClrMCUIntFlag(); temp = APPBUFF_SIZE; AppIMPISR(AppBuff, &temp); ImpedanceShowResult(AppBuff, temp); } } }