Post Go back to editing

Can't read Prod ID on Esp32S3

Category: Software
Product Number: ADIS16505-3
Software Version: Latest

Hi all,

Hardware:

adis16505-3

Esp32-S3-wroom-2

Issue:

I'm running into trouble trying to read the Prod Id I'm just getting all 0's out. I have the IMU on the SPI2 pins and set up the SPI channel at 1MHz. I initially created the SPI cmd as described in the data sheet as:

uint16_t tx_data = (0 << 15) | (reg_addr << 8 );

But I noticed on the scope that the DIN line seemed to be shifted to the right, see the second picture against the 3rd picture.

I tried switching it to

uint16_t tx_data = reg_addr;

not shifting it at all and that produced a scope perfectly resembling the data sheets example, see the last picture.

Code:

Reading register : 0x72

SPI Config:

    spi_bus_config_t buscfg = {

        .miso_io_num = PIN_NUM_MISO,

        .mosi_io_num = PIN_NUM_MOSI,

        .sclk_io_num = PIN_NUM_CLK,

        .quadwp_io_num = -1,

        .quadhd_io_num = -1,

        .max_transfer_sz = 4 * 1024

    };

    spi_device_interface_config_t devcfg = {

        .clock_speed_hz = 1 * 1000 * 1000, // 1 MHz to meet timing requirements

        .mode = 3,                         // SPI mode 3 (CPOL=1, CPHA=1)

        .spics_io_num = PIN_NUM_CS,

        .cs_ena_pretrans = 8,              // Ensure CS is activated 8 SPI clock cycles before transmission

        .cs_ena_posttrans = 8,             // Ensure CS stays active 8 SPI clock cycles after transmission

        .input_delay_ns = 25,              // Based on tDAV and tDSU requirements (typical 25 ns)

        .queue_size = 3

    };

Reading attempt:

esp_err_t imu_read_register(spi_device_handle_t spi, uint8_t reg_addr, uint16_t *data) {

    uint16_t tx_data = (0 << 15) | (reg_addr << 8); // Read command (0), followed by the 7-bit address and 8 don't care bits

    uint8_t rx_buffer[2] = {0x00, 0x00};

    spi_transaction_t t;

    memset(&t, 0, sizeof(t));

    t.length = 16;            // 16 bits for the transaction

    t.tx_buffer = &tx_data;

    t.rxlength = 16;          // 16 bits to read

    t.rx_buffer = rx_buffer;

    esp_err_t ret = spi_device_transmit(spi, &t);

    if (ret == ESP_OK) {

        *data = (rx_buffer[0] << 8) | rx_buffer[1];

        ESP_LOGI(TAG, "Read from register 0x%02X: 0x%04X", reg_addr, *data);

    } else {

        ESP_LOGE(TAG, "Failed to read register 0x%02X: %s", reg_addr, esp_err_to_name(ret));

    }

    return ret;

}


I only have a 2 channel scope so forgive the fragmentation of this snippets.

CS over SCLK

SCLK over DIN : Here you can see DIN is shifted to the right of what it should be


Data sheet example



SCLK over DIN: Shifted to the left matching the data sheet

No matter what I try though I always get 0's from DOUT.

Are there any examples using the espressif toolchain I could reference?

*Separate question: I looked at the analog GitHub and it has a driver library for the 164X, I was wondering if there's an updated one for the 16505 available?

Best Regards,

Wade