/*! ***************************************************************************** @file: AD5940Main.c @author: Neo Xu @brief: Standard 4-wire or 2-wire impedance measurement example. ----------------------------------------------------------------------------- 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" /** User could configure following parameters **/ #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 = 10000.0; pImpedanceCfg->SinFreq = 60000.0; pImpedanceCfg->FifoThresh = 4; /* Set switch matrix to onboard(EVAL-AD5940ELECZ) dummy sensor. */ /* Note the RCAL0 resistor is 10kOhm. */ pImpedanceCfg->DswitchSel = SWD_CE0; pImpedanceCfg->PswitchSel = SWP_RE0; pImpedanceCfg->NswitchSel = SWN_SE0; 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_5K; /* Configure the sweep function. */ pImpedanceCfg->SweepCfg.SweepEn = bTRUE; pImpedanceCfg->SweepCfg.SweepStart = 1.0f; /* Start from 1kHz */ pImpedanceCfg->SweepCfg.SweepStop = 200e3f; /* 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_2; /* 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); } } }