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.

AFE4490 LED doesn't glow with own microcontroller

Other Parts Discussed in Thread: AFE4490, AFE4490SPO2EVM

Hello all,

I have two AFE4490 SPO2 evaluation boards with me, and in each of them, I've disconnected the 0 ohm resistors and thus disabled the MSP430 on the board, connecting them to a K53 eval board microcontroller. With one of them, I succeeded in writing the code and getting the LED on the DB9 connector cable to glow, and even to get PPG data from it - but on the second board, the LED just flickers faintly (I ran the code once on both of them and the LED glowed on the non working board once - it hasn't glowed since). On the working board, I'm seeing signals on TP23 and TP17, and on the non-working board, what I see are flickers of the waveform whenever the LED blinks. Otherwise, it is low. 

I also probed the pins of the afe4490 chip, and it is getting SCLK, MOSI and STE correctly, and it is also giving out the clockout at 1MHz. ADC_RDY is always low. I have pulled up RESET and AFE_PDNZ and have confirmed this at the IC pins. Ground of the board is also connected to the common ground. 

Could you suggest some way to tell me whether fault is in the way I have soldered the board, or whether the board itself is at fault. I do not think it is a code issue since I have run exactly the same code on another board and got it up and running. My register setting are the default ones as given in the sample code for MSP430 and have worked before for another afe4490.

Regards,

