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:
if (dwt_initialise(DWT_LOADUCODE) == DWT_ERROR)
_Error_Handler(“Inicializacion” , 56);
link_sleep_cnt = 2;
dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_LOADOPSET | DWT_CONFIG, DWT_WAKE_SLPCNT | DWT_WAKE_CS | DWT_SLP_EN);
start_ts = get_rx_timestamp_u64();
rx_on_ts= (uint64) (start_ts + (1200000*63897.76358)) >> 8;
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.