Post Go back to editing

Which GPIO I can use and how do I do it? EVAL-AD5940 BIOZ

I would like to use the BIA code for a specific reason. After each print of the IMPEDANCE, I would like to send a "high voltage" / data to an Arduino device to let it know that it completed one BIA.
Is it possible to do so? which GPIO can I use and how?

Thanks.


Edit: another option is to send a "high voltage" / data from the Arduino to the EVAL. When EVAL receives it, it will stop recording until another data is coming.



.
[edited by: DannyM at 1:25 PM (GMT -4) on 18 Oct 2021]
  • Hi,

    We will look into this, I'll contact the product owner and get back to you.

    Regards,

    Andrei

  • Hi,

    You may modify AD5940Main.c as below:

    /*!
    *****************************************************************************
    @file: AD5940Main.c
    @author: Neo Xu
    @brief: Used to control specific application and process data.
    -----------------------------------------------------------------------------

    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.

    *****************************************************************************/
    /**
    * @addtogroup AD5940_System_Examples
    * @{
    * @defgroup BioElec_Example
    * @{
    */
    #include "ad5940.h"
    #include "AD5940.h"
    #include <stdio.h>
    #include "string.h"
    #include "math.h"
    #include "BodyImpedance.h"

    #define APPBUFF_SIZE 512
    uint32_t AppBuff[APPBUFF_SIZE];

    /* It's your choice here how to do with the data. Here is just an example to print them to UART */
    int32_t BIAShowResult(uint32_t *pData, uint32_t DataCount)
    {
    float freq;

    fImpPol_Type *pImp = (fImpPol_Type*)pData;
    AppBIACtrl(BIACTRL_GETFREQ, &freq);

    printf("Freq:%.2f ", freq);
    /*Process data*/
    for(int i=0;i<DataCount;i++)
    {
    printf("RzMag: %f Ohm , RzPhase: %f \n",pImp[i].Magnitude,pImp[i].Phase*180/MATH_PI);
    }
    return 0;
    }

    /* Initialize AD5940 basic blocks like clock */
    static int32_t AD5940PlatformCfg(void)
    {
    CLKCfg_Type clk_cfg;
    FIFOCfg_Type fifo_cfg;
    AGPIOCfg_Type gpio_cfg;

    /* Use hardware reset */
    AD5940_HWReset();
    /* Platform configuration */
    AD5940_Initialize();
    /* Step1. Configure clock */
    clk_cfg.ADCClkDiv = ADCCLKDIV_1;
    clk_cfg.ADCCLkSrc = ADCCLKSRC_HFOSC;
    clk_cfg.SysClkDiv = SYSCLKDIV_1;
    clk_cfg.SysClkSrc = SYSCLKSRC_HFOSC;
    clk_cfg.HfOSC32MHzMode = bFALSE;
    clk_cfg.HFOSCEn = bTRUE;
    clk_cfg.HFXTALEn = bFALSE;
    clk_cfg.LFOSCEn = bTRUE;
    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;//AppBIACfg.FifoThresh; /* DFT result. One pair for RCAL, another for Rz. One DFT result have real part and imaginary part */
    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_TRIG|GP1_SYNC|GP0_INT;
    gpio_cfg.InputEnSet = AGPIO_Pin2;
    gpio_cfg.OutputEnSet = AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6;
    gpio_cfg.OutVal = 0;
    gpio_cfg.PullEnSet = 0;

    AD5940_AGPIOCfg(&gpio_cfg);
    AD5940_SleepKeyCtrlS(SLPKEY_UNLOCK); /* Allow AFE to enter sleep mode. */
    return 0;
    }

    /* !!Change the application parameters here if you want to change it to none-default value */
    void AD5940BIAStructInit(void)
    {
    AppBIACfg_Type *pBIACfg;

    AppBIAGetCfg(&pBIACfg);

    pBIACfg->SeqStartAddr = 0;
    pBIACfg->MaxSeqLen = 512; /** @todo add checker in function */

    pBIACfg->RcalVal = 10000.0;
    pBIACfg->DftNum = DFTNUM_8192;
    pBIACfg->NumOfData = -1; /* Never stop until you stop it manually by AppBIACtrl() function */
    pBIACfg->BiaODR = 20; /* ODR(Sample Rate) 20Hz */
    pBIACfg->FifoThresh = 4; /* 4 */
    pBIACfg->ADCSinc3Osr = ADCSINC3OSR_2;
    }

    void AD5940_Main(void)
    {
    static uint32_t IntCount;
    static uint32_t count;
    uint32_t temp;
    AGPIOCfg_Type GPIO_X;

    GPIO_X.FuncSet = AGP0;
    GPIO_X.OutputEnSet = AGPIO_Pin6; //P0.6
    GPIO_X.InputEnSet = AGPIO_Pin7; //P0.7
    GPIO_X.PullEnSet = 0;
    GPIO_X.OutVal = 0;


    AD5940PlatformCfg();

    AD5940BIAStructInit(); /* Configure your parameters in this function */

    AppBIAInit(AppBuff, APPBUFF_SIZE); /* Initialize BIA application. Provide a buffer, which is used to store sequencer commands */
    AppBIACtrl(BIACTRL_START, 0); /* Control BIA measurement to start. Second parameter has no meaning with this command. */
    AD5940_AGPIOCfg(GPIO_X);
    while(1)
    {
    if(AD5940_AGPIOIn() == 0x80) //Checking P0.7
    {
    /* Check if interrupt flag which will be set when interrupt occurred. */
    if(AD5940_GetMCUIntFlag())
    {
    IntCount++;
    AD5940_ClrMCUIntFlag(); /* Clear this flag */
    temp = APPBUFF_SIZE;
    AppBIAISR(AppBuff, &temp); /* Deal with it and provide a buffer to store data we got */
    BIAShowResult(AppBuff, temp); /* Show the results to UART */

    AD5940_AGPIOSet(AGPIO_Pin2); //P0.6 is set high

    if(IntCount == 240)
    {
    IntCount = 0;
    //AppBIACtrl(BIACTRL_SHUTDOWN, 0);
    }
    }
    count++;
    if(count > 1000000)
    {
    count = 0;
    //AppBIAInit(0, 0); /* Re-initialize BIA application. Because sequences are ready, no need to provide a buffer, which is used to store sequencer commands */
    //AppBIACtrl(BIACTRL_START, 0); /* Control BIA measurement to start. Second parameter has no meaning with this command. */
    }
    }
    }
    }

    /**
    * @}
    * @}
    * */

  • Hi,

    Thank you so much for your answer. However, I do get two errors (shown on the picture):

    Error[Pe020]: identifier "AGP0" is undefined C:\ad5940-examples-master\examples\AD5940_BIA\AD5940Main.c 121
    Error[Pe167]: argument of type "AGPIOCfg_Type" is incompatible with parameter of type "AGPIOCfg_Type *" C:\ad5940-examples-master\examples\AD5940_BIA\AD5940Main.c 134


    1.How do I fix it?
    2.If I understand correctly, when AGPIO_Pin7; //P0.7 receives the byte (0x80) the "if" statement happens and then after AGPIO_Pin6; //P0.6 sets high voltage for a moment and then goes off / low voltage thus over and over again, correct?
    3.Which pins are these over the board? I'm not sure.



  • Set

     GPIO_X.FuncSet = GP6_GPIO|GP7_GPIO;

     AD5940_AGPIOCfg(&GPIO_X);

    Refer to GP6 and GP7 on the board.

  • Hey,

    One last thing. Sadly I found out my device doesn't send bytes (like byte (0x80)). It will work if I would send this as binary word which composed with 1's and 0's and send it through one of Arduino's GPIO (Serial data).

    What do I need to change here:
    if(AD5940_AGPIOIn() == 0x80


  • Hey,

    One last thing. Sadly I found out my device doesn't send bytes (like byte (0x80)). It will work if I would send this as binary word which composed with 1's and 0's and send it through one of Arduino's GPIO (Serial data).

    What do I need to change here:
    if(AD5940_AGPIOIn() == 0x80

  • In this case you have to implement the handshake through I2C or SPI.

  • Basically I want to send a flag to the EVAL-AD5940BIOZ from an Arduino for one BIA, and when the value of BIA is sent, I want the Arduino to get a flag back from the EVAL-AD5940BIOZ.

    How do you think I can implement it?

  • Is there no GPIO pin on the Arduino ?