Samyukta

  • Samyukta,


    I believe this device belongs in the Medical Forum. I've moved it there because I believe the engineers there can help you get an answer for this product. Good luck with your project!


    Joseph Wu
  • Any suggestions?
    Update : I tried reading from all the registers and the values I get are zero. I tried resoldering the 0 ohm resistors onto the device and it works fine with the GUI. Also, the same thing happened with another afe4490 - the code was working fine on the board, and today it doesn't work. The register reads back 0 and the LED isn't glowing, also the signal from the AFE which is supposed to turn on the LED comes in small bursts - discontinuously, which makes the LED flicker discontinuously.
  • Samyukta,

    Let me confirm your setup. You have 2 setups that are exactly the same? For both of them you have disconnected communication to the MSP430? Can you let me know which resistors you have removed? Both of them you have connected a K53 eval board with the same software loaded on it?

    You suspected it could be a soldering issue? What did you solder?

    You should be getting ADC_RDY pulses, you are getting ADC_RDY pulses on the setup that works?
  • 7028.SPIPPGcode.txt
    //PPGPArt
    #include "common.h"
    /******************************global variables********************************/ 
    unsigned int data_afe4490[10000];
    unsigned int data_adas1000[10000];
    unsigned long 	AFE44xx_Default_Register_Settings[49] = { //for 500 Hz
    	//Reg0: CONTROL0: CONTROL REGISTER 0
    	0x00000,
       	//Reg1:REDSTARTCOUNT: SAMPLE RED START COUNT
    	6000,
            //Reg2:REDENDCOUNT: SAMPLE RED END COUNT
    	7599,
            //Reg3:REDLEDSTARTCOUNT: RED LED START COUNT
    	6000,
            //Reg4:REDLEDENDCOUNT: RED LED END COUNT
    	7599,
    	//Reg5:AMBREDSTARTCOUNT: SAMPLE AMBIENT RED START COUNT
    	0000,
    	//Reg6:AMBREDENDCOUNT: SAMPLE AMBIENT RED END COUNT
    	1599,
    	//Reg7:IRSTARTCOUNT: SAMPLE IR START COUNT
    	2000,
            //Reg8:IRENDCOUNT: SAMPLE IR END COUNT
    	3599,
            //Reg9:IRLEDSTARTCOUNT: IR LED START COUNT
    	2000,
    	//Reg10:IRLEDENDCOUNT: IR LED END COUNT
    	3599,
    	//Reg11:AMBIRSTARTCOUNT: SAMPLE AMBIENT IR START COUNT
    	4000,
            //Reg12:AMBIRENDCOUNT: SAMPLE AMBIENT IR END COUNT
    	5599,
    	//Reg13:REDCONVSTART: REDCONVST
    	2,
    	//Reg14:REDCONVEND: RED CONVERT END COUNT
    	1999,
    	//Reg15:AMBREDCONVSTART: RED AMBIENT CONVERT START COUNT
    	2002,
    	//Reg16:AMBREDCONVEND: RED AMBIENT CONVERT END COUNT
    	3999,
    	//Reg17:IRCONVSTART: IR CONVERT START COUNT
    	4002,
    	//Reg18:IRCONVEND: IR CONVERT END COUNT
    	5999,
    	//Reg19:AMBIRCONVSTART: IR AMBIENT CONVERT START COUNT
    	6002,
    	//Reg20:AMBIRCONVEND: IR AMBIENT CONVERT END COUNT
    	7999,
    	//Reg21:ADCRESETSTCOUNT0: ADC RESET 0 START COUNT
    	0,
    	//Reg22:ADCRESETENDCOUNT0: ADC RESET 0 END COUNT
    	0,
    	//Reg23:ADCRESETSTCOUNT1: ADC RESET 1 START COUNT
    	2000,
    	//Reg24:ADCRESETENDCOUNT1: ADC RESET 1 END COUNT
    	2000,
    	//Reg25:ADCRESETENDCOUNT2: ADC RESET 2 START COUNT
    	4000,
    	//Reg26:ADCRESETENDCOUNT2: ADC RESET 2 END COUNT
    	4000,
    	//Reg27:ADCRESETENDCOUNT3: ADC RESET 3 START COUNT
    	6000,
    	//Reg28:ADCRESETENDCOUNT3: ADC RESET 3 END COUNT
    	6000,
    	//Reg29:PRPCOUNT: PULSE REPETITION PERIOD COUNT
    	7999,
    	//Reg30:CONTROL1: CONTROL REGISTER 1
    	0x0101,  //timer enabled, averages=3, RED and IR LED pulse ON PD_ALM AND LED_ALM pins
    	//Reg31:?: ??
    	0x00000,
    	//Reg32:TIAGAIN: TRANS IMPEDANCE AMPLIFIER GAIN SETTING REGISTER
    	0x00000,
    	//Reg33:TIA_AMB_GAIN: TRANS IMPEDANCE AAMPLIFIER AND AMBIENT CANELLATION STAGE GAIN
    	0x00000,
    	 //Reg34:LEDCNTRL: LED CONTROL REGISTER
    	0x11414,
    	//Reg35:CONTROL2: CONTROL REGISTER 2
    	0x00400, //bit 9
    	
    //        0x0,
            //Reg36:?: ??
    	0x00000,
    	//Reg37:?: ??
    	0x00000,
    	//Reg38:?: ??
    	0x00000,
    	 //Reg39:?: ??
    	0x00000,
    	 //Reg40:: ??
    	0x00000,
    	//Reg41:ALARM: ??
    	0x00000,
    	//Reg42:REDVALUE: RED DIGITAL SAMPLE VALUE
    	0x00000,
    	//Reg43:AMBREDVALUE: Ambient RED Digital Sample Value
    	0x00000,
    	//Reg44:IRVALUE: IR Digital Sample Value
    	0x00000,
    	//Reg45:AMBIRVALUE: Ambient IR Digital Sample Value
    	0x00000,
    	//Reg46:RED-AMBREDVALUE: RED-AMBIENT RED DIGITAL SAMPLE VALUE
    	0x00000,
    	//Reg47:IR-AMBIRVALUE: IR-AMBIENT IR DIGITAL SAMPLE VALUE
    	0x00000,
    	 //Reg48:DIGNOSTICS: DIAGNOSTICS FLAGS REGISTER
    	0x00000
    };
    
    /**************************Function declarations*******************************/
    
    unsigned int reg_Write_afe4490(unsigned int address);
    unsigned int reg_read_afe4490(unsigned int address);
    void AFE4490_Init(void);
    void SPI_Init(void);
    void delay(void);
    void gpio_init(void);
    
    /*******************************Function definitions****************************/
    void delay()
    {
      unsigned int i, n;
      for(i=0;i<32000;i++)
      {
        for(n=0;n<320;n++)
        {
          asm("nop");
        }
      }
    }
    
    
    unsigned int reg_read_afe4490(unsigned int address){
       int data[4],i;
      unsigned int dataout,only_data,address1[4];
      address1[0] = address & 0xff000000;
      address1[0] = address1[0]>>24;
      address1[1]= address & 0x00000000;
      address1[1] = address1[1]>>16;
      address1[2] = address & 0x0000ff00;
      address1[2] = address1[2]>>8;
      address1[3] = address & 0x000000ff;
      for(i=0;i<12339;i++);
      
      for(i=0;i<3;i++){
        SPI0_PUSHR = (SPI_PUSHR_TXDATA(address1[i]) |
                      SPI_PUSHR_CONT_MASK | 
                      SPI_PUSHR_PCS(0x3F) | 
                      SPI_PUSHR_CTAS(0x00));
        // write a single byte to the output FIFO - assert CS line
      while (!(SPI0_SR & SPI_SR_RFDF_MASK)) {} // wait for byte to be sent and a byte to be read in
    
      SPI0_SR |= SPI_SR_RFDF_MASK; // clear the reception flag (not self-clearing)
        data[i] = SPI0_POPR;
      }
      SPI0_PUSHR = SPI_PUSHR_TXDATA(address1[3]) |
                      (SPI_PUSHR_CONT_MASK&0x00) | 
                      SPI_PUSHR_PCS(0x3F) | 
                      SPI_PUSHR_CTAS(0x00)|
                        SPI_PUSHR_EOQ_MASK;
        // write a single byte to the output FIFO - assert CS line
      while (!(SPI0_SR & SPI_SR_RFDF_MASK)) {} // wait for byte to be sent and a byte to be read in
      SPI0_SR |= SPI_SR_RFDF_MASK; // clear the reception flag (not self-clearing)
      data[3] = SPI0_POPR;
     
      dataout = (((data[0]<<24) & 0xff000000)|((data[1]<<16)&0x00ff0000))|((data[2]<<8)&0x0000ff00)|(data[3] &0x000000ff);
      only_data = dataout & 0x000fffff;   
      return only_data; 
      
    }
    
    unsigned int reg_Write_afe4490(unsigned int address){
       int data[4],i;
      unsigned int dataout,only_data,address1[4];
      address1[0] = (address & 0xff000000);;
      address1[0] = address1[0]>>24;
    
      address1[1]=address & 0x00ff0000;
      address1[1] = address1[1]>>16;
      address1[2] = address & 0x0000ff00;
      address1[2] = address1[2]>>8;
    
      address1[3]= address & 0x000000ff;
      for(i=0;i<12339;i++);
      
      for(i=0;i<3;i++){
        SPI0_PUSHR = (SPI_PUSHR_TXDATA(address1[i]) |
                      SPI_PUSHR_CONT_MASK | 
                      SPI_PUSHR_PCS(0x3F) | 
                      SPI_PUSHR_CTAS(0x00));
        // write a single byte to the output FIFO - assert CS line
        while (!(SPI0_SR & SPI_SR_TCF_MASK)) {} // wait for byte to be sent and a byte to be read in
        SPI0_SR |= SPI_SR_TCF_MASK; // clear the reception flag (not self-clearing)
        data[i] = SPI0_POPR;
      }
      SPI0_PUSHR = SPI_PUSHR_TXDATA(address1[3]) |
                      (SPI_PUSHR_CONT_MASK&0x00) | 
                      SPI_PUSHR_PCS(0x3F) | 
                      SPI_PUSHR_CTAS(0x00)|
                        SPI_PUSHR_EOQ_MASK;
        // write a single byte to the output FIFO - assert CS line
      while (!(SPI0_SR & SPI_SR_TCF_MASK)) {} // wait for byte to be sent and a byte to be read in
      SPI0_SR |= SPI_SR_TCF_MASK; // clear the reception flag (not self-clearing)
      
      data[3] = SPI0_POPR;
      dataout = (((data[0]<<24) & 0xff000000)|((data[1]<<16)&0x00ff0000))|((data[2]<<8)&0x0000ff00)|(data[3] &0x000000ff);     
      return dataout;  
    }
    
    void gpio_init()
    {
      //Set PTC5 and PTC13 (connected to SW1 and SW2) for GPIO functionality, falling IRQ,
      //   and to use internal pull-ups. (pin defaults to input state)
      //Set PTC7, PTC8(connected to LED's) for GPIO functionality
      PORTE_PCR3 = PORT_PCR_MUX(1);
      GPIOE_PDDR = GPIO_PDDR_PDD(GPIO_PIN(3));
      GPIOE_PDOR = GPIO_PDOR_PDO(GPIO_PIN(3)); 
    }
    
    
    
    void AFE4490_Init(void){
      unsigned int diag_data,address,total_data,reg_data;
      int Reg_Init_i;
      reg_Write_afe4490(0x00000008);//Applying software reset to initialize
                            //registers to default state 
      reg_Write_afe4490(0x00000005);//diagnostic mode enable; read reg enable, software reset bit set
      diag_data = reg_read_afe4490(0x30000000);
      printf("diagnosis: %x\n",diag_data);
      reg_Write_afe4490(0x00000000);
    
      for ( Reg_Init_i = 0; Reg_Init_i < 49; Reg_Init_i++)
      {
        address = ((Reg_Init_i&0x000000ff) <<24);//|0x80000000;
        total_data = 0x00ffffff& AFE44xx_Default_Register_Settings[Reg_Init_i];
        total_data|= address;
        reg_Write_afe4490(total_data);    
      } 
    }
    
    
    void SPI_Init(void){
      SIM_SCGC6 |=SIM_SCGC6_DSPI0_MASK; //to give the clock to the system; SCG6 is for SPI and the 12th bit.
      PORTD_PCR0 |= PORT_PCR_MUX(2);
      PORTD_PCR1 |= PORT_PCR_MUX(2);
      PORTD_PCR2 |= PORT_PCR_MUX(2);
      PORTD_PCR3 |= PORT_PCR_MUX(2);  
      PORTC_PCR2 |= PORT_PCR_MUX(2);
      
      SPI0_MCR = SPI_MCR_MSTR_MASK | 
                  SPI_MCR_DCONF(0x00) | 
                    SPI_MCR_CLR_RXF_MASK | 
                    SPI_MCR_CLR_TXF_MASK |
                    SPI_MCR_PCSIS(0x3F)| 
                    SPI_MCR_HALT_MASK | //halts transfers
                   (SPI_MCR_MDIS_MASK & 0x00);//|//| //enables module clocks
                   // SPI_MCR_CONT_SCKE_MASK; //continuous clock              
                    
                    
      SPI0_CTAR0 = ((SPI_CTAR_DBR_MASK & 0x00)) | 
                      SPI_CTAR_FMSZ(0x07) |
                        SPI_CTAR_PDT(0x00) |
                        SPI_CTAR_BR(0x03) | 
                        (SPI_CTAR_CPHA_MASK&0) |
                          SPI_CTAR_PBR(0x00)|
                        (SPI_CTAR_CPOL_MASK&0);
      
      SPI0_MCR &= 0xfffffffe ; //start transfers again
    }
    
    
    /************************** Main Function *************************************/
    
    void main(void){
      int i,j,k,Reg_Init_i ;
      unsigned int data1,address,total_data,reg_data[49];
      j=0;
      SPI_Init(); 
      delay();
      printf("Initialized SPI lines...\n");
      
      AFE4490_Init();  
      delay();
      printf("Initialized AFE4490...\n");
    
      printf("Starting send of data...\n");
      
      reg_Write_afe4490(0x00000001);
      for ( Reg_Init_i = 1; Reg_Init_i < 49; Reg_Init_i++){
        address = ((Reg_Init_i&0x000000ff) <<24);//|0x80000000;
        total_data = 0x00ffffff& AFE44xx_Default_Register_Settings[Reg_Init_i];
        total_data|= address;
        reg_data[Reg_Init_i]=reg_read_afe4490(total_data);    
        printf("%x:%x\n",total_data,reg_data[Reg_Init_i]);
      } 
        reg_Write_afe4490(0x00000005); //enter diagnostic mode and enable read
    
      while (i<9900){
        data_afe4490[i] = reg_read_afe4490(0x30000000);
        if (data_afe4490[i] !=0)
          printf("%x\n",data_afe4490[i]);
    //    i++;
      }
      
      printf("PPG data...\n");
      for(i=0;i<9900;i++)
        printf("%x\n",data_afe4490[i]);
      delay();
    } 

    Hello, thanks for your response.

    I have two AFE4490s , both of which I have removed the 0 ohm resistors. The resistors I removed are as Mr. Praveen mentioned in this post :
    e2e.ti.com/.../1331211

    Or in short, R25,R26,R29,R31,R33,R35,R42 (however the connections of the pins mentioned in that post seem to be wrong. I have followed the pin out as shown in the datasheet)

    Both of them are connected to a K53 evaluation board with the same code running on it. I have confirmed that SPI for AFE4490 requires an active high clock. (clock polarity = 0). The code that I use is attached.



    I soldered the SPI CLK, MOSI, MISO, STE, AFE_PDNZ, AFE_RESET and ADC_RDY pins onto the board.

    As for ADC_RDY pulses, I do not get them properly even while using the GUI that comes when the communication happens with the MSP430 microcontroller. It is coming in short bursts of three pulses even with the GUI. I have detailed my problem with this in :
    e2e.ti.com/.../422038

    We did an extensive debugging to confirm the following things :
    Let there be two boards, A and B. The setup of A is such that the 0 ohm resistors are in place -thus communication with MSP430is enabled on (A). B is setup for SPI communication with K53.
    1) On running the diagnostic enable on the GUI for board A which is
    2) The SPI lines are working fine - we connected the MSP430 MISO, MOSI, STE and SCLK lines of A (we desoldered the 0 ohm resistors and connected the lines from the MSP side) to the SCLK, MOSI, MISO and SCLK into the AFE4490 chip of B. The LED glowed. Thus the SPI lines are fine.
    3) Board A's AFE4490 chip works fine, as confirmed with the GUI. Board B's afe4490 chip also works fine, as confirmed through the SPI lines of board A's MSP430.
    4) The grounds of the K53 and the board is common and are actually shorted. AFE_PDNZ and RESET are both pulled high.
    5) The code for SPi communication, the basic initialization, works fine with another AFE (ADAS1000SDZ). The initialization was taken from the sample code for MSP430 and has worked with SPI on the K53 on this particular board (board B) before, to glow the LED and even to get a PPG waveform.

    Any help will be much appreciated.
    Regards,
    Samyukta

  • Hello,
    I also wanted to ask, if there is any register that has a default value that I can read without having to make any other configuration, to see whether the communication is happening properly or not. For example, I have been checking the diagnostics register after removing the LED and PD DB9 connector to see if I read back 1E20. But before I do that, I need to go into diagnostics mode and enable read (correct me if I am wrong).

    Also, I wanted to ask if it is necessary to enable diagnostics mode for every read of the diagnostics register, or if one enable and then multiple reads is fine. I ask because on a setup where I do get 1E20 on removin the probe, I do not read 0 on replacing the probe while the code is running in an infinite while loop, in which I continuously read the diagnostics register.

    Also, the datasheet shows the control0 registers last 4 bits as : D3: Software reset    D2: diagnostic mode    D1: Time counter reset      D0: SPI read/write bit 

    In accordance with this, I've written to address 0x00 in sequence 0x08 (software reset), 0x05 (enter diagnostic mode and enable read) and then before I write to the registers, I again write 0x00 to address 0x00. This, however, is giving me unpredicable behaviour (LED dims, I remove ground and it glows brightly again).

    Can you confirm that this is the correct sequence? 


    As a final question, I wanted to confirm that I need to give a common ground between the microcontroller and the AFE4490Spo2EVM board. I ask because in a code, when I have given common ground, the LED starts glowing, and then dims down. On removing the ground pin, the LED starts glowing brightly and constantly, and doesn't dim.
    Regards,
    Samyukta