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.

TUSS4470: Help Needed: Issues Initializing TUSS4470 with STM32

Part Number: TUSS4470
Other Parts Discussed in Thread: TDC1000, ENERGIA

Tool/software:

Hi everyone,

I’m working on a project using the STM32F103RBT6 to interface with the TUSS4470. However, I’ve encountered several issues during the initialization process:

  1. Unexpected Reset Values: The register values I read after powering on do not match the reset values specified in the TUSS4470 datasheet.
  2. Write/Read Inconsistency: When I try to write to a register and read it back, the value does not update as expected.
  3. Abnormal SDO Feedback: After writing to a register, the feedback on the SDO line appears incorrect.

Additional Notes:

  • I’m using a custom-designed circuit board that I assembled using SMT (surface mount technology). I’ve tested two separate PCBs, and both show the same issues.
  • My development environment is IAR Embedded Workbench 8.32.1.

Below is the code snippet I am using for initialization and SPI communication. Comments are included for clarity:

#include "TUSS4470.h"

uint16_t init_check_buffer[13] = {0};
uint16_t write_back[13] = {0};

static uint8_t calculateParity(uint8_t txbuffer[]);

void TUSS4470_init()
{
    TUSS4470_Write_Register(BPF_CONFIG_1, 0x0, &write_back[0]);
    TUSS4470_Write_Register(BPF_CONFIG_2, 0x0, &write_back[1]);
    TUSS4470_Write_Register(DEV_CTRL_1, 0x0, &write_back[2]);
    TUSS4470_Write_Register(DEV_CTRL_2, 0x0, &write_back[3]);
    TUSS4470_Write_Register(DEV_CTRL_3, 0x0, &write_back[4]);
    TUSS4470_Write_Register(VDRV_CTRL, 0x20, &write_back[5]);
    TUSS4470_Write_Register(ECHO_INT_CONFIG, 0x7, &write_back[6]);
    TUSS4470_Write_Register(ZC_CONFIG, 0x14, &write_back[7]);
    TUSS4470_Write_Register(BURST_PULSE, 0x1, &write_back[8]);
    TUSS4470_Write_Register(TOF_CONFIG, 0x0, &write_back[9]);
    TUSS4470_Write_Register(DEV_STAT, 0x0, &write_back[10]);
    TUSS4470_Write_Register(DEVICE_ID, 0xB9, &write_back[11]);
    TUSS4470_Write_Register(REV_ID, 0x2, &write_back[12]);

    HAL_Delay(500);
    TUSS4470_Read_Register(BPF_CONFIG_1, &init_check_buffer[0]);
    TUSS4470_Read_Register(BPF_CONFIG_2, &init_check_buffer[1]);
    TUSS4470_Read_Register(DEV_CTRL_1, &init_check_buffer[2]);
    TUSS4470_Read_Register(DEV_CTRL_2, &init_check_buffer[3]);
    TUSS4470_Read_Register(DEV_CTRL_3, &init_check_buffer[4]);
    TUSS4470_Read_Register(VDRV_CTRL, &init_check_buffer[5]);
    TUSS4470_Read_Register(ECHO_INT_CONFIG, &init_check_buffer[6]);
    TUSS4470_Read_Register(ZC_CONFIG, &init_check_buffer[7]);
    TUSS4470_Read_Register(BURST_PULSE, &init_check_buffer[8]);
    TUSS4470_Read_Register(TOF_CONFIG, &init_check_buffer[9]);
    TUSS4470_Read_Register(DEV_STAT, &init_check_buffer[10]);
    TUSS4470_Read_Register(DEVICE_ID, &init_check_buffer[11]);
    TUSS4470_Read_Register(REV_ID, &init_check_buffer[12]);
}

void TUSS4470_Read_Register(uint8_t regAddr, uint16_t *data)
{
    uint8_t txbuffer[2] = {0}; // SPI transmit buffer
    uint8_t rxbuffer[2] = {0}; // SPI receive buffer

    txbuffer[0] = 0x80 + ((regAddr & 0x3F) << 1); // High byte: RW bit + address bits
    txbuffer[1] = 0x00;                           // Low byte: always 0
    txbuffer[0] |= calculateParity(txbuffer);     // Add parity bit

    TUSS4470_CSN_LOW(); // Pull chip select low
    HAL_Delay(500);
    HAL_SPI_TransmitReceive(&hspi1, txbuffer, rxbuffer, 2, HAL_MAX_DELAY);
    HAL_Delay(500);
    TUSS4470_CSN_HIGH(); // Pull chip select high

    *data = (rxbuffer[0] << 8) | rxbuffer[1]; // Combine received bytes
}

