I’ve been having some trouble sending and receiving packets using the DW chip’s automatic response facilities.

Automatic-response:  It is possible (and probably necessary for ranging) for the DW chip to quickly enter listen mode after it has transmitted a beacon packet.  There is a special mode that can be set up so that no intervention is required by the host processor.  There is a symmetrical capability to set up the DW chip to respond automatically to inbound beacon packets.

When transmitting a packet, and automatically listening for a response, I was receiving a “timeout” response as if the other end has taken too long to respond.  I simplified all the code down to the bare essentials, but still kept getting the timeout.  This is weird because clearly a response had been received, but by the time I polled the status of the response, the chip had decided it was too late arriving.

The cause turned out to be the SPI baudrate.  I was driving the SPI at 110K which is the slowest data rate that the DW can handle, but it is the speed they suggest for initializing the DW.  Deep in their demo code, the STM32 raises the SPI speed to something a lot higher (a rate that is difficult to decipher from the code).

I scanned the DW manual and couldn’t find any hints about legal  higher SPI speeds. My versions of the datasheet, and user manual are pdfs and for some reason I can’t search for keywords, the way I usually can.  Moreover, I couldn’t find any indication how to tell the DW I was going to talk to it at a higher speed.

Short of any better ideas… I simply cranked up the speed at the Nordic side to 8Mb/s, and let it rip.

Not only did the DW figure out the data rate automatically, but it also fixed my timing bug.  Clearly the Nordic software was not testing the status of the radio fast enough using the slow SPI speeds.

I don’t recall ever reading anything about this issue, but perhaps the new manuals mention it.  I suppose this explains why they crank the SPI speed up.   Doh!


1/21/16   I just read that the maximum possible baudrate for the SPI is 20MHz.

We were a little concerned about the antennae on TS06.3 boards.  Recall that the ground plane had extended under the DW module which was against their rules, so David had scraped it off.  The good news is that the TS06.3 antenna seem only to be about 50% as effective as the TS06.2 boards.  Given the packet loss is quite small, we can live with that I think.

I did some rough-and-ready tests to see how many packets get lost.

TS06.2 packet loss test

I left the simplest transceiver programs running on TS06.2 all last night.  The transmitter logs more packets than the receiver.  Sending packets all night at 1Hz 13.58% got lost, which is both dreadful, and strange.  I’ll run that again, and see if it is consistent.   I would expect close to perfection, but sure less than 1% for transceivers  8″ apart, transmitting one packet every second.  Note that my later tests send packets a lot faster.

1s intervals, overnight = 13.58% 

This morning I moved the transceivers 12″ apart and sent packets at 10ms intervals, and got 0.12% packet loss.

10ms intervals – 0.12% packet loss.

Moving the tranceivers back to 6″ separation I now get 0.11%

Repeating for TS06.2 -> TS06.3

10ms intervals TS06.3 -> TS06.2 – 0.3% packet loss

Repeating for TS06.3 -> TS06.3

Here are the exacting test conditions,  The DW antenna are about 6″ apart. The results are about the same.

10ms intervals TS06.3 -> TS06.3 – 0.6% packet loss

Sleep time

While the test is running the listener code in the Nordic is awake an impreceptibly small amount of time.  (I am not sleeping the DW yet.)
The transmitter is sending stuff as fast as it can and rarely get’s to sleep.  That doesn’t seem quite right, because sending packets shouldn’t be a big overhead.

I was having trouble waking up the DW if it had gone to sleep without setting the wakeup condition bits: DWT_WAKE_WK or DWT_SLP_EN. Under these conditions, the correct way to wake the chip up is to force RSTn low for a short time, and then let it float again.  There are strong exhortations in the manual never to drive RSTn high, so my code had been ultra-conservative. 


I now seem to have the code working reliably.  When unplugging the simple reader test, when it is running invariably locks up the DW chip.   This code seems to unlock it OK, and so far has not failed.  A 1ms delay seems to be enough

