DWM1000 timed sleep and delayed RX

Hello, good morning. I’m struggling with this piece of code, but I do not succeed. I want to calculate when the RX should be activated, set the dwt_delayedtxrx time, then put dw1000 in a timed sleep, and see how when the dw1000 is awake, the Rx should be activated. The code I make for testing is the following:

[code]uint64 start_ts;
uint32 rx_on_ts;

resucitaSPI();
reset_DW1000();
port_set_dw1000_slowrate();
if (dwt_initialise(DWT_LOADUCODE) == DWT_ERROR)
{
_Error_Handler(“Inicializacion” , 56);
}
link_sleep_cnt = 2;
dwt_configuresleepcnt(link_sleep_cnt);
port_set_dw1000_fastrate();
dwt_setlnapamode(1, 1);
dwt_configure(&config);
dwt_setrxantennadelay(RX_ANT_DLY);
dwt_settxantennadelay(TX_ANT_DLY);
dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_LOADOPSET | DWT_CONFIG, DWT_WAKE_SLPCNT | DWT_WAKE_CS | DWT_SLP_EN);

dwt_setrxtimeout(10000);
start_ts = get_rx_timestamp_u64();
dwt_rxenable(DWT_START_RX_IMMEDIATE);
rx_on_ts= (uint64) (start_ts + (1200000*63897.76358)) >> 8;
dwt_setdelayedtrxtime(resp_tx_time);
dwt_rxenable(DWT_START_RX_DELAYED);
HAL_Delay(100);
dwt_entersleep();
printf(“hola”);
while(1);[/code]
resucitaSPI is for waking up the dw1000. I set configuresleepcnt with the value 2 that gives around 650 ms of sleeping time. The sleep configuration is made with dwt_configuresleep.

When I run this code I observe the following:

A first RX is seen on the oscilloscope as a pulse of 10ms ([size=small][font=Monaco, Consolas, Courier, monospace]dwt_rxenable(DWT_START_RX_IMMEDIATE);)[/font][/size]

If I comment out the dwt_entersleep call, everything works as expected. After 1.2 seconds a new pulse corresponding to a RX event is seen (10 ms wide).

[size=small][font=Monaco, Consolas, Courier, monospace]rx_on_ts= (uint64) (start_ts + (1200000*63897.76358)) >> 8;[/font][/size] [size=small][font=Monaco, Consolas, Courier, monospace]dwt_setdelayedtrxtime(resp_tx_time);[/font][/size] [size=small][font=Monaco, Consolas, Courier, monospace]dwt_rxenable(DWT_START_RX_DELAYED);[/font][/size]

If the call to dwt_entersleep is made, then in the oscilloscope a fall is seen in the Reset line and the width of this fall is around the 650 ms expected, so the waking up mechanism is working fine as well, but in this case, the RX pulse is not seen at 1.2 seconds from the first pulse.

So, please, what I’m doing wrong? In a previous post Zoran told me that using wake_cnt should put the dw1000 in sleep mode (not deepsleep), so the clock would be running, but in this case it seems that the clock used to delay RX or TX is not working when sleeping.

Is this the expected behaviour? Should I have to make the whole timing in the MCU. If this is the case is a pity because the 40 bit clock of the dw1000 is very precise and it is very easy to make it work.

The TX/RX time that is used for delayed TX/RX is based on the PLL clock, so if you want to do delayed RX/TX then the DW1000 has to be in IDLE. You cannot put device into SLEEP - in SLEEP a different clock is used (based on internal LP oscillator)

Ok, thanks. So, I should make all the timing in the MCU so to save as much energy as possible. Thanks again.