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: SPI communication

Part Number: AFE4490
Other Parts Discussed in Thread: MSP430F5529

In SPI Interface, MOSI is working but MISO is not working. I also tried writing to a register (which is R/W) and reading the same via SPI interface. SPI write operation works successfully but at the same time, SPI read does not work. Through the code i tried these steps to check working of MISO:

 

1. Disable SPI_READ of CONTROL0.

2. Enable SW_RST, DIAG_EN 

3. Enable SPI_READ

4. Read DIAG register (address: 0x30)

5. Disable SPI_READ

But i could not read DIAG register. Please someone help me with this. 

  • Hi Sweety Bhaskare,

    Few points to be considered to debug this issue.
    1) How did you validate the SPI write being successful?
    2) Make sure all the supplies, RESETZ and AFE_PDN pins have proper voltages .
    3) While reading a register using SPI, please probe all the SPI pins and make sure that the waveform looks like figure 1 of the datasheet. You can also share with us to help debug this issue.
    4) I would suggest reading a normal register after the write instead of DIAG register as Diagnostics involves setting up the AFE with proper configuration.

    Regards,
    Prabin
  • Hello Prabin,
    Thank you so much for your help. I forgot to mention the details, apology for that. I'm working on AFE4490 Breakout from ProtoCentral. I've verified the board using Arduino code and could obtain the correct result.

    1. I've used TI reference code on the breakout board to validate SPI communication. I wrote the values in AFE register addresses from 0x01 to 0x29(which are both R/W registers), and the finger probe LEDs glow, this shows that the SPI write operation is successful.
    2. Yes, the voltages of both RESET and AFE_PDN are correct.
    3. Upon checking the SPI waveforms on oscilloscope, i found the same as shown in Figure 1 of Datasheet, except for SPI MISO.
    4. I also have tried reading from other registers, but as i mentioned previously, in vain.

    Please see to what else could be a barrier to my code! Thanking you in advance!
  • unsigned long read_result;
    void main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer

    Init_Ports(); // Initialization of MSP430F552x ports
    Set_GPIO();
    Set_UCB0_SPI();

    //AFE44xx_PowerOn_Init(); // NOTE: If this line is written here, then spo2 probe LED does not glow


    while(1)
    {

    AFE44xx_PowerOn_Init(); // In while loop this line works and spo2 probe LED glows
    Enable_AFE44x0_SPI_Read();

    read_result = AFE44x0_Reg_Read(LED2VAL);

    Disable_AFE44x0_SPI_Read();

    if(read_result != 0 )
    P4OUT |= BIT7; // if LED2VAL has some value, glow LED(P4.7) on MSP430F5529

    }

    }

    In the above code, spo2 probe LED glows continuously only if, after AFE44xx_PowerOn_Init(); SPI_READ operation is not performed. Else this above code results into blinking of spo2 probe LED.
  • Hi Sweety Bhaskare,

    Can you please share the for "Enable_AFE44x0_SPI_Read();"?

    Regards,
    Prabin
  • Hello Prabin,

     This is the code to enable SPI read! Please check and let me know. Thank you!

    void Enable_AFE44x0_SPI_Read(void)
    {
    // Set Control0 - Enable SPI Read bit(BIT0 SPI_read is set to enable read operation)

    unsigned char dummy_rx;

    P2OUT &= ~CS0; // Start of Transmission.

    UCA0TXBUF = 0; // Send Address of CONTROL0 register
    while ( (UCA0STAT & UCBUSY) ); // Is USCI_B0 TX buffer ready?
    dummy_rx = UCA0RXBUF;

    UCA0TXBUF = 0;
    while ( (UCA0STAT & UCBUSY) );
    dummy_rx = UCA0RXBUF;

    UCA0TXBUF = 0;
    while ( (UCA0STAT & UCBUSY) );
    dummy_rx = UCA0RXBUF;

    UCA0TXBUF = 1; // Set BIT0 of CONTROL0 register of AFE44x0
    while ( (UCA0STAT & UCBUSY) );
    dummy_rx = UCA0RXBUF;

    P2OUT |= CS0; // End of Transmission
    }

  • Hi Sweety Bhaskare,

    I see no obvious error in the c program.

    So I would suggest following techniques to debug this.
    1) Disconnect the MISO line from the MCU but still probe it in oscilloscope. This will rule out the possibility that MCU is loading the MISO lines.
    2) In there is no transition in the step 1, then remove the probe and check the presence of ESD diode in MISO pin of the AFE4490. This will help to confirm the connection of the MISO pin with the PCB's trace.

    Regards,
    Prabin
  • Hi Prabin,

    I have tested SPI communication over two different MSP430F5529, and the result was exactly as expected. And AFE4490 is also tested with Arduino Uno , here also SPI was working. So there should not be a problem arising with hardware. Do you have any other code that i can have a look at? Please do help!
    And i request you to please help me with the calculation part as well. Is it Reg: 0x2A and 0x2C whose averages give the DC values of Red and IR LEDs? And how would i be able to find ACrmsof the same?

    Thanking you in anticipation!
  • Hi Sweety Bhaskare,

    Fro the example code you can refer to the source code of the AFE4490EVM's firmware. The source code is written for MSP430F5529.
    Regarding the calculation, I have replied on your other thread.

    Regards,
    Prabin
  • Hey Prabin,
    Thank you for your response! But i still could reach nowhere in my code.
    Can you please tell me what specific registers of AFE4490 give the Probe LED highest intensity and how am i supposed to write the values of those? I've tried writing only LEDCNTRL which gave me no output.
  • Hi Sweety Bhaskare,

    The issue here is SPI communication between AFE4490 and your MCU.
    I saw the schematic of the Protocentral's breakout board for AFE4490 and found that they have Level shifter between AFE and the Arduino.
    Are you still using the level shifter? if yes, does the voltage level of the MCU's IO pin is same as AFE's pin?

    To increase the LED current you can use LEDCNTRL, LED_RANGE and TX_REF settings. You can refer to Table 6 of the datasheet for the relation between them.

    Regards,
    Prabin
  • Hey Prabin,
    I tried as you said. But still could not see any progress. When i interfaced my MCU with another MSP430f5529, it worked. But neither the of the codes for AFE4490 works on MCU(The one provided by TI and the one in which i just changed the SPI code leaving rest of the program as it is.
  • Hi Sweety Bhaskare,

    In that case we would like to observe(Analog) the SPI lines at the AFE4490 pins.

    Regards,
    Prabin