#define RESET_DELAY 1  // 1 msnrf_gpio_cfg(          // set the pin up as an output DW_RSTN, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,  // input buffer disconnected NRF_GPIO_PIN_NOPULL, // no internal pullups – high impedence I guess NRF_GPIO_PIN_S0D1, // ‘0’ drives it low with 0.5mA max sink;                                        // a ‘1’ disconnects it NRF_GPIO_PIN_NOSENSE   // not an input so not relevant );
nrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_set(DW_RSTN); // disconnect the pindeca_sleep(RESET_DELAY); // wait a very long timenrf_gpio_pin_clear(DW_RSTN); // drive the pin lowdeca_sleep(RESET_DELAY); // wait a very long time
nrf_gpio_cfg( // sets the pin up as an input DW_RSTN, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_CONNECT, // connect the input buffer NRF_GPIO_PIN_NOPULL,         // no pullups ??? NRF_GPIO_PIN_S0S1,  NRF_GPIO_PIN_NOSENSE           // not using GPIOTE, so no used );
nrf_gpio_input_disconnect(DW_RSTN); // disconnect itdeca_sleep(2);

I put the three new files out on our shared file system.
I have not looked to see how much has changed yet, so I don’t know if I really need a reprint.
——–
This API is a lot cleaner and easier to understand.  A whole shitload of cruft has been cut out.
There are really clear examples too.  And good news – a single round-trip ranging example.
Oh joy.
Leo,  
Thanks for the info.  To be conservative, I am assuming the worst case, that the IC is not correctly initialized.  I thought I should make sure I can recover from any weird power-down sequence – especially since I managed to provoke the IC to be non-responsive so easily (It's my special gift! :-).  The following sequence quite reliably leaves me unable to get it back from the dead, even by grounding RSTn.  Is it possible that the IC rushes back to sleep before I manage to seize the SPI and set the CS and WK bits?
dwt_configuresleep(DWT_LOADUCODE | DWT_PRESRV_SLEEP | DWT_LOADOPSET | DWT_CONFIG , DWT_WAKE_CS | DWT_WAKE_WK |DWT_SLP_EN);
dwt_entersleep();
I assume that even if the IC is totally uninitialized, that it is possible to get the IC to wake up and have the SPI talk to me, at least at low speed.  
Anyway, rather than beat on this arcane issue some more, 'll check the things new docs. and API which is most welcome.  
Many thanks for the prompt response.

//Mik

On Fri, Jan 15, 2016 at 2:44 PM, leo Theunissen <leo.theunissen@decawave.com> wrote:

Hi Mike,

Joe forwarded your issue to me.

 

Not sure if I could of that much help right now.

 

I take it the IC is correctly initialized , LDE loaded etc..

But to be sure , could I ask you to or could you confirm.

A) study the SPI section of the Datasheet, if not already done (5.8 Host Controller Interface). The DS has just been updated, so I send you the latest.

B) that In case you’re loading the UCODE you also need to wait about let’s say 120 micro seconds before changing clocks back before increasing the SPI frequency (See chapter 2.4 Power on Reset) of the IC usermanual

 

What could/will also be of a help is the fact that we released an API with example code.

This API contains a couple of standalone examples like , just RX or TX, RX or TX with sleep and auto-sleep , Continuous Wave and Frame mode and some more.

These examples could be an aid for your own HW / SW development and could also be used to help to determine if an issue is HW or SW .

 

This new code is attached. Just  change .zop into .zip.

 

Mik, I hope this is some help

 

Kind Regards

Leo Theunissen

 

 

The main change to fix it was increasing the time from wakeup to any SPI activity. 

.

———- Forwarded message ———-
From: Mik Lamming <mik@lamming.com>
Date: 15 January 2016 at 05:51
Subject: Technical support request
To: joe.byrne@decawave.com
Cc: David Carkeek <dcarkeek@gmail.com>

Joe,

I am David Carkeek's colleague working on a prototype that uses the DWM1000 module.  I have a technical issue that is puzzling me, and I wondered if you could shed some light on it for me.

 

