Delay between SPI clock and Data bytes in Zephyr nRF52832 - spi_transceive_dt()

Hello Everyone,

I  have configured SPI1 at 1MHz, to receive data with a sensor. Basically i am reading data from a sensor device. So calling spi_transceive_dt() with 4 Tx byte and 4 Rx bytes (Initially tried with 3 Tx bytes and 3 Rx bytes as sensor outputs 24 bits of data). I am able to receive the data as well correctly, but while checking the waveform of MISO and SCK pin i observed that there is a big gap of 14-15us in the clock signal and clock is not continuous. I have attached tha waveform as well, we can seee that clock is flat for 14-15 us. As per my understanding i am using the Tx and Rx buffer of 4 bytes so clock must be consistent for 32 pulses.

I am wondering if anyone have observed this kind of issue. 

Using Nrf52832, NCS version 2.9.0

Using following code to read the data.

    uint8_t tx_buffer[4] = {0xFF, 0xFF, 0xFF, 0xFF}; // Dummy data to generate clock pulses
    uint8_t rx_buffer[4] = {0};               // Buffer to store received data

    struct spi_buf tx_buf = {
        .buf = tx_buffer,
        .len = sizeof(tx_buffer),
    };
    struct spi_buf rx_buf = {
        .buf = rx_buffer,
        .len = sizeof(rx_buffer),
    };
    struct spi_buf_set tx_bufs = {
        .buffers = &tx_buf,
        .count = 1,
    };
    struct spi_buf_set rx_bufs = {
        .buffers = &rx_buf,
        .count = 1,
    };

    while (!ads1232_data_ready()) {
        k_msleep(1);
    }

    // spi_transceive_dt(spi_dev,);

    // Perform SPI transfer to read 3 bytes of data
    int ret = spi_transceive(spi_dev, &spi_cfg, &tx_bufs, &rx_bufs);
    if (ret < 0) {
        printk("SPI transfer failed: %d\n", ret);
        return ret;
    }

Best Regards,

Pradeep

Parents Reply Children
No Data
Related