void TUSS4470_Write_Register(uint8_t regAddr, uint8_t data, uint16_t *write_back)
{
    uint8_t txbuffer[2] = {0}; // SPI transmit buffer
    uint8_t rxbuffer[2] = {0}; // SPI receive buffer

    txbuffer[0] = (regAddr & 0x3F) << 1;      // High byte: address bits
    txbuffer[1] = data;                       // Low byte: data
    txbuffer[0] |= calculateParity(txbuffer); // Add parity bit

    TUSS4470_CSN_LOW(); // Pull chip select low
    HAL_Delay(500);
    HAL_SPI_TransmitReceive(&hspi1, txbuffer, rxbuffer, 2, HAL_MAX_DELAY);
    HAL_Delay(500);
    TUSS4470_CSN_HIGH(); // Pull chip select high

    *write_back = (rxbuffer[0] << 8) | rxbuffer[1]; // Combine received bytes
}

static uint8_t calculateParity(uint8_t txbuffer[])
{
    uint8_t parity = 0;
    for (int i = 0; i < 2; i++)
    {
        uint8_t byte = txbuffer[i];
        while (byte)
        {
            parity ^= (byte & 1);
            byte >>= 1;
        }
    }
    return parity; // Return calculated parity bit
}

  • This is my schematic, I expect to use a 1MHz piezoelectric ceramic.

  • After a day of effort, I have resolved part of the issues. The initial problem was caused by the SPI speed being too fast.

    However, I’ve now encountered the following issues:

    1. The EE_CRC_FLT bit is always set to 1, indicating a "CRC error for internal memory."
    2. The VDRV voltage is consistently fluctuating around 2.5V, and the chip remains in standby mode.

    I tried increasing the capacitance on the VDRV pin or replacing it with an electrolytic capacitor, but this did not resolve the issue.

    Does anyone have insights or suggestions on how to address these problems?

    The newest code is below:

    void TUSS4470_init()
    {
        TUSS4470_Write_Register(VDRV_CTRL, 0x10, &write_back[5]);
        TUSS4470_Write_Register(BPF_CONFIG_1, 0x5F, &write_back[0]);
        // TUSS4470_Write_Register(BPF_CONFIG_2, 0x0, &write_back[1]);
        // TUSS4470_Write_Register(DEV_CTRL_1, 0x0, &write_back[2]);
        // TUSS4470_Write_Register(DEV_CTRL_2, 0x0, &write_back[3]);
        TUSS4470_Write_Register(DEV_CTRL_3, 0x1D, &write_back[4]);
    
        TUSS4470_Write_Register(ECHO_INT_CONFIG, 0x10, &write_back[6]);
        // TUSS4470_Write_Register(ZC_CONFIG, 0x14, &write_back[7]);
        TUSS4470_Write_Register(BURST_PULSE, 0x4, &write_back[8]);
        // TUSS4470_Write_Register(DEV_STAT, 0x0, &write_back[10]);
        // TUSS4470_Write_Register(DEVICE_ID, 0xB9, &write_back[11]);
        // TUSS4470_Write_Register(REV_ID, 0x2, &write_back[12]);
    
        TUSS4470_Write_Register(TOF_CONFIG, 0x40, &write_back[9]);
        HAL_Delay(100);
        TUSS4470_Write_Register(TOF_CONFIG, 0x00, &write_back[9]);
        HAL_Delay(100);
        // TUSS4470_Write_Register(TOF_CONFIG, 0x01, &write_back[9]);
        // HAL_Delay(100);
        // TUSS4470_Write_Register(TOF_CONFIG, 0x00, &write_back[9]);
        // HAL_Delay(100);
    
        TUSS4470_Read_Register(BPF_CONFIG_1, &init_check_buffer[0]);
        TUSS4470_Read_Register(BPF_CONFIG_2, &init_check_buffer[1]);
        TUSS4470_Read_Register(DEV_CTRL_1, &init_check_buffer[2]);
        TUSS4470_Read_Register(DEV_CTRL_2, &init_check_buffer[3]);
        TUSS4470_Read_Register(DEV_CTRL_3, &init_check_buffer[4]);
        TUSS4470_Read_Register(VDRV_CTRL, &init_check_buffer[5]);
        TUSS4470_Read_Register(ECHO_INT_CONFIG, &init_check_buffer[6]);
        TUSS4470_Read_Register(ZC_CONFIG, &init_check_buffer[7]);
        TUSS4470_Read_Register(BURST_PULSE, &init_check_buffer[8]);
        TUSS4470_Read_Register(TOF_CONFIG, &init_check_buffer[9]);
        TUSS4470_Read_Register(DEV_STAT, &init_check_buffer[10]);
        TUSS4470_Read_Register(DEVICE_ID, &init_check_buffer[11]);
        TUSS4470_Read_Register(REV_ID, &init_check_buffer[12]);
    };

  • Hi Junhao,

    Thanks for posting to the sensors forum and welcome to E2E!

    Our ultrasonic experts are currently out of office due to the holidays, they will get back to you once they return.

    We appreciate your patience.

    Best regards,

    Jesse

  • Hi Jesse,

    Thanks for your reply!

    Now I’ve discovered that the current VDRV voltage is directly linked to the VDD voltage, with a difference of approximately 0.7V between them. Adjusting VPWR has no effect on VDRV.

    Even when I adjust the VDD voltage so that VDRV exceeds 5V, the TUSS4470 still cannot exit standby mode.

    Any suggestions or insights into what might be causing this behavior would be greatly appreciated!

  • Hi Junhao,

    Thanks for the update. An ultrasonic sensing expert should be able to review the information and provide feedback early next week. 

    Best regards,

    Jesse

  • Hi Junhao,

    To help confirm whether or not the TUSS4470 is in standby mode vs listening mode, are you able to measure the current consumption (CC) at VDD? If in standby mode, the CC would be around 1.5mA. If the CC is around 11.5mA, then you can confirm that the device is in listening mode.

    Best,

    ~Alicia

  • Hi Alicia,

    The CC is around 1mA.

  • Hi Alicia,

    Thank you for your previous response. I followed your suggestion and measured the current consumption (CC) at VDD. The result shows that the CC is around 1or2mA, which seems to confirm that the chip is in standby mode.

    I wanted to confirm if this aligns with your expectations or if there’s anything else I should check to further validate the mode status. Looking forward to your guidance!

    Best regards,
    Junhao

  • Hi Junhao,

    Just out of curiosity, is there a reason that you are configuring the device to be in standby mode? Also, when configuring the command to exit standby mode, could you try sending the command twice just in case there is some issue with the first command.

    To further help with this, are you able to send a capture of the SPI communication using a logic analyzer?

    Best,

    ~Alicia

  • Hi Alicia,

    Thank you for your response and suggestions. I truly appreciate your input regarding the SPI communication and will try capturing it using a logic analyzer as you suggested. I’ll provide feedback as soon as possible.

    Regarding the current issue, I want to clarify that my intention is to exit the standby mode and allow the chip to function normally. Based on the attached image, I believe the commands I sent to the chip were received correctly. However, I suspect the problem might be related to the VDRV pin. It seems that the voltage level on VDRV cannot reach the required level, which might be preventing the chip from exiting the standby state.

    Additionally, I noticed that the EE_CRC_FLT register indicates a CRC error. I couldn’t find detailed information about whether this CRC error would affect the chip’s operation or how to resolve it in the datasheet or other forum posts. Could you provide more insights on this matter?

    Looking forward to your advice!

    Best regards,
    Junhao

  • Hi Junhao,

    The CRC error indicates that there was some kind of issue when loading the device's internal EEPROM memory. Do you have another TUSS4470 device that you could use in place of this one, just in case the device that you are currently using has some kind of issue?

    I was able to use the settings from your initialization function to successfully enter and exit standby mode using the TUSS4470EVM and GUI.

    Best,

    ~Alicia 

  • Hi Alicia,

    Thank you for your response and assistance earlier. I wanted to update you that I have identified the issue—it was related to the PCB manufacturing process. After using a circuit board from another PCB manufacturer, the chip is now functioning correctly.

    Thank you again for your support!

    Best regards,
    Junhao

  • Hi Junhao,

    I'm glad you were able to figure out the issue!

    Best,

    ~Alicia

  • Hi Alicia,

    Thank you for your kind words! Now that the issue is resolved, I’m planning to use the TUSS4470 with a 1MHz sensor for liquid level monitoring. While I noticed related examples in the application manual, they seem to rely on the GUI for development, and there aren’t any firmware configurations specifically for 1MHz operation with the TUSS4470 (the provided configurations are for TUSS4470 at 220kHz and TDC1000).

    I was wondering if there’s any chance you could provide firmware configurations for this scenario? Also, does the official GUI include any additional signal processing functions? If so, could you share some insights about those to help guide my development process?

    Looking forward to hearing your advice!

    Best regards,
    Junhao

  • Hi Junhao,

    We do have code examples via the Energia Library that can be referenced as you are developing your firmware: https://www.ti.com/tool/download/SLDC023 

    Best,

    ~Alicia