Hi
We are using the AFE4300 in IQ mode, we are having a problem with the results we get and we will explain what we did to setup the device:
First of we are using 2 calibration resistors (500 and 100 ohms) the magnitude calibration is done properly with no issues, as for the phase we are taking the results of the I and Q of the 500 Ohms resistor, the reference phase we get is about 33.22.
This is a sample code of the state machine we are using :
case 0: // Board_ANALOG_ENABLE
spi_init_state = 1;
PIN_setOutputValue(periHandle, PIN_ID(Board_ANALOG_ENABLE), 1);
Util_rescheduleClock(&sMClock,100);
Util_startClock(&sMClock);
break;
case 1: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 2;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 1);//basel
Util_rescheduleClock(&sMClock,1500);
Util_startClock(&sMClock);
break;
case 2: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 3;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 0);//basel
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 3: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 4;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 1);//basel
Util_rescheduleClock(&sMClock,5);
Util_startClock(&sMClock);
break;
case 4: //open SPI driver and start PWM clock that feeds in the 1MHz clock for the AFE4300
Util_stopClock(&sMClock);
spi_init_state = 14;
//set the regs adata in buffer
index = 0;
txbufInitAFE[index++] = BCM_CON_BCM_DAC_FREQ_ADD | WRITE;
txbufInitAFE[index++] = (0x0000 >> 8);
txbufInitAFE[index++] = (0x0000 & 0x00FF);
//Device Control Reg 2 reset
txbufInitAFE[index++] = DEVICE_CONTROL2_ADD | WRITE;
txbufInitAFE[index++] = (0x0000 >> 8);
txbufInitAFE[index++] = (0x0000 & 0x00FF) ;
//set frequenccyf
txbufInitAFE[index++] = BCM_CON_BCM_DAC_FREQ_ADD | WRITE;
txbufInitAFE[index++] = (FREQ_64_DAC >> 8);
txbufInitAFE[index++] = (FREQ_64_DAC & 0x00FF);
//Device Control Reg 2
txbufInitAFE[index++] = DEVICE_CONTROL2_ADD | WRITE;
txbufInitAFE[index++] = (IQ_64_DEMOD_CLOCK >> 8);
txbufInitAFE[index++] = (IQ_64_DEMOD_CLOCK & 0x00FF) ;
AFESPI_open(peri_spiBufRCVDHandler);
AFEClock_Start();
Util_rescheduleClock(&sMClock,20);
Util_startClock(&sMClock);
break;
case 14:
Util_stopClock(&sMClock);
spi_init_state = 5;
firstTimeGPTInt = false;
regIndex = 0;
GPTimerCC26XX_enableInterrupt(shandle, GPT_INT_CAPTURE);
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 5:
Util_stopClock(&sMClock);
// spi_init_state = 6;
initAFE4300Chip();
afeWorking = true;
dataCount = 0;
DataReady = false;
Util_rescheduleClock(&sMClock,20);
Util_startClock(&sMClock);
break;
case 6:
Util_stopClock(&sMClock);
spi_init_state =15;
spiAcqTransaction.rxBuf =&Xc_Result[0];
RXCal = true;
writeToRegister(0x10, XC_DATA_ACQ);
Util_rescheduleClock(&sMClock,1000);
Util_startClock(&sMClock);
break;
case 30:
Util_stopClock(&sMClock);
startReadyinterrupt = false;
setDefaultElectrodesInput();
Util_rescheduleClock(&sMClock,1000);
Util_startClock(&sMClock);
break;
case 15:
Util_stopClock(&sMClock);
spi_init_state = 20;
xcSum = 0;
xcCount = 0;
rSum = 0;
rCount = 0;
printCounter = 0;
startReadyinterrupt = true;
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 7: //We get here only when a ready interrupt happens
Util_stopClock(&sMClock);
spi_init_state = 20; //exit SM, will get back after the transaction is complete to state 8 or 9
DataReady = true;
readDataTransaction(); //read the ready data through spi transaction
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
The Dac freq and the device control2 registers are written right when we get an interrupt on the one of the internal clock positive edge, it’s as close as we can get to a synchronized spi/device clks then we write the rest of the registers and start the continues mode.
The results we are on sampled networks of resistor||capacitor are not 100% consistent, there is some increase and decrease with time of the actual results, and when tested on the body the whole thing goes haywire, we get a phase equal to 12 for example the first try then 11 then 8 and it keeps falling with then increasing with no apparent pattern.

