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.

CCS/AFE4400: Signal Quality Concerns

Part Number: AFE4400
Other Parts Discussed in Thread: MSP430F5529

Tool/software: Code Composer Studio

Hello,

Currently my senior design group is utilizing the AFE 4400 for heart rate measurement at a user wrist;the AFE is built onto a PCB based off of the references from the user guide. After programming it with the settings recommended in the user guide, out signal shows no usable heart rate information; in addition manual probing of the photo diode with an oscilloscope when the device is worn shows that the general envelope of the expected signal is there.

I was wondering if there was any specific programming sequence or register manipulation that we need to do in order for the get the correct data out of the device, 

We are using an MSP430F5529 to to handle the communication to the AFE.

Below is the code used to initialize the AFE:

void init_SPI(void)
{
	P2OUT	 |= BIT7;
	P2DIR	 |= BIT7;
	P3SEL 	 |= BIT0 + BIT1 + BIT2;                 // P3.0/1/2 option select

	UCB0CTL1 |= UCSWRST;                      		// **Put state machine in reset**
	UCB0CTL0 |= UCMST + UCSYNC + UCCKPH + UCMSB;    // 3-pin, 8-bit SPI master
	                                                // Clock polarity high, MSB
	UCB0CTL1 |= UCSSEL_2;               	        // SMCLK
	UCB0BR0   = 24;                    		        // /2
	UCB0BR1   = 0;                                  //
//	UCB0MCTL  = 0;                                  // No modulation
	UCB0CTL1 &= ~UCSWRST;                           // **Initialize USCI state machine**
//  UCB0IE   |= UCRXIE /*+ UCTXIE*/;                // Enable USCI_B0 RX interrupt

}

int SPI_writeRegister(unsigned char Reg,unsigned long int Dat)
{
	unsigned char send3 = (Dat&0xFF0000)>>16;
	unsigned char send2 = (Dat&0x00FF00)>>8;
	unsigned char send1 = (Dat&0xFF);
    P2OUT &= ~(BIT7);
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = Reg;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = send3;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = send2;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = send1;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
    P2OUT |= (BIT7);
    return 0;
}
void SPI_Read(int Reg, Serial_Type *Out)
{
	unsigned char First;
	unsigned char Second;
	unsigned char Third;
	Out->Status = -1;
    P2OUT &= ~(BIT7);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF =0x01;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = Reg;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF =0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while ((UCB0IFG&UCRXIFG) == 0);
	First = UCB0RXBUF;
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while ((UCB0IFG&UCRXIFG) == 0);
	Second = UCB0RXBUF;
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while ((UCB0IFG&UCRXIFG) == 0);
	Third = UCB0RXBUF;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
	while (!(UCB0IFG&UCTXIFG));
	UCB0TXBUF = 0x00;
	while(USCI_B_SPI_isBusy(SPI_Base) == USCI_B_SPI_BUSY);
    P2OUT |= (BIT7);
    Out->Received[Out->i] = ((First*65536)+(Second*256)+(Third));
//    if(Out->Received[Out->i]>)
    Out->Status=0;
}
void init_AFE(void)
{
    SPI_writeRegister(0x00,8);
    _delay_cycles(100);
    SPI_writeRegister(0x01,6050);
    SPI_writeRegister(0x02,7998);
    SPI_writeRegister(0x03,6000);
    SPI_writeRegister(0x04,7999);
    SPI_writeRegister(0x05,50);
    SPI_writeRegister(0x06,1998);
    SPI_writeRegister(0x07,2050);
    SPI_writeRegister(0x08,3998);
    SPI_writeRegister(0x09,2000);
    SPI_writeRegister(0x0A,3999);
    SPI_writeRegister(0x0B,4050);
    SPI_writeRegister(0x0C,5998);
    SPI_writeRegister(0x0D,4);
    SPI_writeRegister(0x0E,1999);
    SPI_writeRegister(0x0F,2004);
    SPI_writeRegister(0x10,3999);
    SPI_writeRegister(0x11,4004);
    SPI_writeRegister(0x12,5999);
    SPI_writeRegister(0x13,6004);
    SPI_writeRegister(0x14,7999);
    SPI_writeRegister(0x15,0);
    SPI_writeRegister(0x16,3);
    SPI_writeRegister(0x17,2000);
    SPI_writeRegister(0x18,2003);
    SPI_writeRegister(0x19,4000);
    SPI_writeRegister(0x1A,4003);
    SPI_writeRegister(0x1B,6000);
    SPI_writeRegister(0x1C,6003);
    SPI_writeRegister(0x1D,7999);
    _delay_cycles(100);
    SPI_writeRegister(0x22,0x01FFFF);
    SPI_writeRegister(0x1E,0x000702);

}