/*! ***************************************************************************** @file: AD5940Main.c @author: Neo Xu @brief: Example of ramp test for electro-chemical 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 "RampTest.h" /** User could configure following parameters **/ #define APPBUFF_SIZE 1024 uint32_t AppBuff[APPBUFF_SIZE]; float LFOSCFreq; /* Measured LFOSC frequency */ /** * @brief An example to deal with data read back from AD5940. Here we just print data to UART * @note UART has limited speed, it has impact when sample rate is fast. Try to print some of the data not all of them. * @param pData: the buffer stored data for this application. The data from FIFO has been pre-processed. * @param DataCount: The available data count in buffer pData. * @return return 0. */ static int32_t RampShowResult(float *pData, uint32_t DataCount) { static uint32_t index; /* Print data*/ for(int i=0;iSeqStartAddr = 0x10; /* leave 16 commands for LFOSC calibration. */ pRampCfg->MaxSeqLen = 1024-0x10; /* 4kB/4 = 1024 */ pRampCfg->RcalVal = 10000.0; /* 10kOhm RCAL */ pRampCfg->ADCRefVolt = 1820.0f; /* The real ADC reference voltage. Measure it from capacitor C12 with DMM. */ pRampCfg->FifoThresh = 480; /* Maximum value is 2kB/4-1 = 512-1. Set it to higher value to save power. */ pRampCfg->SysClkFreq = 16000000.0f; /* System clock is 16MHz by default */ pRampCfg->LFOSCClkFreq = LFOSCFreq; /* LFOSC frequency */ /* Configure ramp signal parameters */ pRampCfg->RampStartVolt = -1000.0f; /* -1V */ pRampCfg->RampPeakVolt = +1000.0f; /* +1V */ pRampCfg->VzeroStart = 1300.0f; /* 1.3V */ pRampCfg->VzeroPeak = 1300.0f; /* 1.3V */ pRampCfg->StepNumber = 800; /* Total steps. Equals to ADC sample number */ pRampCfg->RampDuration = 24*1000; /* X * 1000, where x is total duration of ramp signal. Unit is ms. */ pRampCfg->SampleDelay = 7.0f; /* 7ms. Time between update DAC and ADC sample. Unit is ms. */ pRampCfg->LPTIARtiaSel = LPTIARTIA_4K; /* Maximum current decides RTIA value */ pRampCfg->LPTIARloadSel = LPTIARLOAD_SHORT; pRampCfg->AdcPgaGain = ADCPGA_1P5; } void AD5940_Main(void) { uint32_t temp; AppRAMPCfg_Type *pRampCfg; AD5940PlatformCfg(); AD5940RampStructInit(); AppRAMPInit(AppBuff, APPBUFF_SIZE); /* Initialize RAMP application. Provide a buffer, which is used to store sequencer commands */ AppRAMPCtrl(APPCTRL_START, 0); /* Control IMP measurement to start. Second parameter has no meaning with this command. */ while(1) { AppRAMPGetCfg(&pRampCfg); if(AD5940_GetMCUIntFlag()) { AD5940_ClrMCUIntFlag(); temp = APPBUFF_SIZE; AppRAMPISR(AppBuff, &temp); RampShowResult((float*)AppBuff, temp); } /* Repeat Measurement continuously*/ if(pRampCfg->bTestFinished ==bTRUE) { AD5940_Delay10us(200000); pRampCfg->bTestFinished = bFALSE; AD5940_SEQCtrlS(bTRUE); /* Enable sequencer, and wait for trigger */ AppRAMPCtrl(APPCTRL_START, 0); } } }