/*! ***************************************************************************** @file: AD5940Main.c @author: $Author: nxu2 $ @brief: Used to control specific application and process data. @version: $Revision: 766 $ @date: $Date: 2017-08-21 14:09:35 +0100 (Mon, 21 Aug 2017) $ ----------------------------------------------------------------------------- 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 "SqrWaveVoltammetry.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 = 512-0x10; /* 4kB/4 = 1024 */ pRampCfg->RcalVal = 10000.0; /* 10kOhm RCAL */ pRampCfg->ADCRefVolt = 1.820f; /* The real ADC reference voltage. Measure it from capacitor C12 with DMM. */ pRampCfg->FifoThresh = 1023; /* 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 */ pRampCfg->AdcPgaGain = ADCPGA_1P5; pRampCfg->ADCSinc3Osr = ADCSINC3OSR_4; /* Step 2:Configure square wave signal parameters */ pRampCfg->RampStartVolt = -400.0f; /* Measurement starts at 0V*/ pRampCfg->RampPeakVolt = 0.0f; /* Measurement finishes at -0.4V */ pRampCfg->VzeroStart = 1300.0f; /* Vzero is voltage on SE0 pin: 1.3V */ pRampCfg->VzeroPeak = 1300.0f; /* Vzero is voltage on SE0 pin: 1.3V */ pRampCfg->Frequency = 750; /* Frequency of square wave in Hz */ pRampCfg->SqrWvAmplitude = 150; /* Amplitude of square wave in mV */ pRampCfg->SqrWvRampIncrement = 5; /* Increment in mV*/ pRampCfg->SampleDelay = 0.2f; /* Time between update DAC and ADC sample. Unit is ms and must be < (1/Frequency)/2 - 0.2*/ pRampCfg->LPTIARtiaSel = LPTIARTIA_1K; /* Maximum current decides RTIA value */ pRampCfg->bRampOneDir = bFALSE;//bTRUE; /* Only measure ramp in one direction */ } void AD5940_Main(void) { uint32_t temp; AD5940PlatformCfg(); AD5940RampStructInit(); //AD5940_McuSetLow(); AppSWVInit(AppBuff, APPBUFF_SIZE); /* Initialize RAMP application. Provide a buffer, which is used to store sequencer commands */ AD5940_Delay10us(100000); /* Add a delay to allow sensor reach equilibrium befor starting the measurement */ AppSWVCtrl(APPCTRL_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; AppSWVISR(AppBuff, &temp); RampShowResult((float*)AppBuff, temp); } } }