Device ID (DW1000)

Hello, i try to program my dwm1000. I am new on that. At the first step i send 0x00 to take the ID verification (0xDECA1000) but its not constant at the same value. Some times is 0xDECA1000 with the same code. Some times i take 0xDC8A0330 or something like this.
(i have connected analysizer )
I use spi from stm32L4 series.

My code is:
uint8_t FID = 0x00;
uint8_t data[4];

HAL_Delay(1000);
HAL_GPIO_WritePin(DW_RESET_GPIO_Port, DW_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(DW_RESET_GPIO_Port, DW_RESET_Pin, GPIO_PIN_RESET);
HAL_Delay(100);
HAL_GPIO_WritePin(DW_RESET_GPIO_Port, DW_RESET_Pin, GPIO_PIN_SET);

HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_RESET );

HAL_SPI_Transmit(&hspi1, &FID, 1, 100);
HAL_SPI_Receive(&hspi1, data, 4, 100);

HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_SET );

Can anyone help me please?

Two things to look at:
SPI bus mode / timings - which clock edges the data is output and received on.
Signal integrity - if you are using a neat PCB then this probably won’t be an issue. If you are on a breadboard or anything with long wires / connections then this could be the issue.

1 Like

Hi Konstantinos

HAL_GPIO_WritePin(DW_RESET_GPIO_Port, DW_RESET_Pin, GPIO_PIN_SET);

Note that the DW1000 reset pin should not be pulled high with a low impedance / resistance. The DW1000 will pull this pin down on reset until the oscillator is stable. It is best to set this pin as input after reset and/or to configure it as open-drain output. See section 2.4 in the DW1000 User Manual.

Also note that after reset, the DW1000 will by default lock the PLL and switch to IDLE mode. On the DWM1000 this typically takes ~500μs (DEEPSLEEP to INIT) + 5μs (PLL lock), but it depends on the temperature. If a SPI operation takes place while PLL is locking, the SPI operation could get corrupted, see “INIT” state description in Table 1 of the DW1000 UM.

You might also want to check the return value of the SPI functions. Your use of a 100ms timeout should work for these small operations, but depending on the SPI speed the operations might time out.

Try this:

uint8_t FID = 0x00;
uint8_t data[4];

// Configure DW1000 reset pin as open drain output
GPIO_InitStruct.Pin = DW_RESET_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(DW_RESET_GPIO_Port, &GPIO_InitStruct);

// Pull the reset pin low for 1 ms
HAL_GPIO_WritePin(DW_RESET_GPIO_Port, DW_RESET_Pin, GPIO_PIN_RESET);
HAL_Delay(1);

// Configure DW1000 reset pin as input
GPIO_InitStruct.Pin = DW_RESET_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DW_RESET_GPIO_Port, &GPIO_InitStruct);

// Wait at least 505 μs (for DWM1000 v1). 5 ms is a very conservative, allowing to support slow clocks like TCXOs
// Note: for DWM1000 V2 at least 1000μs (1ms) should be used.
// You can also read the reset pin or enable the MSLP2INIT IRQ to detect the INIT state being reached
HAL_Delay(5);

HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_RESET );
// An additional wait might be needed here depending on parasitics and pin speed
// Assuming good wiring this is not needed.
if (HAL_SPI_Transmit(&hspi1, &FID, 1, 100) != HAL_OK)
{
    // handle error
}
if (HAL_SPI_Receive(&hspi1, data, 4, 100) != HAL_OK)
{
    // handle error
}

HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_SET );
1 Like

Hello, i fixed it.
Thank you very much for your help.

Good to hear. Do you mind sharing the solution so others could learn from it? Was the problem related to the SPI wiring?

Maybe my problem it was the analysizer.
So i use your part code to configure the RST pin and after i use the ready function of deca_API, dwt_readdevid.