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.

AFE440 on arduino

Other Parts Discussed in Thread: AFE4400

hello i want to ask about my afe4400 , i want to connect chip afe4400 to my arduino board and this is my code on arduino board. i have connected my chip with this configuration

this is my arduino config

the configurations are

AFE_PDN --> ARD_PWDN

ADC_RESET --> ARD_START

ADC_RDY -- > ARD_DRDY

LED_ALM --> ARD_LED_ALM

SPI_MOSI --> ARD_MOSI

SPI_MISO --> ARD_MISO

SPI_SCK --> ARD_SCK

DIAG_END --> ARD_DIAG_END

SPI_CS0 --> ARD_CS0

PD_ALM --> ARD_PD_ALM

this is my code

#include <string.h>
#include <SPI.h>
#include <math.h>
//#include "Average.h"
#include <FIR.h>

#define CONTROL0		0x00
#define LED2STC			0x01
#define LED2ENDC		0x02
#define LED2LEDSTC		0x03
#define LED2LEDENDC		0x04
#define ALED2STC		0x05
#define ALED2ENDC		0x06
#define LED1STC			0x07
#define LED1ENDC		0x08
#define LED1LEDSTC		0x09
#define LED1LEDENDC		0x0a
#define ALED1STC		0x0b
#define ALED1ENDC		0x0c
#define LED2CONVST		0x0d
#define LED2CONVEND		0x0e
#define ALED2CONVST		0x0f
#define ALED2CONVEND	0x10
#define LED1CONVST		0x11
#define LED1CONVEND		0x12
#define ALED1CONVST		0x13
#define ALED1CONVEND	0x14
#define ADCRSTCNT0		0x15
#define ADCRSTENDCT0	0x16
#define ADCRSTCNT1		0x17
#define ADCRSTENDCT1	0x18
#define ADCRSTCNT2		0x19
#define ADCRSTENDCT2	0x1a
#define ADCRSTCNT3		0x1b
#define ADCRSTENDCT3	0x1c
#define PRPCOUNT		0x1d
#define CONTROL1		0x1e
#define SPARE1			0x1f
#define TIAGAIN			0x20
#define TIA_AMB_GAIN	0x21
#define LEDCNTRL		0x22
#define CONTROL2		0x23
#define SPARE2			0x24
#define SPARE3			0x25
#define SPARE4			0x26
#define SPARE4			0x26
#define RESERVED1		0x27
#define RESERVED2		0x28
#define ALARM			0x29
#define LED2VAL			0x2a
#define ALED2VAL		0x2b
#define LED1VAL			0x2c
#define ALED1VAL		0x2d
#define LED2ABSVAL		0x2e
#define LED1ABSVAL		0x2f
#define DIAG			0x30


#define BPM_WINDOW 300
#define count 60
int IRheartsignal[count];
int Redheartsignal[count];
int IRdc[count];
int Reddc[count];
double difIRheartsig_dc;
double difREDheartsig_dc;
double powdifIR;
double powdifRed;
double IRac; 
double Redac;
double SpOpercentage;
double Ratio;

const int SOMI = 12; 
const int SIMO = 11; 
const int SCLK  = 13;
const int SPISTE = 7; 
const int SPIDRDY = 6;

int pin = 3;
int pin2 = 4;
volatile int state = LOW;


void AFE4490Init (void);
void AFE4490Write (uint8_t address, uint32_t data);
uint32_t AFE4490Read (uint8_t address);
signed long average_BPM( signed long );
//--------------------------------------------------------------------------------------------------------------------

#define	CES_CMDIF_PKT_START_1		0x0A
#define	CES_CMDIF_PKT_START_2		0xFA
#define	CES_CMDIF_TYPE_DATA		0x02
#define	CES_CMDIF_PKT_STOP		0x0B

volatile char DataPacketHeader[5];
volatile char DataPacketFooter[2];
volatile int datalen = 135;
unsigned long time;

volatile byte SPI_RX_Buff[150] ;
volatile static int SPI_RX_Buff_Count = 0;
volatile char *SPI_RX_Buff_Ptr;
volatile int Responsebyte = false;
volatile unsigned int pckt =0 , buff=0,t=0 , j1=0,j2=0;
volatile unsigned long int EEG_Ch1_Data[150],EEG_Ch2_Data[150];
volatile unsigned char datac[150];
unsigned long ueegtemp = 0, ueegtemp2 = 0, Pkt_Counter=0;
signed long seegtemp=0, seegtemp2=0;
volatile int i;

FIR fir;

void setup()
{
   Serial.begin(57600);
    
   SPI.begin(); 
   pinMode (SOMI,INPUT);
   pinMode (SPISTE,OUTPUT);
   pinMode (SCLK, OUTPUT);
   pinMode (SIMO, OUTPUT);
   pinMode (SPIDRDY,INPUT);
   
   pinMode(2, INPUT);
 pinMode(3, OUTPUT);

  //pinMode(pin, OUTPUT);
  attachInterrupt(0, blink, RISING );
   
   SPI.setClockDivider (SPI_CLOCK_DIV8);
   SPI.setDataMode (SPI_MODE0);
   SPI.setBitOrder (MSBFIRST);
//-------------------------------------------
	DataPacketHeader[0] = CES_CMDIF_PKT_START_1;
	DataPacketHeader[1] = CES_CMDIF_PKT_START_2;
	DataPacketHeader[2] = (datalen);
	DataPacketHeader[3] = (datalen >> 8);
	DataPacketHeader[4] = CES_CMDIF_TYPE_DATA;
  
	DataPacketFooter[0] = 0x00;
	DataPacketFooter[1] = CES_CMDIF_PKT_STOP;
//------------------------------------------------- 
    float coef[FILTERTAPS] = { 0.021, 0.096, 0.146, 0.096, 0.021};
    fir.setCoefficients(coef);

//declare gain coefficient to scale the output back to normal
    float gain = 1; // set to 1 and input unity to see what this needs to be
    fir.setGain(gain);
    

   AFE4490Init (); 
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void loop()
{           // for(int i = 0; i<count; i++) 
               
                    //if (0)
                      //                    Serial.println("TEST3");
                    if (state == HIGH)
                    {
                        //noInterrupts();
                        detachInterrupt(0);
                          digitalWrite(3, 1);        //test pin 3
                          digitalWrite(3, 0); 
                   //   Serial.println("TEST3");                                              
                                                //delay(10);                      
                        AFE4490Write(CONTROL0,0x000001);  
                        ueegtemp = AFE4490Read(LED1VAL);
                        ueegtemp =ueegtemp;
                        //ueegtemp2 = AFE4490Read(LED1VAL);
		          Responsebyte = true;
                          /*  AFE4490Read(LED1VAL);
                          AFE4490Read(LED2VAL);
                        *//*Serial.print(AFE4490Read(LED1VAL)); 
                       Serial.print("\t"); 
                       Serial.println(AFE4490Read(LED2VAL));    
                          */

                    }  
                    
	if(Responsebyte == true)
	{
		//for(t=0; t< 1 ; t++)
		{	
			buff = 0;
			Pkt_Counter++; //if(Pkt_Counter > 0) Pkt_Counter = 0x00;
					
			datac[buff++] = 0xA0;  // sync0
			datac[buff++] = 36;   //sync1
					
			datac[buff++] = (unsigned char)(Pkt_Counter >> 24);
			datac[buff++] = (unsigned char)(Pkt_Counter >> 16);
			datac[buff++] = (unsigned char)(Pkt_Counter >> 8);
			datac[buff++] = (unsigned char)(Pkt_Counter );
											
        
			ueegtemp = (unsigned long) (ueegtemp<<10);
			seegtemp = (signed long) (ueegtemp);
			seegtemp = (signed long) (seegtemp>>10);	
                   //     Serial.println(seegtemp);
          //            Serial.println("TEST2");
                       // seegtemp = seegtemp - average_BPM(seegtemp);
                        seegtemp = seegtemp*100;
                       // seegtemp = fir.process(seegtemp);    
                        //Serial.println(seegtemp);
                        
                        ueegtemp2 = (unsigned long) (ueegtemp2<<10);
			seegtemp2 = (signed long) (ueegtemp2);
			seegtemp2 = (signed long) (seegtemp2>>10);
                        /*for(i=3000;i<seegtemp;i+=10)
                        {
                            Serial.print("*");
                            //Serial.print("hai");
                        }    
                        Serial.println(" ");    
                        */    
			pckt+= 3;
				
                        //seegtemp = seegtemp*5			
			datac[buff++] = (unsigned char) (seegtemp);
			datac[buff++] = (unsigned char) (seegtemp>>8);   //>>8
			datac[buff++] = ( unsigned char) (seegtemp >> 16); //>>16
			datac[buff++] = (unsigned char) (seegtemp >>24);

			 //Serial.println(seegtemp);

			/*datac[buff++] = (unsigned char) (seegtemp2);
			datac[buff++] = (unsigned char) (seegtemp2>>8);   //>>8
			datac[buff++] = ( unsigned char) (seegtemp2 >> 16); //>>16
			datac[buff++] = (unsigned char) (seegtemp2 >>24);
			*/		
			for(i=0;i<28;i++)  // fill channel 1 buff
			{
				//ueegtemp = (uint16_t) ( (EEG_Ch1_Data[pckt+1]<<8)| EEG_Ch1_Data[pckt]);
				//seegtemp = (int16_t) (ueegtemp);
				//pckt++
				//datac[buff++] = EEG_Ch1_Data[pckt++] ;
				datac[buff++] = 0x00 ;
			}						
						
			datac[buff++] = 0xc0;//(uint8_t)seegtemp ;
			
			//Serial.println(seegtemp);	

			for(i=0; i<39; i++) // transmit the data
			{
				Serial.write(datac[i]);
				//udi_cdc_putc(datac[i]);
				//cpu_delay_us(90, 48000000);		
			}					
			//	cpu_delay_us(100, 48000000);	
		}
		
		//SPI_RX_Buff_Count = 0;
                Responsebyte = false;
                
                 state = LOW;
                       attachInterrupt(0, blink, RISING );
		/*  
		Serial.print("Stop Time: ");
		time = millis();
		//prints time since program started
		Serial.println(time);
		*/			
	}
                      
        
}


signed long average_BPM( signed long bpm)
{
	static int bpm_sample_count;
	static signed long bpm_store[BPM_WINDOW];
	signed long bpm_sum =0, bpm_avg=0;

	if (bpm_sample_count < BPM_WINDOW)
		bpm_store[bpm_sample_count++] = bpm;

	else	
	{
		for(i=0 ; i<BPM_WINDOW-1 ; i++) 
			bpm_store[i] = bpm_store[i+1] ; 
		
		bpm_store[BPM_WINDOW-1] = bpm;
	}

/*
        Serial.println("\nbpm_store\t");
	for(i=0 ; i<BPM_WINDOW ; i++)
        {
		Serial.print(bpm_store[i]);
                Serial.print("\t");
        } 


     	Serial.print("\nbpm_sample_count\t");
	Serial.println(bpm_sample_count);
*/
	for(i=0 ; i<BPM_WINDOW ; i++)
	    bpm_sum += bpm_store[i];
/*
        Serial.print("\nbpm_sum\t");
	Serial.println(bpm_sum);
*/
	bpm_avg = bpm_sum/(bpm_sample_count);
/*
	Serial.print("\nbpm_avg\t");
	Serial.println(bpm_avg);
*/
	return (bpm_avg);
}
  

void blink()
{
  state = HIGH;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AFE4490Init (void)
{ 
    Serial.println("AFE4490 Initialization Starts"); 
     AFE4490Write(CONTROL0,0x000000);
     
                  AFE4490Write(TIAGAIN,0x000000);	// CF = 5pF, RF = 500kR
                   AFE4490Write(TIA_AMB_GAIN,0x000005);	// Timers ON, average 3 samples 
                   AFE4490Write(LEDCNTRL,0x0011414);	  
                   AFE4490Write(CONTROL2,0x000000);	// LED_RANGE=100mA, LED=50mA 
                   AFE4490Write(CONTROL1,0x010707);	// Timers ON, average 3 samples  
    
     AFE4490Write(PRPCOUNT, 0X001F3F);
    /*AFE4490Write(CONTROL1, 0x000101);
    AFE4490Write(CONTROL2, 0x000000);  
    AFE4490Write(PRPCOUNT, 0X001F3F);*/

    AFE4490Write(LED2STC, 0X001770); //timer control
    AFE4490Write(LED2ENDC,0X001F3E); //timer control
    AFE4490Write(LED2LEDSTC,0X001770); //timer control
    AFE4490Write(LED2LEDENDC,0X001F3F); //timer control
    AFE4490Write(ALED2STC, 0X000000); //timer control
    AFE4490Write(ALED2ENDC, 0X0007CE); //timer control
    AFE4490Write(LED2CONVST,0X000002); //timer control
    AFE4490Write(LED2CONVEND, 0X0007CF); //timer control
    AFE4490Write(ALED2CONVST, 0X0007D2); //timer control
    AFE4490Write(ALED2CONVEND,0X000F9F); //timer control

    AFE4490Write(LED1STC, 0X0007D0); //timer control
    AFE4490Write(LED1ENDC, 0X000F9E); //timer control
    AFE4490Write(LED1LEDSTC, 0X0007D0); //timer control
    AFE4490Write(LED1LEDENDC, 0X000F9F); //timer control
    AFE4490Write(ALED1STC, 0X000FA0); //timer control
    AFE4490Write(ALED1ENDC, 0X00176E); //timer control
    AFE4490Write(LED1CONVST, 0X000FA2); //timer control
    AFE4490Write(LED1CONVEND, 0X00176F); //timer control
    AFE4490Write(ALED1CONVST, 0X001772); //timer control
    AFE4490Write(ALED1CONVEND, 0X001F3F); //timer control

    AFE4490Write(ADCRSTCNT0, 0X000000); //timer control
    AFE4490Write(ADCRSTENDCT0,0X000000); //timer control
    AFE4490Write(ADCRSTCNT1, 0X0007D0); //timer control
    AFE4490Write(ADCRSTENDCT1, 0X0007D0); //timer control
    AFE4490Write(ADCRSTCNT2, 0X000FA0); //timer control
    AFE4490Write(ADCRSTENDCT2, 0X000FA0); //timer control
    AFE4490Write(ADCRSTCNT3, 0X001770); //timer control
    AFE4490Write(ADCRSTENDCT3, 0X001770);
  
    delay(1000);
    Serial.println("AFE4490 Initialization Done"); 
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AFE4490Write (uint8_t address, uint32_t data)
{
    digitalWrite (SPISTE, LOW); // enable device
    SPI.transfer (address); // send address to device
    SPI.transfer ((data >> 16) & 0xFF); // write top 8 bits
    SPI.transfer ((data >> 8) & 0xFF); // write middle 8 bits
    SPI.transfer (data & 0xFF); // write bottom 8 bits    
    digitalWrite (SPISTE, HIGH); // disable device
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
uint32_t AFE4490Read (uint8_t address)
{       
    uint32_t data=0;
    digitalWrite (SPISTE, LOW); // enable device
    SPI.transfer (address); // send address to device
    //SPI.transfer (data);
    data |= (SPI.transfer (0)<<16); // read top 8 bits data
    data |= (SPI.transfer (0)<<8); // read middle 8 bits  data
    data |= SPI.transfer (0); // read bottom 8 bits data
    digitalWrite (SPISTE, HIGH); // disable device
    
   /* pinMode (SOMI,OUTPUT);
    digitalWrite (SOMI, HIGH); 
     delay(1);
    pinMode (SOMI,INPUT);    
    */
    
    return data; // return with 24 bits of read data
}

i have several problem which are :

1. last time, i have trouble in connecting this small chip into my printed pcb board. at first i try to arrange it so the pin is matched with the routing manually. but suddenly this chip is getting hot. So finally i have soldered that chip but it dontgive any result.  

i have checked it the sign of life of afe4400 chip. but it has different result with what stated in FAQ section

1.  tx-ref_pin = 0.11 V

2. BG = 0.65 V

3. VCM = 1.12 V

voltage tx_ref/led_drv and rx_ana/rx_div, both are supplied from arduino uno board which value is 3.3 V

i am suspicious that i have damage my chip, is there any way to test that my chip can still work?

2. is there any proper way to make the chip connected to printed board without damaging it? any soldering reccomendation?

3. is there any other references code that can help my case? right now i am designing a photoplethysmograph sensor based on afe4400 chip

4. is my configuration is right? i use 22pF instead 18pF as stated in datasheet, i also supply LED_DRV_SUP, TX_CTRL_SUP, RX_DIG_SUP, RX_ANA_SUP with 3.3 V because, 3.3 V is only available supply in my system.

5. i have connected led and IR like in the datasheet, i have tried both configuration, common anode and H-bridge, but it still dont give any result. i have tested pin INP , INM, TXM and TXP

pin INP : 0.07V

pin INM : 0.02V

pin TXM : 0.35V

pin TXP : 0.35 V

with my above code, the result of register led1val is always 0.

i have check it with giving a led in ADC_RDY pin to tell me when the ADC_RDY is updated and reset, but the result is still none.

FYI, i bought raw chip, not evaluation module 

thanks, pardon for my mistake because english is not my native

i look forward to your help 

regards.

  • Arrozaq,

    We've received your post and hope to respond back to you soon.
  • hello amy, i have tried to modify source code and give a check point where my source code is stopped. this is the look of my source code on arduino

    #include <string.h>
    #include <SPI.h>
    #include <math.h>
    #include <FIR.h>
    //#include "Average.h"
    #define BPM_WINDOW 300
    
    
    #define CONTROL0		0x00
    #define LED2STC			0x01
    #define LED2ENDC		0x02
    #define LED2LEDSTC		0x03
    #define LED2LEDENDC		0x04
    #define ALED2STC		0x05
    #define ALED2ENDC		0x06
    #define LED1STC			0x07
    #define LED1ENDC		0x08
    #define LED1LEDSTC		0x09
    #define LED1LEDENDC		0x0a
    #define ALED1STC		0x0b
    #define ALED1ENDC		0x0c
    #define LED2CONVST		0x0d
    #define LED2CONVEND		0x0e
    #define ALED2CONVST		0x0f
    #define ALED2CONVEND	        0x10
    #define LED1CONVST		0x11
    #define LED1CONVEND		0x12
    #define ALED1CONVST		0x13
    #define ALED1CONVEND	        0x14
    #define ADCRSTCNT0		0x15
    #define ADCRSTENDCT0	        0x16
    #define ADCRSTCNT1		0x17
    #define ADCRSTENDCT1	        0x18
    #define ADCRSTCNT2		0x19
    #define ADCRSTENDCT2	        0x1a
    #define ADCRSTCNT3		0x1b
    #define ADCRSTENDCT3	        0x1c
    #define PRPCOUNT		0x1d
    #define CONTROL1		0x1e
    #define SPARE1			0x1f
    #define TIAGAIN			0x20
    #define TIA_AMB_GAIN	        0x21
    #define LEDCNTRL		0x22
    #define CONTROL2		0x23
    #define SPARE2			0x24
    #define SPARE3			0x25
    #define SPARE4			0x26
    #define SPARE4			0x26
    #define RESERVED1		0x27
    #define RESERVED2		0x28
    #define ALARM			0x29
    #define LED2VAL			0x2a
    #define ALED2VAL		0x2b
    #define LED1VAL			0x2c
    #define ALED1VAL		0x2d
    #define LED2ABSVAL		0x2e
    #define LED1ABSVAL		0x2f
    #define DIAG			0x30
    
    
    #define count 60
    int IRheartsignal[count];
    int Redheartsignal[count];
    int IRdc[count];
    int Reddc[count];
    double difIRheartsig_dc;
    double difREDheartsig_dc;
    
    FIR fir;
    
    //unsigned int Redac_sq ;
    
    /*
    double powdifIR;
    double powdifRed;
    
    double SpOpercentage;
    double Ratio;
    */
    
    const int SOMI = 12; 
    const int SIMO = 11; 
    const int SCLK  = 13;
    const int SPISTE = 7; 
    const int SPIDRDY = 6;
    
    int pin = 3;
    int pin2 = 4;
    volatile int state = LOW;
    
    
    void AFE4490Init (void);
    void AFE4490Write (uint8_t address, uint32_t data);
    uint32_t AFE4490Read (uint8_t address);
    
    void setup()
    {
       Serial.begin(9600);
        
       SPI.begin(); 
       pinMode (SOMI,INPUT);
       pinMode (SPISTE,OUTPUT);
       pinMode (SCLK, OUTPUT);
       pinMode (SIMO, OUTPUT);
       pinMode (SPIDRDY,INPUT);
       
       pinMode(2, INPUT);
       pinMode(3, OUTPUT);
    
      //pinMode(pin, OUTPUT);
      attachInterrupt(0, blink, RISING );
       
       SPI.setClockDivider (SPI_CLOCK_DIV8);
       SPI.setDataMode (SPI_MODE0);
       SPI.setBitOrder (MSBFIRST);
       
        
      
    float coef[FILTERTAPS] = { 0.021, 0.096, 0.146, 0.096, 0.021};
        fir.setCoefficients(coef);
    
        //declare gain coefficient to scale the output back to normal
        float gain = 1; // set to 1 and input unity to see what this needs to be
        fir.setGain(gain);
        
        
     
       AFE4490Init (); 
       }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    void loop()
    {
        Serial.println("loop dimulai");
        float data = sp02();
                           if(data)
                           {
                            Serial.print("sp02:--> ");
                           Serial.println(data);
                           }
        Serial.println("loop diakhir");
    
    }
    
    
    void blink()
    {
      Serial.print("stateblink :");Serial.println(state);
      Serial.println("subroutine is began");
      state = HIGH;
      Serial.println("state is high");
      Serial.println("subroutine has been passed");
      Serial.print("stateblink :");Serial.println(state);
      
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void AFE4490Init (void)
    { 
        Serial.println("AFE4490 Initialization Starts");
        Serial.println("CHIP is being registered"); 
         AFE4490Write(CONTROL0,0x000000);
         
                       Serial.print("TIAGAIN :");AFE4490Write(TIAGAIN,0x000000);Serial.println(TIAGAIN,BIN);	// CF = 5pF, RF = 500kR
                       Serial.print("TIA_AMB_GAIN :");AFE4490Write(TIA_AMB_GAIN,0x000005);Serial.println(TIA_AMB_GAIN,BIN);	// Timers ON, average 3 samples 
                       Serial.print("LENDCNTRL :");AFE4490Write(LEDCNTRL,0x0011414);Serial.println(LEDCNTRL,BIN);	  
                       Serial.print("CONTROL2 :");AFE4490Write(CONTROL2,0x000000);Serial.println(CONTROL2,BIN);	// LED_RANGE=100mA, LED=50mA 
                       Serial.print("CONTROL1 :");AFE4490Write(CONTROL1,0x010707);Serial.println(CONTROL1,BIN);	// Timers ON, average 3 samples  
        
         Serial.print("PRPCOUNT :");AFE4490Write(PRPCOUNT, 0X001F3F);Serial.println(PRPCOUNT,BIN);
        /*AFE4490Write(CONTROL1, 0x000101);
        AFE4490Write(CONTROL2, 0x000000);  
        AFE4490Write(PRPCOUNT, 0X001F3F);*/
    
        Serial.print("LED2STC :");AFE4490Write(LED2STC, 0X001770);Serial.println(LED2STC,BIN); //timer control
        Serial.print("LED2ENDC :");AFE4490Write(LED2ENDC,0X001F3E);Serial.println(LED2ENDC,BIN); //timer control
        Serial.print("LED2LEDSTC :");AFE4490Write(LED2LEDSTC,0X001770);Serial.println(LED2LEDSTC,BIN); //timer control
        Serial.print("LED2LEDENDC :");AFE4490Write(LED2LEDENDC,0X001F3F);Serial.println(LED2LEDENDC,BIN); //timer control
        Serial.print("ALED2STC :");AFE4490Write(ALED2STC, 0X000000);Serial.println(ALED2STC,BIN); //timer control
        Serial.print("ALED2ENDC :");AFE4490Write(ALED2ENDC, 0X0007CE);Serial.println(ALED2ENDC,BIN); //timer control
        Serial.print("LED2CONVST :");AFE4490Write(LED2CONVST,0X000002);Serial.println(LED2CONVST,BIN); //timer control
        Serial.print("LED2CONVEND :");AFE4490Write(LED2CONVEND, 0X0007CF);Serial.println(LED2CONVEND,BIN); //timer control
        Serial.print("ALED2CONVST :");AFE4490Write(ALED2CONVST, 0X0007D2);Serial.println(ALED2CONVST,BIN); //timer control
        Serial.print("ALED2CONVEND :");AFE4490Write(ALED2CONVEND,0X000F9F);Serial.println(ALED2CONVEND,BIN); //timer control
    
        Serial.print("LED1STC :");AFE4490Write(LED1STC, 0X0007D0);Serial.println(LED1STC,BIN); //timer control
        Serial.print("LED1ENDC :");AFE4490Write(LED1ENDC, 0X000F9E);Serial.println(LED1ENDC,BIN); //timer control
        Serial.print("LED1LEDSRC :");AFE4490Write(LED1LEDSTC, 0X0007D0);Serial.println(LED1LEDSTC,BIN); //timer control
        Serial.print("LED1LEDENDC :");AFE4490Write(LED1LEDENDC, 0X000F9F);Serial.println(LED1LEDENDC,BIN); //timer control
        Serial.print("ALED1STC :");AFE4490Write(ALED1STC, 0X000FA0);Serial.println(ALED1STC,BIN); //timer control
        Serial.print("ALED1ENDC :");AFE4490Write(ALED1ENDC, 0X00176E);Serial.println(ALED1ENDC,BIN); //timer control
        Serial.print("LED1CONVST :");AFE4490Write(LED1CONVST, 0X000FA2);Serial.println(LED1CONVST,BIN); //timer control
        Serial.print("LED1CONVEND :");AFE4490Write(LED1CONVEND, 0X00176F);Serial.println(LED1CONVEND,BIN); //timer control
        Serial.print("ALED1CONVST :");AFE4490Write(ALED1CONVST, 0X001772);Serial.println(ALED1CONVST,BIN); //timer control
        Serial.print("ALED1CONVEND :");AFE4490Write(ALED1CONVEND, 0X001F3F);Serial.println(ALED1CONVEND,BIN); //timer control
    
        Serial.print("ADCRSTCNT0 :");AFE4490Write(ADCRSTCNT0, 0X000000);Serial.println(ADCRSTCNT0,BIN); //timer control
        Serial.print("ADCRSTENDCT0 :");AFE4490Write(ADCRSTENDCT0,0X000000);Serial.println(ADCRSTENDCT0,BIN); //timer control
        Serial.print("ADCRSTCNT1 :");AFE4490Write(ADCRSTCNT1, 0X0007D0);Serial.println(ADCRSTCNT1,BIN); //timer control
        Serial.print("ADCRSTENDCT1 :");AFE4490Write(ADCRSTENDCT1, 0X0007D0);Serial.println(ADCRSTENDCT1,BIN); //timer control
        Serial.print("ADCRSTCNT2 :");AFE4490Write(ADCRSTCNT2, 0X000FA0);Serial.println(ADCRSTCNT2,BIN); //timer control
        Serial.print("ADCRSTENDCT2 :");AFE4490Write(ADCRSTENDCT2, 0X000FA0);Serial.println(ADCRSTENDCT2,BIN); //timer control
        Serial.print("ADCRSTCNT3 :");AFE4490Write(ADCRSTCNT3, 0X001770);Serial.println(ADCRSTCNT3,BIN); //timer control
        Serial.print("ADCRSTENDCT3 :");AFE4490Write(ADCRSTENDCT3, 0X001770);Serial.println(ADCRSTENDCT3,BIN);
      
        delay(1000);
        Serial.println("AFE4490 Initialization Done"); 
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    void AFE4490Write (uint8_t address, uint32_t data)
    {
        //Serial.print("AFE4400 is writing data to its register...");
        digitalWrite (SPISTE, LOW); // enable device
        SPI.transfer (address); // send address to device
        SPI.transfer ((data >> 16) & 0xFF); // write top 8 bits
        SPI.transfer ((data >> 8) & 0xFF); // write middle 8 bits
        SPI.transfer (data & 0xFF); // write bottom 8 bits    
        digitalWrite (SPISTE, HIGH); // disable device
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    uint32_t AFE4490Read (uint8_t address)
    {       
        uint32_t data=0;
        digitalWrite (SPISTE, LOW); // enable device
        SPI.transfer (address); // send address to device
        //SPI.transfer (data);
        data |= (SPI.transfer (0)<<16); // read top 8 bits data
        data |= (SPI.transfer (0)<<8); // read middle 8 bits  data
        data |= SPI.transfer (0); // read bottom 8 bits data
        digitalWrite (SPISTE, HIGH); // disable device
        
       /* pinMode (SOMI,OUTPUT);
        digitalWrite (SOMI, HIGH); 
         delay(1);
        pinMode (SOMI,INPUT);    
        */
    	
        return data; // return with 24 bits of read data
    }
    
    
    void enableDRDY()
    {
          Serial.println("attach interrupt...");
          state = LOW;
          Serial.print("state1: ");Serial.println(state);
          attachInterrupt(0, blink, RISING );
          Serial.print("state2: ");Serial.println(state);  
    }
    
    void disableDRDY()
    {
           Serial.println("detach interrupt...");
           detachInterrupt(0);  
    }
    
    signed long AFERead (uint8_t address)
    {       
    
      	uint32_t data = AFE4490Read (address);
            Serial.print("isi dari data adalah : "); Serial.println(data,HEX); 
            Serial.print("\t"); 
    	
    	unsigned long utemp = (unsigned long) (data<<10);
    	signed long stemp = (signed long) (utemp);
    	stemp = (signed long) (stemp>>10);	
    	
    
        return stemp; // return with 22 bits of read data
    }
    
    
    float sp02(void)
    {
            Serial.println("sp02 subroutine");
    	//unsigned int 
            long Redvalue, IRvalue, Redhigh, Redlow, IRhigh, IRlow;
            long Redsum = 0, IRsum = 0;
            unsigned long Redac_sq = 0;
            unsigned long IRac_sq = 0;
            static int flag1 = 1;
            long Reddc, IRdc,Reddc_prev,IRdc_prev;
            int samples = 2000;
            long IRac; 
            long  Redac;
    
            
            AFE4490Write(CONTROL0,0x000001);  	
    	Redhigh = Redlow = AFERead(LED2VAL);
            Serial.print("led2val contains:");Serial.println(LED2VAL);
            IRhigh = IRlow = AFERead(LED1VAL);
    	Serial.print("led1val contains:");Serial.println(LED1VAL);
    
            for(int i=1;i<(samples+1);i++)
    	{
                    
                    Serial.println("uterations");
                    Serial.println("ADC begins in");Serial.println(ADCRSTCNT0,BIN);Serial.println(ADCRSTCNT1,BIN);Serial.println(ADCRSTCNT2,BIN);Serial.println(ADCRSTENDCT3,BIN);
                    Serial.println("ADC ends in");Serial.println(ADCRSTENDCT0,BIN);Serial.println(ADCRSTENDCT1,BIN);Serial.println(ADCRSTENDCT2,BIN);Serial.println(ADCRSTENDCT3,BIN);
                    enableDRDY();Serial.println("masuk ke interrupt");
                    Serial.print("state3: ");Serial.println(state);
                    
                    while (state == LOW);
                    Serial.print("state4: ");Serial.println(state);
    		Redvalue = AFERead(LED2VAL);
                    Serial.print("RedValue : ");Serial.println(Redvalue);
    		IRvalue = AFERead(LED1VAL);
                    Serial.print("IRValue : ");Serial.println(IRvalue);
                     disableDRDY();
                     Serial.println("detach interrupt");
                    //Serial.print(Redvalue); 
                    //Serial.print("\t");                 
                    Redvalue = fir.process(Redvalue);  
                    IRvalue = fir.process(IRvalue);  
                    //Serial.println(Redvalue); 
                     
                 /*               Serial.print(i); 
                    Serial.print("\t");   
                   Serial.print(Redvalue); 
                    Serial.print("\t"); 
                    Serial.print(IRvalue); 
                    Serial.print("\t"); 
                 	*/	
    		Redsum += Redvalue;
    		IRsum += IRvalue;
    		
    		if(Redvalue > Redhigh)
    			Redhigh = Redvalue;	
    		if(Redvalue < Redlow)
    			Redlow = Redvalue;	
    			
    		if(IRvalue > IRhigh)
    			IRhigh = IRvalue;	
    		if(IRvalue < IRlow)
    			IRlow = IRvalue;	
    
                   /*  Reddc = average_BPM(Redvalue);
                      IRdc = average_BPM2(IRvalue);
    */
                    if (i<501)
                    {
                      continue;
                    }
                        Reddc = Redsum/i;
                      IRdc = IRsum/i;
    
                    //Redac_sq = Redhigh - Reddc;
    	        //IRac_sq = IRhigh - IRdc;
                     /* Serial.print(Reddc);
                                       Serial.print("\t");
                                                         Serial.print(IRdc);
                                       Serial.print("\t");\
                       */                
                    /* Redac_sq += pow (((long)(Redvalue - Reddc_prev)), 2.0);
                     IRac_sq += pow (((long)(IRvalue - IRdc_prev)), 2.0);
                     
                     */
                     Redac_sq += pow (((long)(Redvalue - Reddc)), 2.0);
                     IRac_sq += pow (((long)(IRvalue - IRdc)), 2.0);
                  /*   
                     Serial.print((Redvalue - Reddc));
                     Serial.print("\t");
                     Serial.print(Redac_sq);
                     Serial.print("\t");
                                      Serial.print((IRvalue - IRdc));
                     Serial.print("\t");
                     Serial.println(IRac_sq);
                    */ 
                     
    	}		
    	
          if((Reddc < 0 && IRdc < 0) ||( Reddc>4000 && IRdc>4000))
          {
             Serial.println("Finger not detected.");
             return 0;
          }   
    //Serial.println("hai");
    	/*Reddc_prev = Reddc = Redsum/500;
    	IRdc_prev = IRdc = IRsum/500;
    	
            if(flag1 ==1)
            {
              flag1 = 0;
              return 0;
            }
              
              */
    	/*Redac = Redhigh - Redlow;
    	IRac = IRhigh - IRlow;
    */
    	Redac = sqrt(Redac_sq/(samples-500));
    	IRac = sqrt(IRac_sq/(samples-500));
    
            Serial.print("Reddc: "); 
            Serial.print(Reddc); 
            Serial.print("\t"); 
                    Serial.print("Redhigh: ");                 
                    Serial.print(Redhigh); 
                    Serial.print("\t");
                    Serial.print("Redlow: ");                 
                    Serial.print(Redlow); 
                    Serial.print("\t");
                    Serial.print("Redac_sq: ");                 
                    Serial.print(Redac_sq); 
                    Serial.print("\t");
                    Serial.print("Redac :"); 
                    Serial.print(Redac); 
                    Serial.print("\t");         
            
            
                    Serial.print("IRdc: "); 
                    Serial.print(IRdc); 
                    Serial.print("\t");          
                    Serial.print("IRhigh: ");                 
                    Serial.print(IRhigh); 
                    Serial.print("\t");
                    Serial.print("IRlow: ");                 
                    Serial.print(IRlow); 
                    Serial.print("\t");     
                    Serial.print("IRac_sq :")  ;
                    Serial.print(IRac_sq); 
                    Serial.print("\t");            
                    Serial.print("IRac :"); 
                    Serial.print(IRac); 
                    Serial.print("\t"); 
                   
    	
    	float spo2 = (float)((float)Redac/Reddc)/(float)((float)IRac/IRdc);
    	
    	return spo2;
    }	

    and this is the  serial print out of chip afe4400, i am still use the same configuration like above post

    my code is stuck on state 3 like above pictures, which below of this code. i have waited several time and my chip is getting hot

    any idea about my problem?

  • Azzozaq,

    A few things...

    1. Pin 9 is TX_REF and should have a 2.2uF decoupling cap to GND on it. I also see that AFE_PD is floating. This should be driven as a logic level. It is an active low pin.
    2. I would suggest you sample some more parts from us so that you a few backups since the soldering is difficult. My recommendation for soldering is use solder paste and heat the part, but that is only a preference. Everyone solders things differently.

    3. There is source code available on the product folder www.ti.com/.../toolssoftware scoll down to software and you will find the EVM source code.

    4. Having only a 3.3V supply is ok as long as your LED will allow it. See parametirc table at the beginning of page 8. If your Vfb of the LED is less than 2.2V you should be ok using 3.3V.

    5. It is very possible the chip is damaged because it doesn't seem like you are getting a response from the device. I would try a new device on your board.