Thanks
Basel
Hi
We are using the AFE4300 in IQ mode, we are having a problem with the results we get and we will explain what we did to setup the device:
First of we are using 2 calibration resistors (500 and 100 ohms) the magnitude calibration is done properly with no issues, as for the phase we are taking the results of the I and Q of the 500 Ohms resistor, the reference phase we get is about 33.22.
This is a sample code of the state machine we are using :
case 0: // Board_ANALOG_ENABLE
spi_init_state = 1;
PIN_setOutputValue(periHandle, PIN_ID(Board_ANALOG_ENABLE), 1);
Util_rescheduleClock(&sMClock,100);
Util_startClock(&sMClock);
break;
case 1: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 2;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 1);//basel
Util_rescheduleClock(&sMClock,1500);
Util_startClock(&sMClock);
break;
case 2: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 3;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 0);//basel
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 3: // reset pulse
Util_stopClock(&sMClock);
spi_init_state = 4;
PIN_setOutputValue(periHandle, PIN_ID(Board_Sensor_Reset), 1);//basel
Util_rescheduleClock(&sMClock,5);
Util_startClock(&sMClock);
break;
case 4: //open SPI driver and start PWM clock that feeds in the 1MHz clock for the AFE4300
Util_stopClock(&sMClock);
spi_init_state = 14;
//set the regs adata in buffer
index = 0;
txbufInitAFE[index++] = BCM_CON_BCM_DAC_FREQ_ADD | WRITE;
txbufInitAFE[index++] = (0x0000 >> 8);
txbufInitAFE[index++] = (0x0000 & 0x00FF);
//Device Control Reg 2 reset
txbufInitAFE[index++] = DEVICE_CONTROL2_ADD | WRITE;
txbufInitAFE[index++] = (0x0000 >> 8);
txbufInitAFE[index++] = (0x0000 & 0x00FF) ;
//set frequenccyf
txbufInitAFE[index++] = BCM_CON_BCM_DAC_FREQ_ADD | WRITE;
txbufInitAFE[index++] = (FREQ_64_DAC >> 8);
txbufInitAFE[index++] = (FREQ_64_DAC & 0x00FF);
//Device Control Reg 2
txbufInitAFE[index++] = DEVICE_CONTROL2_ADD | WRITE;
txbufInitAFE[index++] = (IQ_64_DEMOD_CLOCK >> 8);
txbufInitAFE[index++] = (IQ_64_DEMOD_CLOCK & 0x00FF) ;
AFESPI_open(peri_spiBufRCVDHandler);
AFEClock_Start();
Util_rescheduleClock(&sMClock,20);
Util_startClock(&sMClock);
break;
case 14:
Util_stopClock(&sMClock);
spi_init_state = 5;
firstTimeGPTInt = false;
regIndex = 0;
GPTimerCC26XX_enableInterrupt(shandle, GPT_INT_CAPTURE);
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 5:
Util_stopClock(&sMClock);
// spi_init_state = 6;
initAFE4300Chip();
afeWorking = true;
dataCount = 0;
DataReady = false;
Util_rescheduleClock(&sMClock,20);
Util_startClock(&sMClock);
break;
case 6:
Util_stopClock(&sMClock);
spi_init_state =15;
spiAcqTransaction.rxBuf =&Xc_Result[0];
RXCal = true;
writeToRegister(0x10, XC_DATA_ACQ);
Util_rescheduleClock(&sMClock,1000);
Util_startClock(&sMClock);
break;
case 30:
Util_stopClock(&sMClock);
startReadyinterrupt = false;
setDefaultElectrodesInput();
Util_rescheduleClock(&sMClock,1000);
Util_startClock(&sMClock);
break;
case 15:
Util_stopClock(&sMClock);
spi_init_state = 20;
xcSum = 0;
xcCount = 0;
rSum = 0;
rCount = 0;
printCounter = 0;
startReadyinterrupt = true;
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
case 7: //We get here only when a ready interrupt happens
Util_stopClock(&sMClock);
spi_init_state = 20; //exit SM, will get back after the transaction is complete to state 8 or 9
DataReady = true;
readDataTransaction(); //read the ready data through spi transaction
Util_rescheduleClock(&sMClock,2);
Util_startClock(&sMClock);
break;
The Dac freq and the device control2 registers are written right when we get an interrupt on the one of the internal clock positive edge, it’s as close as we can get to a synchronized spi/device clks then we write the rest of the registers and start the continues mode.
The results we are on sampled networks of resistor||capacitor are not 100% consistent, there is some increase and decrease with time of the actual results, and when tested on the body the whole thing goes haywire, we get a phase equal to 12 for example the first try then 11 then 8 and it keeps falling with then increasing with no apparent pattern.