cancel
Showing results for 
Search instead for 
Did you mean: 

I have problem with my spi. Its not give me a constant answer with the same code.

KDeli.1
Associate II

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?

4 REPLIES 4

How long does it take to come out of reset?

How long does it expect CS/NSS to be low before the clock starts?

I'd probably use HAL_SPI_Transmit_Receive, but that's me..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

Are you driving RSTn in push-pull or open-drain mode?

RSTn should never be driven high by an external source.

I'd give it at least a few ms after reset before trying to send data.

If you feel a post has answered your question, please click "Accept as Solution".

Hello, my RST it was open-drain but i turn to push-pull.

I'd try with a delay after the reset but i take the same behavior.

ok thank you, i will try the HAL_SPI_Transmit_Receive!!!