This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AFE4300 BCM Configuration (AVDD increased to about 4.5V)

Other Parts Discussed in Thread: AFE4300

Hi,

I'm quite a newbie, and trying to configure my AFE4300 into a BCM setting.

I don't need the weight measurement at all, and use only one set of the tetra-pole electrodes.

My problem is that 3.3V AVDD got increased to about 4.5V after connection. I must have gotten some connections wrong or missed some.

Can I leave unused pins for electrodes floated (Pins 22-25, 28-31, 33-36, 39-40)? Or should I keep them grounded?

How about pins related to instrumentation amps and IQ demodulators (Pins 2-5, 10-13, 47-50)? I left them NC as I am not using them either. Should I make them grounded even if I am not using them?

Thanks,

JY

  • I would not leave the pins floating because there could be some impedance on the lines. I would ground it if they're not used. This should be a quick test. Let me know if this does not solve your issue.

  • It turned out that it is because I used an arduino that runs in 5V, not 3.3V. This seems to flow 5V into SPI pins and somehow caused increase in voltage from 3.3V to 4.5V. With the change of the arduino to a different model with 3.3V operating voltage, I got it solved.

    I actually have another question. I was successfully able to communicate with AFE4300 from my arduino chip through SPI, except one register (0x00). There was no problem in reading and writing from/to any other register addresses. I think my electrode connections are okay, but I don't know why I only get 0 from the register 0x00 (ADC_DATA_RESULT). Any clue?

    Thanks much.

  • Hello Jinyong,

    What are your AFE register settings?

    Please refer to the datasheet for the register bits that need to be set after reset.

    Do you have an AFE4300EVM? Have you verified if your electrode setup works with the AFE4300 EVM and the GUI?

    Best regards

    Praveen.

  • Hi Guys,


    I am trying to achieve the sma thing here, i have AFE4300 evm, i would to power it from Arduino and make a SPI connection?
  • Hi, I am doing a project for BCM, even with it not communicate with my arduino AFE4300, you know how I can do? thanks
  • #include <SPI.h>
    //#include "pins_arduino.h"
    const int slaveSelectPin = 10;
    void setup() {
    SPI.begin();
    Serial.begin(9600);
    pinMode (slaveSelectPin, OUTPUT);
    SPI.setClockDivider(SPI_CLOCK_DIV16);

    }

    void loop() {
    digitalWrite (slaveSelectPin, LOW);
    //REGISTRO [23,16] 0 0 0 0 0 0 0 1
    //DATA MSB [15,8] 0 1 0 0 0 0 0 1
    //DATA LSB [7,0] 0 1 0 0 0 0 0 0
    //Apuntamos al registro 01
    SPI.transfer (0x03); //ponemos el bit 21 a '0' para escribir datos
    SPI.transfer (0xFF); //escribimos DATA el MSB [15...8]
    SPI.transfer (0xFF); //escribimos DATA el LSB [7...0]
    digitalWrite (slaveSelectPin, HIGH);
    delay(10);
    //digitalWrite (slaveSelectPin, LOW);
    //REGISTRO [23,16] 0 0 1 0 0 0 0 1
    //SPI.transfer (0x21); //ponemos al bit 21 a '1' para leer lo que hay en el registro
    //byte MSB = SPI.transfer(0x00);
    //byte LSB = SPI.transfer(0x00);
    //Serial.print(MSB, LSB);
    //digitalWrite (slaveSelectPin, HIGH);
    SPI.end ();
    }
  • #include <SPI.h>
    //#include "pins_arduino.h"
    const int slaveSelectPin = 10;
    void setup() {
    SPI.begin();
    Serial.begin(9600);
    pinMode (slaveSelectPin, OUTPUT);
    SPI.setClockDivider(SPI_CLOCK_DIV16);

    }

    void loop() {
    digitalWrite (slaveSelectPin, LOW);
    //REGISTRO [23,16] 0 0 0 0 0 0 0 1
    //DATA MSB [15,8] 0 1 0 0 0 0 0 1
    //DATA LSB [7,0] 0 1 0 0 0 0 0 0
    //Apuntamos al registro 01
    SPI.transfer (0x01); //ponemos el bit 21 a '0' para escribir datos
    SPI.transfer (0x41); //escribimos DATA el MSB [15...8]
    SPI.transfer (0x40); //escribimos DATA el LSB [7...0]
    digitalWrite (slaveSelectPin, HIGH);
    delay(10);
    digitalWrite (slaveSelectPin, LOW);
    //LECTURA DE REGISTRO
    //REGISTRO [23,16] 0 0 1 0 0 0 0 1
    SPI.transfer (0x21); //ponemos al bit 21 a '1' para leer lo que hay en el registro
    byte MSB = SPI.transfer(0x00);
    byte LSB = SPI.transfer(0x00);
    Serial.print(MSB, LSB);
    digitalWrite (slaveSelectPin, HIGH);
    SPI.end ();
    }
  • Hi guys,

    I too trying to make the AFE4300 to work with ardiuno due , I connected the EVM breakout board to due . but no luck the AFE not responding at all and RDY is high always - pragadhees

    my code as below


    #include <SPI.h>

    // pins

    #define PIN_RESET 6
    #define PIN_DRDY 2
    #define PIN_LED 13
    #define PIN_CS 9

    #define SlaveSelectPIn 4

    void resetAFE4300();


    void writeRegister(unsigned char address, unsigned int data); //Writes to a register on the AFE4300

    int readRegister(unsigned char address); //Reads from a register on the AFE4300

    void initAFE4300(); //intialize AFE

    void initWeighScale(); // Initializes the Weigh Scale Module

    void initBCM(); // Initializes the BCM Module


    void initFW(); // Initializes the BCM Module for FW mode


    void initBCMMeasure(); //Initializes the BCM Module for measuring user resistance


    void initBCMCalibrate1(); //Initializes the BCM Module for 100 ohm reference calibration


    void initBCMCalibrate2(); //Initializes the BCM Module for 1000 ohm reference calibration


    void initDevice(); //Initializes the device


    void setupBCM();


    int readData(); // Reads the ADC data register


    void setIdle(); // Set the state machine to IDLE state


    void setOffsetMeas(); //state machine to Offset measurement state


    void setMeasBCM(); //Set the state machine to Measure BCM state


    void setMeasWeight(); //Set the state machine to Measure Weight state


    void setCalWeight(); // Set the state machine to Calibrate Weight state

    void setDisconnect(); // Set the state machine to Disconnect state


    bool checkMeasWeightStatus(); //Check if device is in Measure Weight state


    bool checkCalWeightStatus(); //Check if device is in Calibrate Weight state

    void toggleChipSelect();

    //Flags for ISR interrupts
    extern unsigned char drdyFlag;
    extern unsigned char measBCMFlag;
    extern unsigned char offsetFlag;
    extern unsigned char measWeightFlag;
    extern unsigned char calWeightFlag;
    extern unsigned char calBCMFlag;
    extern unsigned char disconnectFlag;

    //Enum values for SPI state machine
    enum STATUS {IDLE,OFFSET_MEASUREMENT, CALIBRATE_WEIGHT1,CALIBRATE_WEIGHT2, MEASURE_WEIGHT, CALIBRATE_BCM, MEASURE_BCM, DISCONNECT};
    enum STATUS currentStatus = IDLE;

    int datain =0 ;

    /***************************
    AFE4300 register address definitions
    ****************************/

    #define ADC_DATA_RESULT   0x00
    #define ADC_CONTROL_REGISTER  0x01
    #define MISC1_REGISTER     0x02
    #define MISC2_REGISTER    0x03
    #define DEVICE_CONTROL_1 0x09
    #define ISW_MATRIX 0x0A
    #define VSW_MATRIX 0x0B
    #define IQ_MODE_ENABLE 0x0C
    #define WEIGHT_SCALE_CONTROL 0x0D
    #define BCM_DAC_FREQ 0x0E
    #define DEVICE_CONTROL_2 0x0F
    #define ADC_CONTROL_REGISTER_2 0x10
    #define MISC3_REGISTER 0x1A

    void setup()
    {


    pinMode(PIN_LED, OUTPUT);
    pinMode(PIN_RESET, OUTPUT);
    pinMode(PIN_DRDY, INPUT);
    pinMode (PIN_CS, OUTPUT);


    Serial.begin(115200);
    Serial.flush();

    SPI.begin(SlaveSelectPIn);
    SPI.setClockDivider(SlaveSelectPIn,84);


    resetAFE4300();

    initAFE4300();
    //
    delay(3000);
    //
    initWeighScale();




    }

    void loop()
    {


    int datainp= readRegister(0x00);
    //
    Serial.println(datainp);


    }


    /**
    * @brief Resets the AFE4300 device
    *
    * @param None
    *
    * @return None
    */
    void resetAFE4300()
    {

    digitalWrite(PIN_RESET ,LOW);
    delay(100);
    digitalWrite(PIN_RESET ,HIGH);

    }


    /**
    * @brief Writes to a register on the AFE4300
    *
    * @param address an unsigned character
    * @param data an unsigned integer
    *
    * @return None
    */
    void writeRegister(unsigned char address, unsigned int data)

    {
    unsigned char firstByte = (unsigned char)(data >> 8);
    unsigned char secondByte = (unsigned char)data;


    address = address & 0x1F; //Last 5 bits specify address, first 3 bits need to be 0 for write opcode


    // Specify address of register to be written to
    SPI.transfer(SlaveSelectPIn,address,SPI_CONTINUE);
    //Send 2 bytes to be written
    SPI.transfer(SlaveSelectPIn,firstByte,SPI_CONTINUE);
    SPI.transfer(SlaveSelectPIn,secondByte);

    // SPI.end(10);

    }

    /**
    * @brief Reads from a register on the AFE4300
    *
    * @param address an unsigned character
    *
    * @return None
    */
    int readRegister(unsigned char address)
    {

    int spiReceive = 0;
    unsigned char spiReceiveFirst = 0;
    unsigned char spiReceiveSecond = 0;

    address = address & 0x1F; //Last 5 bits specify address
    address = address | 0x20; //First 3 bits need to be 001 for read opcode


    //digitalWrite(slaveselectpin,LOW);
    SPI.transfer(SlaveSelectPIn,address,SPI_CONTINUE);
    spiReceiveFirst = SPI.transfer(SlaveSelectPIn,0x00,SPI_CONTINUE);
    spiReceiveSecond = SPI.transfer(SlaveSelectPIn,0x00);


    //Combine the two received bytes into a signed int
    spiReceive = (spiReceiveFirst << 8);
    spiReceive |= spiReceiveSecond;

    return spiReceive;


    }


    // toggle chipselect

    void toggleChipSelect()
    {
    //Pull CS high to block MISO
    digitalWrite(PIN_CS,HIGH);
    //delayMicroseconds(1);
    digitalWrite(PIN_CS,LOW);

    }


    /**
    * @brief Initializes the AFE4300 device
    *
    * @param None
    *
    * @return None
    */
    void initAFE4300()
    {
    writeRegister(ADC_CONTROL_REGISTER,0x5140);

    writeRegister(MISC1_REGISTER,0x0000);

    writeRegister(MISC2_REGISTER,0xFFFF);

    writeRegister(DEVICE_CONTROL_1,0x0004); //Power down both signal chains

    writeRegister(ISW_MATRIX,0x0000);

    writeRegister(VSW_MATRIX,0x0000);

    writeRegister(IQ_MODE_ENABLE,0x0000);

    writeRegister(WEIGHT_SCALE_CONTROL,0x0000);

    writeRegister(BCM_DAC_FREQ,0x0040);

    writeRegister(DEVICE_CONTROL_2,0x0000);

    writeRegister(ADC_CONTROL_REGISTER_2,0x0011);

    writeRegister(MISC3_REGISTER,0x00C0);

    }

    /**
    * @brief Initializes the Weigh Scale Module
    *
    * @param None
    *
    * @return None
    */
    void initWeighScale()
    {
    writeRegister(ADC_CONTROL_REGISTER,0x4120); //Differential measurement mode, 32 SPS

    writeRegister(DEVICE_CONTROL_1,0x0005); //Power up weigh scale signal chain

    writeRegister(ADC_CONTROL_REGISTER_2,0x0000); //ADC selects output of weigh scale


    writeRegister(WEIGHT_SCALE_CONTROL,0x003F); //Gain = 1 DAC Offset = -1


    writeRegister(BCM_DAC_FREQ,0x0040); //Frequency = default


    writeRegister(IQ_MODE_ENABLE,0x0000); //Disable IQ mode


    writeRegister(ISW_MATRIX,0x0000); //Channels IOUTP1 and IOUTN0


    writeRegister(VSW_MATRIX,0x0000); //Channels VSENSEP1 and VSENSEN0


    }

    /**
    * @brief Initializes the BCM Module
    *
    * @param None
    *
    * @return None
    */
    void initBCM()
    {
    writeRegister(ADC_CONTROL_REGISTER,0x4120); //Differential measurement mode, 32 SPS

    writeRegister(DEVICE_CONTROL_1,0x0006); //Power up BCM signal chain

    writeRegister(ISW_MATRIX,0x0804); //Channels IOUTP1 and IOUTN0

    writeRegister(VSW_MATRIX,0x0804); //Channels VSENSEP1 and VSENSEN0

    writeRegister(ADC_CONTROL_REGISTER_2,0x0063); //ADC selects output of BCM-I output

    writeRegister(WEIGHT_SCALE_CONTROL,0x0000); //Gain = 1 DAC Offset = 0

    }

    /**
    * @brief Initializes the BCM Module for FW mode
    *
    * @param None
    *
    * @return None
    */
    void initFW()
    {
    writeRegister(BCM_DAC_FREQ,0x0032); //Frequency = 50Khz

    writeRegister(IQ_MODE_ENABLE,0x0000); //Disable IQ mode

    }

    /**
    * @brief Initializes the BCM Module for measuring user resistance
    *
    * @param None
    *
    * @return None
    */
    void initBCMMeasure()
    {

    writeRegister(ISW_MATRIX,0x0804); //Channels IOUTP1 and IOUTN0

    writeRegister(VSW_MATRIX,0x0804); //Channels VSENSEP1 and VSENSEN0

    }

    /**
    * @brief Initializes the BCM Module for 100 ohm reference calibration
    *
    * @param None
    *
    * @return None
    */
    void initBCMCalibrate1()
    {

    writeRegister(ISW_MATRIX,0x0101); //Reference resistors RP0 and RN0

    writeRegister(VSW_MATRIX,0x0101); //Reference resistors RP0 and RN0

    }

    /**
    * @brief Initializes the BCM Module for 1000 ohm reference calibration
    *
    * @param None
    *
    * @return None
    */
    void initBCMCalibrate2()
    {

    writeRegister(ISW_MATRIX,0x0202); //Reference resistors RP1 and RN1

    writeRegister(VSW_MATRIX,0x0202); //Reference resistors RP1 and RN1

    }


    /**
    * @brief Initializes the device
    *
    * @param None
    *
    * @return None
    */
    void initDevice()
    {


    digitalWrite(PIN_RESET ,HIGH);//RESET is pulled high


    resetAFE4300();

    //

    initAFE4300();


    }


    /**
    * @brief Sets up device to measure body composition
    *
    * @param None
    *
    * @return None
    */
    void setupBCM()
    {
    //Prepare to measure BCM
    initAFE4300();
    initBCM();


    currentStatus = MEASURE_BCM;

    }

    /**
    * @brief Reads the ADC data register
    *
    * @param None
    *
    * @return integer
    */
    int readData()
    {
    return readRegister(ADC_DATA_RESULT);
    }

    /**
    * @brief Set the state machine to IDLE state
    *
    * @param None
    *
    * @return None
    */
    void setIdle()
    {
    currentStatus = IDLE;
    }

    /**
    * @brief Set the state machine to Offset measurement state
    *
    * @param None
    *
    * @return None
    */
    void setOffsetMeas()
    {
    currentStatus = OFFSET_MEASUREMENT;
    }

    /**
    * @brief Set the state machine to Measure BCM state
    *
    * @param None
    *
    * @return None
    */
    void setMeasBCM()
    {
    currentStatus = MEASURE_BCM;
    }

    /**
    * @brief Set the state machine to Measure Weight state
    *
    * @param None
    *
    * @return None
    */
    void setMeasWeight()
    {
    currentStatus = MEASURE_WEIGHT;
    }

    /**
    * @brief Set the state machine to Calibrate Weight state
    *
    * @param None
    *
    * @return None
    */
    void setCalWeight()
    {
    currentStatus = CALIBRATE_WEIGHT1;
    }

    /**
    * @brief Set the state machine to Disconnect state
    *
    * @param None
    *
    * @return None
    */
    void setDisconnect()
    {
    currentStatus = DISCONNECT;
    }

    /**
    * @brief Check if device is in Measure Weight state
    *
    * @param None
    *
    * @return boolean
    */
    bool checkMeasWeightStatus()
    {
    if(currentStatus == MEASURE_WEIGHT) return true;

    return false;
    }

    /**
    * @brief Check if device is in Calibrate Weight state
    *
    * @param None
    *
    * @return boolean
    */
    bool checkCalWeightStatus()
    {
    if(currentStatus == CALIBRATE_WEIGHT1) return true;
    return false;
    }

     

  • Hi Guys,

    I managed to successfully interfaced, AFE4300 EVM to arduino by removing the Mbb3 board, and my code worked fine. Then i translated all that to a pcb, with Atmel chip and AFE4300, but for some reason i cannot communicate with AFE4300 chip..

    for reference i am attaching my schematic with this email.