Skip to content

Why DM1000/DWM1000 is not functioning when other devices on the same SPI bus #1

Description

@wjxway

I'm using IMU (BNO08x) together with DWM1000 on the same SPI bus on ESP32-S3. When using only one of them, they worked out fine, but when using both together, none of them worked. DWM1000 will very frequently report RXOK-TXCONF-RXTO-RXERR in series while TXCONF shouldn't be initiated yet.

Solution: TXCONF-RXTO-RXERR shall not trigger at the same time, so after days of diagnosis, I figured that this is because in dwt_ISR() it checks for all interrupt types based on the SYS_STATUS_ID register. However, DW1000's SPI bus is not the most tolerant type: if the polarity of SCLK is flipped at the beginning of the transaction after CS is pulled low, it will not respond to the message, returning 0xFFFFFFFF for status. This will trigger all the interrupts in order. A walk-around already implemented in the code is adding a redundant read immediately after acquiring SPI bus:

// Add a idle read here to allow SPI to switch to the right mode.
// for ESP32, mode switching occurs at the start of transaction
// and this moment will be later than CS pulling low.
// Thus the first reading will be invalid.
// add this to ensure that the next useful spi reading is valid.
dwt_read32bitreg(SYS_STATUS_ID);

As long as you acquire bus using decamutexon() before doing anything, you are good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions