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 measurement issue: ready Never low and other

Other Parts Discussed in Thread: MSP430F2234, AFE4300
Hello,
I am using an MSP430F2234 uC. I am trying to measure my on board 100R and 1k reference resisotr and a thirsd resisor using the code I have pasted in the end of my message.
The RDY signal is always constant and at VDD. I am performing both one shot and continuous measurements and I see no change at RDY.
Is there a way to set the gain of the recording amplifier for the impedance measurements?
By connecting a resistor t in series with the capacitor between pin 19 and 20, the resistor allows the control of the injected current, correct? What is the smallest current we can inject in the way?
What does ADC SPS change? How should one choose the setting for the ADC conversion rate? The signal being converted is DC, right?
Thank you.
Here is the code I am using, I have copied most from the code you supply.
#include <msp430.h>
static unsigned int ADCVal[6];            // holds 1st ADC result
static unsigned int idMux;
void initiSPI()
{
P3SEL |= BIT3 | BIT2 | BIT1;            // P3.1, P3.2, P3.3 as USCI_B0 option select
P3DIR |= 0x00;  // P3.0/UCB0STE (!CS) output direction
UCB0CTL0 |= UCMSB + UCMST + UCSYNC; // 3 pin synchronous SPI mode; Master Mode; MSB first; ClockPP == 00; 8-bit data shift
UCB0CTL1 |= UCSSEL_2;  // SMCLK source for SPI Module
UCB0BR0 = 0x04; // SPI Clock prescaler register #0   (SPI clock = 250 kHz for SMCLK = 1 MHz)
UCB0BR1 = 0x00; // SPI Clock prescaler register #1
UCB0CTL1 &= ~UCSWRST;  // Initialize USCI_B0 state machine
}
unsigned char spi_routine (unsigned char command)
{
unsigned char result;
// P3OUT &= ~0x01; // !CS low state
IFG2 &= ~UCB0RXIFG; // Clear SPI SDI Flag
UCB0TXBUF = command;      // Start SPI by sending command data
while (!(IFG2 & UCB0RXIFG)); // wait until the 8-bit data is shifted-out on P3.1/UCB0SIMO pin AND shifted-in on P3.2/UCB0SOMI pin
result = UCB0RXBUF; // read SDI register
// P3OUT |= 0x01; // !CS high state
return result;
}
/***************************
 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 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_routine (address);
  //Send 2 bytes to be written
  spi_routine (firstByte);
  spi_routine (secondByte);
}
/**
* @brief  Reads from a register on the AFE4300
*
* @param  address an unsigned character
*
* @return  None
*/
signed int readRegister(unsigned char address)
{
  signed int spiReceive = 0;
  signed int spiReceiveFirst = 0;
  signed int spiReceiveSecond = 0;
  address = address & 0x1F; //Last 5 bits specify address
  address = address | 0x20; //First 3 bits need to be 001 for read opcode
  //Specify address of register to be written to
  spi_routine (0x20);//address
  //Send 2 dummy bytes to read back
  spiReceiveFirst = spi_routine (0);
  spiReceiveSecond = spi_routine (0);
  //Combine the two received bytes into a signed int
  spiReceive = (spiReceiveFirst << 8);
  spiReceive |= spiReceiveSecond;
  return spiReceive;
}
void initAFE4300()
{
  writeRegister(ADC_CONTROL_REGISTER,0x01C3);
  writeRegister(MISC1_REGISTER,0x8000);
  writeRegister(MISC2_REGISTER,0x7FFF);
  writeRegister(DEVICE_CONTROL_1,0x0000); //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,0x0000);
  writeRegister(DEVICE_CONTROL_2,0x0000);
  writeRegister(ADC_CONTROL_REGISTER_2,0x0011);
  writeRegister(MISC3_REGISTER,0x0030);
}
/**
* @brief  Initializes the BCM Module
*
* @param  None
*
* @return  None
*/
void initBCM()
{
  writeRegister(ADC_CONTROL_REGISTER,0x4100); //Differential measurement mode, 32 SPS
  //writeRegister(ADC_CONTROL_REGISTER,0xC1A0); //Differential measurement mode, 32 SPS
  writeRegister(DEVICE_CONTROL_1,0x6006); //Power up BCM signal chain
  writeRegister(ISW_MATRIX,0x0000); //Channels IOUTP1 and IOUTN0
  writeRegister(VSW_MATRIX,0x0000); //Channels VSENSEP1 and VSENSEN0
  writeRegister(ADC_CONTROL_REGISTER_2,0x0063); //ADC selects output of BCM-I output
  writeRegister(BCM_DAC_FREQ,0x000F);//1kHz
  writeRegister(IQ_MODE_ENABLE,0x0000); //Disable IQ mode
  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
  //writeRegister(ADC_CONTROL_REGISTER,0xC1A0); //Differential measurement mode, 32 SPS
}
/**
* @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
  //writeRegister(ADC_CONTROL_REGISTER,0xC1A0); //Differential measurement mode, 32 SPS
}
/**
* @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
  //writeRegister(ADC_CONTROL_REGISTER,0xC1A0); //Differential measurement mode, 32 SPS
}
/**
* @brief  Reads the ADC data register
*
* @param  None
*
* @return  integer
*/
int readData()
{
  return readRegister(ADC_DATA_RESULT);
}
void startMeasure()
{
//writeRegister(ADC_CONTROL_REGISTER,0xC1A0); //Differential measurement mode, 32 SPS
}
void delay()
{
int j;
for(j=0; j<500; j++){}
}
void Test()
{
//writeRegister(MISC1_REGISTER,0x0707);
signed int i = 0;
//i = readRegister(MISC1_REGISTER);
initAFE4300();
initBCM();
initBCMCalibrate1();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate1();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate1();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate1();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate2();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate2();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate2();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMCalibrate2();
delay();
startMeasure();
delay();
i = readData();
delay();
initBCMMeasure();
delay();
startMeasure();
delay();
i = readData();
delay();
startMeasure();
delay();
i = readData();
delay();
startMeasure();
delay();
i = readData();
delay();
startMeasure();
delay();
i = readData();
delay();
//for(j=0; j<50; j++){}
//int i = readData();
}
int main(void)
{
volatile unsigned int i;
 initiSPI();
WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
//buffer
    OA0CTL0 = OAP_1 + OAPM_1 + OAADC1;                // "+" connected to OA0IO (default),
                                              // Slow slew rate,
                                              // Output connected to A1/OA0O
    OA0CTL1 = OAFC_2;                         // Unity gain buffer mode
  // LOW POWER Clock (1MHz)
  if (CALBC1_1MHZ==0xFF||CALDCO_1MHZ==0xFF)
  {
while(1);
  }
  //DCOCTL = 0;
  BCSCTL1 = CALBC1_1MHZ;
  DCOCTL = CALDCO_1MHZ;
  //Timers
  TACCR0 = 62500 - 1;  // a period of 62,500 cycles is 0 to 62,499.
  TACCTL0 = CCIE;      // Enable interrupts for CCR0.
  TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR;
  //Input ADC CH 6
  ADC10CTL1 = INCH_6;                       // input A1
  ADC10AE0 |= 0x47;                         // PA.6 ADC option select and A2
  //ref voltage 1.5V
  ADC10CTL0 = REFON + REFOUT + SREF_1; // ADC10ON, interrupt enabled
  // Multiplexer CONFIGURATION PINS
  P4DIR |= 0x1F; // set  P4.3 to output direction for AFE4300 RESET
  P4OUT = 0x00;
  //Enable 1MHz clock for AFE4300
  P1DIR |= 0x10;
  P1SEL |= 0x10;
  for(i=0; i<50; i++){}
//Reset
  P4OUT = 0x00;
    for(i=0; i<50; i++){}
    P4OUT = 0x08;
while(1){
Test();
}
  
}