On a couple of occasions, following a crash of my software (not your demo), I have apparently unset the wakeup flags: DWT_WAKE_CS  and DWT_WAKE_WK just before sending the chip to sleep.  In that mode the chip won't wake up on CS, or WAKE of course.

 

I understood from the manual that grounding the RSTn line should reset the chip, and enable my program to regain control and talk over the SPI again. To test that theory I have manually jumpered RSTn to ground momentarily, but I still can't talk to it over SPI and so I can't reset those wakeup flags.  Indeed the only thing that seems to work is to power everything off completely, and restart.  Then, fortunately I regain control again.

 

Grounding RTSn does appear to reset the DW chip.  I say that because when the wakeup flags are set correctly and everything is running correctly, grounding that pin makes the DW inaccessible for a short while, and then my software recovers, after the reset finishes I assume.  

 

I want to bulletproof my code against this happening, and I wondered what the magic formula for waking up a deep-sleeping DW chip is.

 

I wonder what it is that I'm not understanding, and if you or your colleagues could explain what I'm doing wrong.

 

//Mik Lamming

 

On Tue, Mar 10, 2015 at 3:19 AM, Joe Byrne< joe.byrne@decawave.com> wrote:

Good morning David,

 

I am currently updating our latest Salesforce documents for our costumer base. I would just like to confirm your address as

 

 

David Carkeek

19339 Harleigh Drive

Saratoga, CA 95070

 

Phone No : ?

 

I would also like to add a note ( if you wish ) regarding your project ,your progress to date and anything else you might

think would be helpful to you. 

 

Thanks David . 

 

Regards

 

Joe .

 

Joseph Byrne .

 

Applications Team

DecaWave Ltd.
Adelaide Chambers,
Peter Street,
Dublin 8,
Ireland.

 

 

//Mik



 

Joseph Byrne .

 

Applications Team

DecaWave Ltd.
Adelaide Chambers,
Peter Street,
Dublin D08 T6YA
Ireland.

 

 

I have RTX running multiple parallel threads.  I have two separate threads contending to talk to the DW chip at the same time, and they are interleaving nicely without stepping on each other.  This is an arcane test, but it shows that I have the mutex situation sussed out at last (I hope).  With luck this means that I should be able to service DW "packet received" interrupts while there is other traffic on the SPI.

There is a new wireless concept emerging called wake-up radio (WUR).  The only thing a WUR does is listen for a radio request to wake up other circuits – a more power-hungry radio like WiFi or Bluetooth for example.  It is not a radio for transmitting many bits.  It’s simply needs to respond when it hears it’s name called. What makes it important is that it is able to listen at extremely low power levels – perhaps a 1000 times less than the best ultra-low power BLE chips.
Since the main cost of running a battery-powered device is the power consumed listening for a message that might only come very infrequently, a 1000-fold improvement could translate into a 1000-fold extension in battery life for some devices (like mine).
The organization that built it is a Belgian research org. called IMEC, and it’s reasonable to expect that there will be people looking to incorporate this radio into WiFi, BLE and UWB (in fact I know it is going on).  
What impact is this likely to have on the industry?  Getting batteries and/or mains power to all these projected IoT devices is going to be a challenge, and changing the batteries on the 1000 devices you will have in your home will be a big turnoff. If WUR works, then it could be cosmic. 
  • Watch out for new devices that require no batteries, and can run of harvested energy. 
  • Look for wearables that you don’t want to take off to charge – watches, pacemakers…  
  • Look for business that have to install/maintain a lot of battery-powered wireless devices suddenly getting traction in new markets – especially places where a power grid is not taken for granted.   
Looks like a 6-axis and BLE on a single chip.  No compass, so I'm not sure it would reduce out chip count.


//Mik

———- Forwarded message ———-
From: David Carkeek <dcarkeek@gmail.com>
Date: Mon, Jan 11, 2016 at 10:36 PM
Subject: Intel shows off Curie chip for sports at CES
To: Mik Lamming <mik@lamming.com>

Is this important? Probably not.

http://www.businessinsider.com/intel-curie-could-change-entire-live-sports-experience-2016-1

What's the big deal? I wonder what's in it.