Thanks Zoran. I think I wait enough time. Here is the code that sleeps the dw1000 and then awakens it.
} else if (to_sleep) {
to_sleep = false;
dwt_entersleep();
HAL_Delay(myTag.link_sleep_ms);
awake_SPI();
}
The code for awakening the dw1000 is:
void awake_SPI(void){
HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_RESET);
usleep(600);
HAL_GPIO_WritePin(DW_NSS_GPIO_Port, DW_NSS_Pin, GPIO_PIN_SET);
while (! (HAL_GPIO_ReadPin(DW_RESET_GPIO_Port, DW_RESET_Pin)) );
usleep(300);
dwt_spicswakeup(dummy_buffer, DUMMY_BUFFER_LEN);
}
I pull down SPI_CS pin for 600 us. Then I wait to RST pin to be high. Then I wait again for 300 us.
Then I use dwt_spicswakeup with a 1500 bytes buffer (18MBits/8 x 667 us = 1500 bytes. I use here the dwt_spicswakeup, because if I use directly this function I get a HardFault error in HAL_SPI_TransmitReceive (called from readfromspi()). I’ using CubeMX with a STM32F103C8, but I’m moving to a STM32L432. Nevertheless these problems are with the STM32F103.
With this code and debugging step by step (so the time from RST up is very big) I still get CLOCK_PLL error the next time I RX instead of Timeout.
Is there anything regarding sleep and waking up the dw1000 I’m not aware of?
Is there a problem with HAL library?
Thanks for your help