DW3XXX Software API Guide 2p2
DW3XXX Software API Guide 2p2
DRIVER APPLICATION
PROGRAMMING
INTERFACE (API) GUIDE
DOCUMENT INFORMATION
Disclaimer
Decawave reserves the right to change product specifications without notice. As far as possible changes to
functionality and specifications will be issued in product specific errata sheets or in new versions of this
document. Customers are advised to check the Decawave website for the most recent updates on this
product
Decawave products are not authorized for use in safety-critical applications (such as life support) where a
failure of the Decawave product would reasonably be expected to cause severe personal injury or death.
Decawave customers using or selling Decawave products in such a manner do so entirely at their own risk
and agree to fully indemnify Decawave and its representatives against any damages arising out of the use of
Decawave products in such safety-critical applications.
DISCLAIMER
This Disclaimer applies to the DW3xxx API source code (collectively “Decawave Software”) provided
by Decawave Ltd. (“Decawave”).
Downloading, accepting delivery of or using the Decawave Software indicates your agreement to the
terms of this Disclaimer. If you do not agree with the terms of this Disclaimer do not download,
accept delivery of or use the Decawave Software.
Decawave Software is solely intended to assist you in developing systems that incorporate
Decawave semiconductor products. You understand and agree that you remain responsible for using
your independent analysis, evaluation and judgment in designing your systems and products. THE
DECISION TO USE DECAWAVE SOFTWARE IN WHOLE OR IN PART IN YOUR SYSTEMS AND PRODUCTS
RESTS ENTIRELY WITH YOU.
DECAWAVE SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY
THIRD PARTY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON THE DECAWAVE SOFTWARE
OR THE USE OF THE DECAWAVE SOFTWARE WITH DECAWAVE SEMICONDUCTOR TECHNOLOGY. IN
NO EVENT SHALL DECAWAVE BE LIABLE FOR ANY ACTUAL, SPECIAL, INCIDENTAL, CONSEQUENTIAL
OR INDIRECT DAMAGES, HOWEVER CAUSED, INCLUDING WITHOUT LIMITATION TO THE GENERALITY
OF THE FOREGOING, LOSS OF ANTICIPATED PROFITS, GOODWILL, REPUTATION, BUSINESS RECEIPTS
OR CONTRACTS, COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION), LOSSES OR EXPENSES RESULTING FROM THIRD
PARTY CLAIMS. THESE LIMITATIONS WILL APPLY REGARDLESS OF THE FORM OF ACTION, WHETHER
UNDER STATUTE, IN CONTRACT OR TORT INCLUDING NEGLIGENCE OR ANY OTHER FORM OF ACTION
AND WHETHER OR NOT DECAWAVE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES,
ARISING IN ANY WAY OUT OF DECAWAVE SOFTWARE OR THE USE OF DECAWAVE SOFTWARE.
You are authorized to use Decawave Software in your end products and to modify the Decawave
Software in the development of your end products. HOWEVER, NO OTHER LICENSE, EXPRESS OR
IMPLIED, BY ESTOPPEL OR OTHERWISE TO ANY OTHER DECAWAVE INTELLECTUAL PROPERTY RIGHT,
AND NO LICENSE TO ANY THIRD PARTY TECHNOLOGY OR INTELLECTUAL PROPERTY RIGHT, IS
GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or other
intellectual property right relating to any combination, machine, or process in which Decawave
semiconductor products or Decawave Software are used.
You acknowledge and agree that you are solely responsible for compliance with all legal, regulatory
and safety-related requirements concerning your products, and any use of Decawave Software in
Decawave reserves the right to make corrections, enhancements, improvements and other changes
to its software at any time.
Mailing address: -
Decawave Ltd.,
Adelaide Chambers,
Peter Street,
Dublin D08 T6YA
TABLE OF CONTENTS
1 INTRODUCTION AND OVERVIEW ........................................................................................................... 12
6.3.30 Example 06f: single-sided two-way ranging responder (SS TWR) with AES ............................. 151
6.3.31 Example 07a: Auto ACK TX ....................................................................................................... 151
6.3.32 Example 07b: Auto ACK RX ....................................................................................................... 151
6.3.33 Example 11a: Use of SPI CRC .................................................................................................... 151
6.3.34 Example 13a: Use of DW3XXX GPIO lines ................................................................................. 151
6.3.35 Example 14: OTP Write ............................................................................................................. 152
6.3.36 Example 15: LE (Low-Energy) pend........................................................................................... 152
6.3.37 Example 16 PLL Cal ................................................................................................................... 152
6.3.38 Example 17 Bandwidth Calibration .......................................................................................... 152
6.3.39 Example 18: Timer Example ..................................................................................................... 152
6.3.40 Example 19: TX Power Adjustment Example ............................................................................ 152
6.3.41 Example 20: Simple AES............................................................................................................ 152
List of Tables
TABLE 1: CONFIG PARAMETER TO DWT_INITIALISE() FUNCTION .......................................................................................... 27
TABLE 2: SUPPORTED UWB CHANNELS AND RECOMMENDED PREAMBLE CODES ..................................................................... 32
TABLE 3: RECOMMENDED PREAMBLE LENGTHS................................................................................................................ 33
TABLE 4: RECOMMENDED PAC SIZE .............................................................................................................................. 33
TABLE 5: STSMODE PARAMETER TO DWT_CONFIGURE() FUNCTION ..................................................................................... 34
TABLE 6: PGDLY RECOMMENDED VALUES....................................................................................................................... 37
TABLE 7: TX POWER RECOMMENDED VALUES.................................................................................................................. 37
TABLE 8: DWT_TXCONFIG_T PARAMETER: POWER FUNCTION ............................................................................................ 37
TABLE 9: SFDTYPE PARAMETER TO DWT_CONFIGURESFDTYPE() FUNCTION ............................................................................ 43
TABLE 10: VALID CRC_MODE OPTIONS .......................................................................................................................... 46
TABLE 11: CHANNEL 5 LOOKUP TABLE CONFIGURATION FOR DW3XXX DEVICES .................................................................... 47
TABLE 12: CHANNEL 9 LOOKUP TABLE CONFIGURATION FOR DW3XXX DEVICES .................................................................... 47
TABLE 13: MODE PARAMETER TO DWT_STARTTX() FUNCTION............................................................................................ 58
TABLE 14: MODE PARAMETER TO DWT_RXENABLE() FUNCTION.......................................................................................... 68
TABLE 15: VALUES FOR DWT_CONFIGCIADIAG() ENABLE_MASK PARAMETER ......................................................................... 76
TABLE 16: STSSTATUS VALUES...................................................................................................................................... 85
TABLE 17: BITMASK VALUES FOR DWT_CONFIGURESLEEP() MODE BIT MASK.......................................................................... 92
TABLE 18: BITMASK VALUES FOR DWT_CONFIGURESLEEP() WAKE BIT MASK .......................................................................... 92
TABLE 19: BITMASK_LO VALUES FOR CONTROL OF COMMON EVENT INTERRUPTS.................................................................. 101
TABLE 20: BITMASK VALUES FOR CONTROL OF RX BUFFER EVENT INTERRUPTS ..................................................................... 103
TABLE 21: LIST OF EVENTS HANDLED BY THE DWT_ISR() FUNCTION AND SIGNALLED IN CALL-BACKS .......................................... 104
TABLE 22: BITMASK VALUES FOR FRAME FILTERING ENABLING/DISABLING........................................................................... 112
TABLE 23: OTP MEMORY MAP .................................................................................................................................. 117
TABLE 24: SPI_MODES_E ENUM VALUES (SPI READ/WRITE MODES) .................................................................................. 138
TABLE 25: LIST OF SUPPORTED COMMANDS .................................................................................................................. 140
List of Figures
FIGURE 1: GENERAL SOFTWARE FRAMEWORK OF THE DEVICE DRIVER ................................................................................... 13
FIGURE 2: DEVICE DRIVER COMPATIBILITY LAYER............................................................................................................. 15
FIGURE 3: TYPICAL FLOW OF INITIALISATION.................................................................................................................... 17
FIGURE 4: INTERRUPT HANDLING .................................................................................................................................. 18
FIGURE 5: STANDARD COMPLIANT VERSUS SECURE RANGING PACKET ................................................................................... 34
FIGURE 6: AES IN COUNTER MODE BASED CPRNG .......................................................................................................... 35
FIGURE 7: INTERRUPT HANDLING ................................................................................................................................ 107
FIGURE 8: API PACKAGE STRUCTURE TREE .................................................................................................................... 143
FIGURE 9: CONTINUOUS WAVE OUTPUT ....................................................................................................................... 147
FIGURE 10: CONTINUOUS FRAME OUTPUT.................................................................................................................... 148
This document, “DW3xxx Device Driver - Application Programming Interface (API) Guide” is a guide
to the device driver software developed by Decawave to drive Decawave’s family of UWB radio
transceiver ICs: DW3000 and QM33120.
The device driver is essentially a set of low-level functions providing a means to exercise the main
features of the transceiver without having to deal with the details of accessing the device directly
through its SPI interface register set.
The device driver is provided as source code to allow it to be ported to any target microprocessor
system with an SPI interface1. The source code employs the C programming language.
The device driver is controlled through its Application Programming Interface (API) which is
comprised of a set of functions. This document is predominately a guide to the device driver API
describing each of the API functions in detail in terms of its parameters, functionality and utility.
The device driver version information may be found in source code file “deca_version.h”.
1
Since the DW3xxx IC is controlled through its SPI interface, an SPI interface is a mandatory requirement for
the system.
2 GENERAL FRAMEWORK
Figure 1 shows the general framework of the software system encompassing the DW3xxx device
driver. The device driver controls the IC through its SPI interface. The device driver abstracts the
target SPI device by calling it through generic functions writetospi() and readfromspi (). In porting the
IC device driver to different target hardware, the body of these SPI functions are written/re-
written/provided to drive the target microcontroller device’s physical SPI hardware. The
initialisation of the physical SPI interface mode and data rate is considered to be part of the target
system outside the IC device driver.
Software
RX Okay
TX Done RX Error
RX Timeout
dwt_isr()
writetospi() readfromspi()
Target SPI Target IRQ
SPIMOSI
SPIMISO
SPICLK
SPICSn
IRQ
DW3000 PHYSICAL IC
The control of the IC through the device driver software is achieved via a set of API functions,
documented in section 5 – API function descriptions below, and called from the upper layer
application code.
The IRQ interrupt line output from the IC (assuming interrupts are being employed) is connected to
the target microcontroller system’s interrupt handling logic. Again, this is considered to be outside
the device driver. It is assumed that the target systems interrupt handling logic and its associated
target specific interrupt handling software will correctly identify the assertion of the IC’s IRQ and will
as a result call the device driver’s interrupt handling function dwt_isr() to process the interrupt.
The device driver’s dwt_isr () function processes the IC interrupts and calls TX, RX, RX error, RX
timeout, SPI error or SPI ready call-back functions in the upper layer application code. This is done
via function pointers *cbTxDone(), *cbRxOk(), *cbRxTo, *cbRxErr(), *cbSPIErr() and *cbSPIRdy() or
*dualSPIavailable() which are configured to call the upper layer application code’s own call-back
functions via the dwt_setcallbacks () API function.
Using interrupts is recommended, but it is possible to drive the IC without employing interrupts. In
this case the background loop can periodically call the device driver’s dwt_isr () function, which will
poll the IC status register and process any events that are active.
Note background application activity invoking API functions employing the SPI interface can
conflict with foreground interrupt activity also needing to employ the SPI interface.
The device driver’s interrupt handler accesses the IC through the writetospi() and readfromspi ()
functions, and, it is generally expected that the call-back functions will also access the IC through the
device driver’s API functions which ultimately also call the writetospi() and readfromspi () functions.
This means that the writetospi() and readfromspi () functions need to incorporate protection
against foreground activity occurring when they are being used in the background. This is
achieved by incorporating calls to decamutexon () and decamutexoff() within the writetospi() and
readfromspi () functions to disable interrupts from the IC from being recognised while the
background SPI access is in progress.
Other than the provisions for interrupt handling, the device driver and its API functions are not
written to be re-entrant or for simultaneous use by multiple threads. The design in general assumes
a single caller that allows each function to complete before it is called again.
The driver also includes a “compatibility layer” that sits within the device driver. Its purpose is to
“route” the API calls to the correct function for the calling device. For example, if device “A” wants
to check the version of the API, the compatibility layer will route it to the correct code for device
“A”. If device “B” wants to do the same, it will route it to the correct code for device “B”. However,
the upper layer / application code will only need to call one API and the device driver will route to
the correct device by itself.
The main purpose of this compatibility layer is to allow for inter-operability between
Qorvo/Decawave UWB devices of the same family. However, it is only implemented for one device
at present. Future releases will allow for compatibility with other UWB devices of the same family.
Each of the Qorvo/Decawave UWB devices that are supported by the device driver will need to
populate the device descriptor structure and store it into flash memory (or equivalent, presuming an
embedded platform). For example, the DW3000 device descriptor is declared like so:
This package contains support for both the STM Nucleo F429 and Nordic nRF52840-DK evaluation
boards. For the STM board, the linker script (STM32F429ZITx_FLASH.ld) is changed to include this
structure in the “.text” segment of memory like so:
© Decawave Ltd 2021 Version 2.2 Page 15 of 155
DW3XXX API GUIDE
. = ALIGN(4);
__dw_drivers_start = .;
KEEP(*(.dw_drivers))
__dw_drivers_end = .;
For the Nordic board, the linker script (flash_placement.xml) is changed to include this structure in
the “.text” segment of memory like so:
Any additional device descriptor structures that are declared must be stored between
“__dw_drivers_start” and “__dw_driver_end” addresses in memory.
Power
ON
4 INTERRUPT HANDLING
Figure 4 shows how the DW3xxx interrupts should be processed by the microcontroller system. Once
the interrupt is active, the microcontroller’s target specific interrupt handler for that interrupt line
should get called. This in turn calls the device driver’s interrupt handler service routine, the
dwt_isr() API function, which processes the event that triggered the interrupt.
DW IRQ is
asserted
1
Assuming interrupts are enabled,
target specific hardware invokes target
specific interrupt processing software
IRQ
YES
Pending
?
NO
3
Clear and re-enable target specific
interrupt processing hardware for the Once complete,
DW IRQ line and return from the return from Interrupt
interrupt servicing routine
The flow shown above, with the rechecking of continued IRQ line activation and calling the dwt_isr()
API function again, is only required for edge sensitive interrupts. This is done in case another
interrupt becomes pending during the processing of the first interrupt, in this case if all interrupt
sources are not cleared the IRQ line will not be de-asserted and edge sensitive interrupt processing
hardware will not see another edge. For proper level sensitive interrupts only steps numbered 1, 2,
and 3 are required – any still pending interrupt should cause the interrupt handler to be re-invoked
as soon as it finishes processing the first interrupt.
More information about individual interrupt events and associated processing is shown in Figure 7:
Interrupt handling.
These functions are implemented in the device driver source code file “deca_device.c”, written in
the ‘C’ programming language.
The device driver code interacts with the IC using simple SPI read and write functions. These are
abstracted from the physical hardware, and are easily ported to any specific SPI implementation of
the target system. There are two SPI functions: writetospi() and readfromspi() these prototypes are
defined in the source code file “deca_spi.c”.
The functions of the device driver are covered below in individual sub-sections.
5.1.1 dwt_probe
int dwt_probe(void);
This function will read the device identifier (DEV_ID) from the device and initialise all the required
pointers for the API calls to pass through the Compatibility Layer based on the device identifier. This
function must be called first in any application. Otherwise, all other subsequent API calls will fail as
they will not be able to pass through the compatibility layer correctly.
On embedded platforms, a section of the flash memory must be reserved to hold the device
structure (struct dwt_driver_s) that contains information such as device identifiers, device names,
device API versions, etc. Please see Device Descriptor Structures Stored in Memory for more
information.
This section of flash memory will have a start address and end address. Data structures containing
information on the available devices will be stored in between the start and end address of this
memory block.
If the DEV_ID that was read from the device matches the DEV_ID that is stored in the device
descriptor structure in memory, then this function will set the compatibility layer to ‘point’ to the
correct code.
Parameters:
none
Return Parameters:
Type Description
int DWT_SUCCESS if the DEV_ID read from the device matches a device descriptor structure
stored in memory
DWT_ERROR if no DEV_ID can be read from device, or if the DEV_ID does not match
what is stored in memory
Notes:
5.1.2 dwt_apiversion
int32_t dwt_apiversion(void);
Type Description
Notes:
5.1.3 dwt_version_string
char *dwt_version_string(void);
This function returns the version string of the API as defined by device descriptor structure (struct
dwt_driver_s). It will return a char pointer to the string: DRIVER_VERSION_STR.
Parameters:
none
Return Parameters:
Type Description
char* char pointer to device descriptor version name (e.g. DW3000 Device Driver Version
05.00.00").
Notes:
5.1.4 dwt_readdevid
uint32_t dwt_readdevid(void);
This function returns the device identifier (DEV_ID) register value (32-bit value). It reads the DEV_ID
register (0x00) and returns the result to the caller. This may be used for instance by the application
to verify the DW IC is connected properly over the SPI bus and is running.
Parameters:
none
Return Parameters:
Type Description
uint32_t 32-bit device ID value, e.g. for QM33120 the device ID is 0xDECA0314.
Notes:
This function can be called any time to read the device ID value. A return value of 0xFFFFFFFF or 0x0
indicates an error unless the device is in DEEP_SLEEP or SLEEP mode.
Example code:
uint32_t devID = dwt_readdevid();
5.1.5 dwt_check_dev_id
int dwt_check_dev_id(void);
This function checks if the device ID that is being read back from the DEV_ID register is a correct
value. If the device ID is incorrect, it can mean that either something is wrong with the SPI reads to
the DW3XXX, or the driver is reading a device ID from an incompatible version of hardware. The
latter can occur if a newer version of the software is used to try read from an older version of
hardware. It is useful to run this function upon initialisation.
Parameters:
none
Return Parameters:
Type Description
int DWT_SUCCESS is returned if the device ID read back from the device is correct.
DWT_ERROR is returned if the device ID does not conform with this version of software.
Notes:
Calling this function upon initialisation can be beneficial in cases where there is potential for versions
of software and hardware to be out of sync.
Example code:
if ((err=dwt_check_dev_id())==DWT_SUCCESS)
{
printf("DEV ID OK\n");
}
else
{
printf("DEV ID FAILED\n");
}
5.1.6 dwt_getpartid
uint32_t dwt_getpartid(void);
This function returns the part identifier as programmed in the factory during device test and
qualification. ( dwt_initialise() must be called prior to this)
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called any time to read the locally stored value which will be valid after device
initialisation is done by a call to the dwt_initialise () function.
Example code:
uint32_t partID = dwt_getpartid();
5.1.7 dwt_getlotid
uint32_t dwt_getlotid(void);
This function returns the lot identifier as programmed in the factory during device test and
qualification.( dwt_initialise() must be called prior to this)
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called any time to read the locally stored value which will be valid after device
initialisation is done by a call to the dwt_initialise() function .
Example code:
uint32_t lotID = dwt_getlotid();
5.1.8 dwt_geticrefvolt
uint8_t dwt_geticrefvolt(void);
During the IC manufacturing test, a 3.0 volt reference level is applied to the power the device and
the battery voltage reported by the battery voltage monitor SAR A/D convertor is sampled and
programmed into OTP address 0x8 (VBAT_ADDRESS). This reference value may be used to
calibrate/interpret battery voltage monitor values during IC use. The dwt_geticrefvolt() function
returns this factory reference voltage value.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called any time to read the locally stored value which will be valid after device
initialisation is done by a call to the dwt_initialise() API function.
5.1.9 dwt_geticreftemp
uint8_t dwt_geticreftemp(void);
Type Description
Notes:
This function can be called any time to read the locally stored value which will be valid after device
initialisation is done by a call to the dwt_initialise() API function.
5.1.10 dwt_getxtaltrim
uint8_t dwt_getxtaltrim(void);
This function returns the current value of XTAL trim. If called after dwt_initialise() API on power up, it
will either contain crystal trim value loaded from OTP memory or a default value.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.1.11 dwt_setlocaldataptr
The DW3xxx API uses an internal data structure to hold some local state data. The device driver is
able to handle multiple DW3xxx devices by using an array of those structures, as set by the #define
of the DWT_NUM_DW_DEV pre-processor symbol. This dwt_setlocaldataptr() API function sets the
local data structure pointer to point to the element in the local array as given by the index.
Parameters:
This selects the array element to point to. Must be within the array
unsigned int index
bounds, i.e. < DWT_NUM_DW_DEV.
Return Parameters:
Type Description
Notes:
The local device static data is an array to support multiple devices, e.g. in testing applications and
platforms. This function selects which element of the array is being accessed. For example, if two
QM33120 devices are controlled in your application then this function should be called before
accessing either of the devices to configure the local structure pointer. To handle multiple devices
the low-level SPI access function also needs to be set to talk to the correct device.
5.1.12 dwt_otprevision
uint8_t dwt_otprevision(void);
This function returns OTP revision as read during the call to dwt_initialise(). This location is
suggested for customer programming, (and is used in Decawave’s evaluation board products to
identify different/changes in usage of the OTP area).
Parameters:
none
Return Parameters:
Type Description
5.1.13 dwt_softreset
This function performs a software-controlled reset of the transceiver IC. All of the IC configurations
will be reset back to default. Please refer to the User Manual [2] for details of IC default
configuration register values. The SPI rate must be set to <= 7 MHz before a calling this API.
Parameters:
Return Parameters:
none
Notes:
This function is used to reset the IC, e.g. before applying new configuration to clear all of the
previously set values. After reset the IC will be in the INIT state, and all of the registers will have
default values. Any values programmed into the always on (AON) low-power configuration array store
will also be cleared. Then it will progress to IDLE_RC state. Once in IDLE_RC the SPI_RDY event will be
set.
Note: The RSTn pin can also be used to reset the device. Host microprocessor can use this pin to reset
the device instead of calling dwt_softreset() function. The pin should be driven low (for 10 ns) and
then left in open-drain mode. RSTn pin should never be driven high.
5.1.14 dwt_checkidlerc
uint8_t dwt_checkidlerc(void);
The DW3XXX states are described in the User Manual. On power up, or following a reset the device
will progress from INIT_RC to IDLE_RC. Once the device is in IDLE_RC SPI rate ca be increased to
more than 7 MHz. The device will automatically proceed from INIT_RC to IDLE_RC and both INIT_RC
and SPI_RDY event flags will be set, once device is in IDLE_RC. It is recommended that host waits for
SPI_RDY event, which will also generate interrupt once device is ready after reset/power on. If the
host cannot use interrupt as a way to check device is ready for SPI comms, then we recommend the
host waits for 2 ms and reads this function, which checks if the device is in IDLE_RC state by reading
the SYS_STATUS register and checking for the IDLE_RC event to be set. If host initiates SPI
transaction with the device prior to it being ready, the SPI transaction may be incorrectly decoded by
the device and device may be misconfigured. Reading registers over SPI prior to device being ready
may return garbage on the MISO, which may confuse the host application.
Parameters:
none
Return Parameters:
Type Description
Notes:
It is advised to call this function before calling dwt_initialise() in order to check that the device is in
the correct state before initializing.
Example code:
/* Reads and validate device ID returns DWT_ERROR if it does not match
expected else DWT_SUCCESS */
int err;
if ((err=dwt_check_dev_id())==DWT_SUCCESS)
{
printf("DEV ID OK\n");
}
else
{
printf("DEV ID FAILED\n");
}
5.1.15 dwt_initialise
Parameters:
Return Parameters:
Type Description
Notes:
This dwt_initialise() function is the first function that should be called to initialise the device, e.g.
after the power has been applied. It reads the device ID to verify the IC is one supported by this
software (e.g. for QM33120 the 32-bit device ID value is 0xDECA0314).
• LDO tune and crystal trim values, which are applied directly if they are valid.
• Device’s Part ID and Lot ID which are stored in driver’s local structure for future access.
If the DWT_ERROR is returned by dwt_initialise() then further configuration and operation of the IC
is not advised, as the IC will not be functioning properly.
Table 1: Config parameter to dwt_initialise() function
Mask
Mode Description
Value
DWT_DW_INIT 0x0 Do not load any OTP values, also leave the device in INIT
state.
DWT_READ_OTP_PID 0x10 Reads part ID from OTP, and stores it in internal structure.
The dwt_getpartid() API can then be used to access it.
DWT_READ_OTP_LID 0x20 Reads lot ID from OTP, and stores it in internal structure.
The dwt_getlotid() API can then be used to access it.
Mask
Mode Description
Value
DWT_READ_OTP_BAT 0x40 Reads reference (measured @ 3.0 V) raw Voltage value
from OTP, and stores it in internal structure. The
dwt_geticrefvolt() API can then be used to access it.
DWT_READ_OTP_TMP 0x80 Reads reference (measured @ 23 ˚C) raw Temperature
value from OTP, and stores it in internal structure. The
dwt_geticreftemp() API can then be used to access it.
Notes:
For more details of the OTP memory programming please refer to section 5.9 OTP and AON access
APIs. Programming OTP memory is a one-time only activity, any values programmed in error cannot
be corrected. Also, please take care when programming OTP memory to only write to the
designated areas – programming elsewhere may permanently damage the IC’s ability to function
normally.
5.2.1 dwt_configure
This function is responsible for setting up the channel configuration parameters for use by both the
transmitter and the receiver. The settings are specified by the dwt_config_t structure passed into
the function, see notes below. (Note also there is a separate function dwt_setplenfine() for setting
preamble length in blocks of 8. This is described in section 5.2.3 below). The device will be put into
IDLE sate after the configuration of the PLL.
Parameters:
typedef struct
{
uint8_t chan ; //!< channel number {5, 9}
dwt_tx_plen_e txPreambLength; //!< DWT_PLEN_64..DWT_PLEN_4096
dwt_pac_size_e rxPAC ; //!< Acquisition Chunk Size (Relates to RX
// preamble length)
uint8_t txCode ; //!< TX preamble code
uint8_t rxCode ; //!< RX preamble code
dwt_sfd_type_e sfdType ; //!< SFD type (0 - short IEEE 8 standard
// 1 - DW 8, 2 - DW 16, 3 - 4z
} dwt_config_t ;
typedef enum
{
DWT_PLEN_4096 = 0x03, //! Standard preamble length 4096 symbols
DWT_PLEN_2048 = 0x0A, //! Non-standard preamble length 2048 symbols
DWT_PLEN_1536 = 0x06, //! Non-standard preamble length 1536 symbols
DWT_PLEN_1024 = 0x02, //! Standard preamble length 1024 symbols
DWT_PLEN_512 = 0x0d, //! Non-standard preamble length 512 symbols
DWT_PLEN_256 = 0x09, //! Non-standard preamble length 256 symbols
DWT_PLEN_128 = 0x05, //! Non-standard preamble length 128 symbols
DWT_PLEN_64 = 0x01, //! Standard preamble length 64 symbols
DWT_PLEN_32 = 0x04, //! Non-standard length 32
DWT_PLEN_72 = 0x07, //! Non-standard length 72
} dwt_tx_plen_e;
typedef enum
{
DWT_BR_850K = 0, //!< UWB bit rate 850 kbits/s
DWT_BR_6M8 = 1, //!< UWB bit rate 6.8 Mbits/s
DWT_BR_NODATA = 2, //!< No data (SP3 packet format)
} dwt_uwb_bit_rate_e;
typedef enum
{
DWT_PRF_16M = 1, //!< UWB PRF 16 MHz
DWT_PRF_64M = 2, //!< UWB PRF 64 MHz
DWT_PRF_SCP = 3, //!< SCP UWB PRF ~100 MHz
} dwt_prf_e;
typedef enum
{
DWT_PAC8 = 0, //!< PAC 8 (recommended for RX of preamble length <=128
DWT_PAC16 = 1, //!< PAC 16 (recommended for RX of preamble length 256
DWT_PAC32 = 2, //!< PAC 32 (recommended for RX of preamble length 512
DWT_PAC4 = 3, //!< PAC 4 (recommended for RX of preamble length < 127
} dwt_pac_size_e;
typedef enum
{
DWT_SFD_IEEE_4A = 0, //!< IEEE 8-bit ternary
DWT_SFD_DW_8 = 1, //!< DW 8-bit
DWT_SFD_DW_16 = 2, //!< DW 16-bit
DWT_SFD_IEEE_4Z = 3, //!< IEEE 8-bit binary (4z)
DWT_SFD_LEN8 = 8, //!< IEEE, and DW 8-bit are length 8
DWT_SFD_LEN16 = 16, //!< DW 16-bit is length 16
} dwt_sfd_type_e;
typedef enum
{
DWT_STS_LEN_32 =0,
DWT_STS_LEN_64 =1,
DWT_STS_LEN_128 =2,
DWT_STS_LEN_256 =3,
DWT_STS_LEN_512 =4,
DWT_STS_LEN_1024=5,
DWT_STS_LEN_2048=6
}dwt_sts_lengths_e;
typedef enum
{
DWT_PHRMODE_STD = 0x0, // standard PHR mode
DWT_PHRMODE_EXT = 0x1, // DW proprietary extended frames PHR mode
} dwt_phr_mode_e;
typedef enum
{
DWT_PHRRATE_STD = 0x0, // standard PHR rate
DWT_PHRRATE_DTA = 0x1, // PHR at data rate (6M81)
} dwt_phr_rate_e;
typedef enum
{
DWT_PDOA_M0 = 0x0, // DW PDOA mode is off
DWT_PDOA_M1 = 0x1, // DW PDOA mode 1
DWT_PDOA_M3 = 0x3, // DW PDOA mode 3
} dwt_pdoa_mode_e;
typedef enum
{
DWT_STS_MODE_OFF = 0x0, // STS is off
DWT_STS_MODE_1 = 0x1, // STS mode 1
DWT_STS_MODE_2 = 0x2, // STS mode 2
DWT_STS_MODE_ND = 0x3, // STS with no data
DWT_STS_MODE_SDC = 0x8, // Enable Super Deterministic Codes
DWT_STS_CONFIG_MASK = 0xB,
DWT_STS_CONFIG_MASK_NO_SDC = 0x3,
} dwt_sts_mode_e;
Return Parameters:
Type Description
Notes:
The dwt_configure() function should be used to configure the IC’s channel (TX/RX) parameters before
receiver enable or before issuing a start transmission command. It can be called again to change
configurations as needed, however before using dwt_configure() the IC should be returned to idle
mode using the dwt_forcetrxoff() API call.
The config parameter points to a dwt_config_t structure that has various fields to select and configure
different parameters within the IC. The fields of the dwt_config_t structure are identified are
individually described below:
The chan parameter sets the UWB channel number, (defining the centre
chan
frequency and bandwidth). The supported channels are 5, and 9.
The txCode and rxCode parameters select the preamble codes to use in the
transmitter and the receiver – these are generally both set to the same values.
For correct operation of the device, the selected preamble code should follow
txCode and rxCode the rules of IEEE 802.15.4-2015 [3] UWB with respect to which codes are
allowed in the particular channel and PRF configuration, this is shown in Table
2 below. The code will also define the PRF (pulse repetition frequency) used.
The sfdType parameter enables the use of one of 4 possible SFD (Start Frame
Delimiter) sequences. The supported values are: 0 - short IEEE 8-bit standard,
sfdType 1 - DW 8-bit, 2 - DW 16-bit, 3 - 4z BPRF) DW 8 and 16 bit sequences, which
Decawave has found to be more robust than that specified in the IEEE 802.15.4
standard, give improved performance.
The rxPAC parameter specifies the Preamble Acquisition Chunk size to use.
Allowed values are DWT_PAC8, DWT_PAC16, DWT_PAC32 or DWT_PAC4.
Table 4 below gives the recommended PAC size to use in the receiver
depending on the preamble length being used in the transmitter. PAC size is
rxPAC specified in preamble symbols, which are approximately 1 µs each.
The phrMode parameter selects between either the standard or extended PHR
mode is set, either DWT_PHRMODE_STD for standard length frames 5 to 127
phrMode
octets long or non-standard DWT_PHRMODE_EXT allowing frames of length 5
to 1023 octets long.
The phrRate parameter selects between either using the standard 850 kbps
phrRate
rate for PHR symbols or using a higher rate – same as the data rate
The sfdTO parameter sets the SFD timeout value. The purpose of the SFD
detection timeout is to recover from the occasional false preamble detection
events that may occur. By default, this value is 4096 + 64 + 1 symbols, which is
just longer the longest possible preamble and SFD sequence. This is the
sfdTO maximum value that is sensible. When it is known that a shorter preamble is
being used then the value can be reduced appropriately. The function does
not allow a value of zero. (If a 0 value is selected the default value of 4161
symbols (DWT_SFDTOC_DEF) will be used). The recommended value is
preamble length + 1 + SFD length – PAC size.
The stsMode parameter sets one of four possible STS modes: no STS, STS
stsMode
before PHR, STS after data, or no data mode.
The stsLength parameter specifies STS length. The API supports the lengths
stsLength
defined by the dwt_sts_lengths_e.
The dwt_configure() function does not error check the input parameters unless the
DWT_API_ERROR_CHECK code switch is defined. If this is defined, it will assert in case an error is
detected. It is up to the developer to ensure that the assert macro is correctly enabled in order to
trap any error conditions that arise. If DWT_API_ERROR_CHECK switch is not defined, error checks
are not performed.
NOTE: SFD timeout cannot be set to 0; if a zero value is passed into the function the default value will
be programmed. To minimise power consumption in the receiver, the SFD timeout of the receiving
device, sfdTO parameter, should be set according to the TX preamble length of the transmitting
device. As an example, if the transmitting device is using 128 preamble length, an SFD length of 8 and
a PAC size of 8, the corresponding receiver should have sfdTO parameter set to 129 (128 + 1 + 8 - 8).
In addition to the preamble codes in shown in Table 2 above, for 64 MHz PRF there are eight additional
preamble codes, (13 to 16, and 21 to 24), available for use on all channels. These should only be
selected as part of implementing dynamic preamble selection (DPS). Please refer to the IEEE 802.15.4
standard [3] for more details of the dynamic preamble selection technique.
The preamble sequence used on a particular channel is the same at all data rates, however its length,
(i.e. the number of symbol times for which it is repeated), has a significant effect on the operational
range. Table 3 gives some recommended preamble sequence lengths to use depending on the data
rate. In general, a longer preamble gives improved range performance and better first path time of
arrival information while a shorter preamble gives a shorter air time and saves power. When
operating a low data rate for long range, then a long preamble is needed to achieve that range. At
higher data rates the operating range is naturally shorter so there is no point in sending an overly long
preamble as it wastes time and power for no added range advantage.
Recommended preamble
Data Rate
sequence length
6.8Mbps 32, 64, 128 or 256
850kbps 256, or higher
The preamble sequence is detected by cross-correlating in chunks which are a number of preamble
symbols long. The size of chunk used is selected by the PAC size configuration, which should be
selected depending on the expected preamble size. A larger PAC size gives better performance when
the preamble is long enough to allow it. But if the PAC size is too large for the preamble length then
receiver performance will reduce or fail to work at the extremes – (e.g. a PAC of 32 will never receive
frames with just 32 preamble symbols). Table 4 below gives the recommended PAC size configuration
to use in the receiver depending on the preamble length being used in the transmitter.
Expected preamble
Recommended
length of frames being Data Rate
PAC size
received
32 6.81 Mb/s 4
≥ 64 6.81 Mb/s 8
≥ 128 850 kb/s 16
This function configures the STS mode (defined in Table 5). When STS modes 1 or 2 are configured,
the IC will transmit a STS after the SFD (in Mode 1) or after data (in Mode 2). The STS PRF will match
the Ipatov. The API supports a number of STS length configurations as specified by dwt_sts_lengths_e.
Prior to transmission of STS, a 128-bit IV (initial value), via counter register, generates a 128-bit
“NONCE” value which with the 128-bit key value feeds into the CPRNG block (pseudo-random number
generator block) to generate codes for each pair of preamble symbols, see Figure 6. The supported
PRF is 64 MHz.
A user is expected to either set a unique key and IV e.g. per ranging/communication session is started
between a number of devices, or keep the same key for some time but update the IV (e.g. the low x
bits) to keep session secure. Optionally Super Deterministic Codes can be used, this means that the
programming of STS key and IV is not necessary.
Table 5: stsMode parameter to dwt_configure() function
The QM33120 supports four STS modes of operation, the packet format of each of these is shown in
Figure 5. When the STS modes are used then the IC will transmit a STS preamble, which is a pseudo-
random sequence of pulses. This pseudo-random sequence is based on AES128 in counter mode.
The host controller needs to provide the IC with a seed and Initial Value, which can be
(re)programmed individually (for this dwt_configurestskey() and dwt_configurestsiv() APIs are used).
Assuming the seed is not changed, and the counter is not reset between packets (i.e. by loading a new
Initial Value), then a different set of STS symbols will be generated as a result of the natural
advancement of the counter. These will be applied to generate the STS that is either used for the
transmitted frames, or used in the receiver to correlate with the symbols of the STS in the received
frame. Over time the counter will generate 231 - separate 128-bit values before it repeats.
5.2.2 dwt_restoreconfig
void dwt_restoreconfig(void);
This function needs to be called after device is woken up from DEEPSLEEP/SLEEP state, to restore the
configuration and calibration data which has not been automatically restored from AON.
Parameters:
none
Return Parameters:
none
Notes:
After a device has woken from a sleep state, this function must be called in order to restore
configurations such as LDO configuration, bias tuning and gear table configuration.
5.2.3 dwt_setplenfine
This API function is used to configure frame preamble length, the frame preamble length can be
configured in steps of 8, from 16 to 2048 symbols. If a non-zero value is configured, then the
TXPSR_PE setting is ignored.
Parameters:
Return Parameters:
none
Notes:
5.2.4 dwt_configuretxrf
typedef struct
{
uint8_t PGdly; //Pulse generator delay value
uint32_t power; //the TX power – 4 bytes
uint16_t PGcount; //Pulse generator count value
} dwt_txconfig_t ;
Return Parameters:
none
Notes:
This function can be called any time and it will configure the IC’s TX spectrum parameters. The config
parameter points to a dwt_txconfig_t structure (shown above) with fields to configure the pulse
generator delay (PGdly), TX power (power), and pulse generator count (PGCount). Recommended
values for PGdly are given in Table 6 below. (this may be called to adjust power and bandwidth as
temperature fluctuates)
Table 7 above gives the recommended TX power settings. The use of the individual octet values of the
4-byte TX power array are specified in Table 8, for further details of the power values please refer to
the User Manual [2].
NB: The values in Table 7 have been chosen to suit Decawave’s evaluation boards. For other
hardware designs the values here may need to be changed as part of the transmit power calibration
activity, and there is a location in OTP memory where the calibrated values can be stored and then
read and programmed from the application code. Please consult with Decawave’s applications
support team for details of transmit power calibration procedures and considerations.
5.2.5 dwt_adjust_tx_power
This function calculates a new TX power setting (adj_tx_power) relative to a reference TX power setting
(ref_tx_power) and a boost to apply on top on this reference setting. The function finds the best possible
adjustment that can be made to give the closest solution (power value) corresponding to the required boost.
The boost which is applied is provided through applied_boost parameter. The setting calculation depends on
the operating channel (channel).
This function is typically used to give a benefit of the additional TX power than can be transmitted for shorter
frames.
Parameters:
uint16_t boost The amount of boost in 0.1dB step to be applied on top of the
reference TX power setting.
uint8_t channel The channel for which the calculation must be performed.
uint16_t applied_boost The amount of boost in 0.1dB step that was effectively applied
by the API on top of the reference TX power setting.
Return Parameters:
Type Description
Notes:
Example:
Theoretical boost between 1000us and 250us is 6dB (Boost = 10*log10(ref_duration/fr_duration))
Input:
reference_tx_power: 0x4a4a4a4a // Setting for 1000s frame to comply with regulation
boost = 60 // 6dB in 0.1dB steps
channel = 9
Output:
adj_tx_power: 0x9a9a9a9a// Setting for 250s frame to comply with regulation
applied_boost: 58 //Actual boost that was applied is 5.8dB
The setting 0x9a9a9a9a should be use to transmit a 250us frame in channel 9 and comply with
regulations.
5.2.6 dwt_setrxantennadelay
This function sets the RX antenna delay. The antennaDelay value passed is programmed into the RX
antenna delay register. This needs to be set so that the RX timestamp is correctly adjusted to
account for the time delay between the antenna and the internal digital RX timestamp event. This is
determined by a calibration activity. Please consult with Decawave applications support team for
details of antenna delay calibration procedures and considerations.
Parameters:
Return Parameters:
none
Notes:
This function is used to program the RX antenna delay.
5.2.7 dwt_getrxantennadelay
uint16_t dwt_getrxantennadelay(void);
This function returns the RX antenna delay, the value programmed into the RX antenna delay
register.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function is used to read the RX antenna delay programmed in the device.
5.2.8 dwt_settxantennadelay
This function returns the TX antenna delay, the value programmed into the TX antenna delay
register.
Parameters:
Return Parameters:
none
Notes:
This function is used to program the TX antenna delay.
5.2.9 dwt_gettxantennadelay
uint16_t dwt_gettxantennadelay(void);
This function sets the TX antenna delay. The antennaDelay value passed is programmed into the TX
antenna delay register. This needs to be set so that the TX timestamp is correctly adjusted to
account for the time delay between internal digital TX timestamp event and the signal actually
leaving the antenna. This is determined by a calibration activity. Please consult with Decawave
applications support team for details of antenna delay calibration procedures and considerations.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function is used to read the TX antenna delay programmed in the device .
5.2.10 dwt_setpdoaoffset
This function sets PDoA offset, the PDoA result (dwt_readpdoa()) will have this offset applied.
Parameters:
Return Parameters:
none
Notes:
5.2.11 dwt_readpdoaoffset
uint16_t dwt_readpdoaoffset(void);
This function reads PDoA offset as is currently set in the device. The values is in DWT_TIME_UNITS
(15.65 picoseconds ticks).
Parameters:
none
Return Parameters:
Type Description
Notes:
5.2.12 dwt_configurestskey
This function can be used to configure the STS 128-bit AES key value. The default value is [31:0]
C9A375FA, [63:32] 8DF43A20, [95:64] B5E5A4ED, [127:96] 0738123B
Parameters:
typedef struct
{
uint32_t key0;
uint32_t key1;
uint32_t key2;
uint32_t key3;
} dwt_ata_cp_key_t;
Return Parameters:
none
Notes:
5.2.13 dwt_configurestsiv
This function is used to configure the STS 128-bit initial value. The default value is 1, i.e. the IC reset
value is 1. A value of all 0 is invalid and the IC will automatically detect this condition and set it to 1.
Parameters:
typedef struct
{
uint32_t iv0;
uint32_t iv1;
uint32_t iv2;
uint32_t iv3;
} dwt_sts_cp_iv_t;
Return Parameters:
none
Notes:
In order to make the counter more random its initial state (IV) is seeded from time to time (updating
frequency should be less than its period). For security reasons the key should also be updated at the
same time (with a different value).
The values it generates act as a nonce which together with the supplied key are used to generate the
STS.
5.2.14 dwt_configurestsloadiv
This function is used to load the IV and KEY initial value into the STS AES block.
Parameters:
none
Return Parameters:
none
Notes:
If this function is called when reloading the counter with a previously set IV, without changing the key,
then the generated STS sequence will potentially be repeating in a predictable way. While this may
be useful in some testing scenarios, it could be a security risk if it were done in normal operation,
where any reloading of the counter should be accompanied by a new key load also.
5.2.15 dwt_configurestsmode
This function configures STS mode (e.g. DWT_STS_MODE_OFF, DWT_STS_MODE_1, etc.) The
dwt_configure() should be called prior to this to configure other parameters.
Parameters:
uint8_t stsMode The STS mode that the device should be configured for.
Return Parameters:
none
Notes:
For more information on the input parameter, please see Table 5: stsMode parameter to
dwt_configure() function.
5.2.16 dwt_configuresfdtype
This function configures SFD type only: e.g. IEEE 4a - 8, DW-8, DW-16, or IEEE 4z -8 (binary). The
dwt_configure() should be called prior to this to configure other parameters.
Parameters:
This value is used to assign the SFD type used when configuring
uint8_t sfdType
the device. Please see Table 9 for more information.
Return Parameters:
none
5.2.17 dwt_setleds
This is used to set up Tx/Rx GPIOs which are then used to control (for example) LEDs. This is not
completely IC dependent; it requires that LEDs are connected to the GPIO lines.
Parameters:
Return Parameters:
none
Notes:
For more information on GPIO control and configuration please consult the User Manual [2] and Data
Sheet [1].
5.2.18 dwt_setlnapamode
This is used to enable GPIO for external LNA or PA functionality – HW dependent, consult the User
Manual [2]. This can also be used for debug as enabling TX and RX GPIOs is can help monitoring the
IC's activity.
Parameters:
Return Parameters:
none
Notes:
Enabling PA functionality requires that fine grain TX sequencing is deactivated. This can be done using
the dwt_setfinegraintxseq() API function.
For more information on GPIO control and configuration please consult the User Manual [2] and Data
Sheet [1].
5.2.19 dwt_generatecrc8
This function is used to generate 8-bit CRC to send as part of SPI write transaction when the IC is
configured for SPI CRC check mode.
Parameters:
uint8_t* byteArray This array supplies the bytes for which to calculate the CRC.
Return Parameters:
Type Description
Notes:
It is possible to calculate CRC for two separate blocks (that will be sent as one contiguous SPI
transaction) by calling the dwt_generatecrc8() function twice, once for each; setting the first
crcRemainderInit parameter to the configured CRC seed (zero by default), and the second
crcRemainderInit parameter to the CRC value returned from the first call to the dwt_generatecrc8()
function.
5.2.20 dwt_enablespicrccheck
This function can be used to enable or disable the SPI CRC check in the IC.
Parameters:
Return Parameters:
none
Notes:
The crc_mode parameter is used to select the CRC mode to be used. The following table shows all the
available options in the dwt_spi_crc_mode_e enum that is used to contain the argument:
Table 10: Valid crc_mode options
During normal SPI mode the SPICRC bit of the SYS_STATUS_LO register will be asserted. When using
SPI CRC check mode this will only be asserted if there is a mismatch between the CRC byte calculated
by the IC and the one sent in the SPI write transaction.
5.2.21 dwt_configmrxlut
This function sets the default values of the lookup tables depending on the channel selected.
Parameters:
Return Parameters:
none
Notes:
The lookup table contains the desired front-end settings for the chosen level of noise dithering.
Different settings will apply for channel 5 or channel 9. The seven registers starting at
DGC_DGC_LUT_0_CFG and ending at DGC_DGC_LUT_6_CFG are populated as follows depending on
the channel given:
5.2.22 dwt_enablegpioclocks
void dwt_enablegpioclocks(void);
This function enables the GPIO clocks on the IC. GPIO clocks are required to ensure correct GPIO
operation.
Parameters:
none
Return Parameters:
none
Notes:
An example of how this API can be used is included the API package [5]. Also, please see Example
13a: Use of DW3XXX GPIO lines.
5.2.23 dwt_setgpiomode
This function is used to configure the GPIO mode of one or more GPIO pins. The gpio_mask
parameter allows to only configure the mode of specific pins, without altering the mode of other
pins.
Parameters:
The mask of the GPIOs to change the mode of. Typically built
uint32_t gpio_mask
from dwt_gpio_mask_e values.
Return Parameters:
none
Notes:
An example of how this API can be used is included the API package [5]. Also, please see Example
13a: Use of DW3XXX GPIO lines.
5.2.24 dwt_setgpiodir
Return Parameters:
none
Notes:
An example of how this API can be used is included the API package [5]. Also, please see Example
13a: Use of DW3XXX GPIO lines.
5.2.25 dwt_setgpiovalue
This is used to set output value on GPIOs that have been configured for output via dwt_setgpiodir()
API
Parameters:
Return Parameters:
none
Notes:
5.2.26 dwt_pgf_cal
This function sets up the PGF calibration and then calls dwt_run_pgfcal() to run the calibration. This
is needed prior to reception of any frames/packets.
Parameters:
Return Parameters:
Type Description
Notes:
5.2.27 dwt_run_pgfcal
int dwt_run_pgfcal(void);
This function runs the PGF calibration. It is usually called by dwt_pgf_cal(). This is needed prior to
reception of any frames/packets.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.2.28 dwt_pll_cal
int dwt_pll_cal(void);
This function will be used to recalibrate and relock the PLL. If the cal/lock is successful
DWT_SUCCESS will be returned otherwise DWT_ERROR will be returned.
Parameters:
none
Return Parameters:
Type Description
5.2.29 dwt_setdwstate
This function can place DW3xxx into IDLE/IDLE_PLL or IDLE_RC mode when it is not actively in TX or
RX.
Parameters:
Return Parameters:
none
Notes:
5.2.30 dwt_enable_disable_eq
This function enables or disables the equaliser block within in the CIA block within the QM331XX.
The equaliser should be used when receiving from devices which transmit using a Symmetric Root
Raised Cosine pulse shape. The equaliser will adjust the CIR to give improved receive timestamp
results. Normally, this is left disabled (the default value), which gives the best receive timestamp
performance when interworking with devices (like this IC) that use the IEEE 802.15.4z recommended
minimum precursor pulse shape.
Parameters:
Return Parameters:
none
Notes:
5.2.31 dwt_configure_rf_port
Parameters:
Return Parameters:
none
Notes:
5.2.32 dwt_configure_and_set_antenna_selection_gpio
Parameters:
Return Parameters:
none
Notes:
5.2.33 dwt_wifi_coex_set
Parameters:
typedef enum
{
DWT_EN_WIFI_COEX=0, /* Configure GPIO for WiFi co-ex - GPIO high*/
DWT_DIS_WIFI_COEX /* Configure GPIO for WiFi co-ex - GPIO low */
}dwt_wifi_coex_e;
Return Parameters:
none
Notes:
© Decawave Ltd 2021 Version 2.2 Page 53 of 155
DW3XXX API GUIDE
5.2.34 dwt_set_fixedsts
This API enables "Fixed STS" function. The fixed STS function means that the same STS will be sent in
each packet. And also in the receiver, each time the receiver is enabled, the STS will be reset. Thus,
transmitter and the receiver will be in sync.
Parameters:
Return Parameters:
none
5.2.35 dwt_set_alternative_pulse_shape
Parameters:
Return Parameters:
none
Notes:
Below is the image for the usual pulse shape grey colour and alternate pulse shape according to ARIB STD-T91
in blue colour, fitting inside the limits of standard.
5.2.36 dwt_config_ostr_mode
Parameters:
Return Parameters:
none
Notes:
At the time the SYNC signal is asserted, the clock PLL dividers generating the 125 MHz system clock
are reset, to ensure that a deterministic phase relationship exists between the system clock and the
asynchronous 38.4 MHz external clock. For this reason, the WAIT value programmed will dictate the
phase relationship and should be chosen to give the desired phase relationship, as given by WAIT
modulo 4. A WAIT value of 33 decimal is recommended, but if a different value is chosen it should be
chosen so that WAIT modulo 4 is equal to 1, i.e. 29, 37, and so on.
5.3.1 dwt_writetxdata
This is the total length to write into the TX buffer, it can include
the space for the two-byte CRC but it does not have to. The
uint16_t txBufferLength device will automatically put a two-byte CRC in the last two bytes
of the TX data it is sending. The length of data to transmit is
specified by the txFrameLength parameter in dwt_writetxfctrl()
Return Parameters:
Type Description
Notes:
This function writes the specified size of txBuffLength bytes from the memory, pointed to by the
txBuffBytes parameter, into the device’s internal transmit data buffer, starting at the specified offset
(txBufferOffset). During the transmission, the device will automatically add the two CRC bytes to
complete the TX frame to its txFrameLength as specified by the txFrameLength parameter in
dwt_writetxfctrl ().
NOTE: standard PHR mode allows frames of up to 127 bytes. For longer lengths non-standard PHR
mode DWT_PHRMODE_EXT needs to be set in the phrMode configuration passed into the
dwt_configure() function.
The dwt_writetxfctrl() function checks that the sum of txBufferLength and txBufferOffset is less than
the max (1024 bytes) internal TX buffer length to avoid messing with IC’s other registers and memory.
If such an error occurs, the write is not performed and the function returns DWT_ERROR. Otherwise,
the functions returns DWT_SUCCESS.
If DWT_API_ERROR_CHECK code switch is defined, the function will perform additional checks on
input parameters. If an error is detected, the function will assert. It is up to the developer to ensure
that the assert macro is correctly enabled in order to trap any error conditions that arise.
Example code:
Typical usage is to write the data, configure the frame control with starting buffer offset and frame
length and then enable transmission as follows:
dwt_writetxdata(fLength,dataBuffPtr,0); // write the frame data at offset 0
dwt_writetxfctrl(fLength+2,0,0); // set the frame control register
dwt_starttx(DWT_START_TX_IMMEDIATE); // send the frame
5.3.2 dwt_writetxfctrl
uint16_t txFrameLength This is the total frame length, including the two-byte CRC.
Return Parameters:
none
Notes:
This function configures the TX frame control register parameters, namely the length of the frame and
the offset in the IC’s transmit data buffer where the data starts. It also controls whether the ranging
bit is set in the frame’s PHR.
The ranging bit identifies a frame as a ranging frame. This has no operational effect on the IC, but in
some receiver implementations, it might be used to enable hardware or software associated with
time stamping the frame. In the IC’s receiver, the time stamping does not depend or use the ranging
bit in the received PHR. The status of the ranging bit in received frames is reported by the cbRxOk
function (if enabled) in the rx_flags element of its dwt_cb_data_t structure parameter. See the
dwt_isr() and the dwt_setcallbacks() functions.
The dwt_writetxfctrl() function does not error check the txFrameLength and the txBufferOffset input
parameter unless the DWT_API_ERROR_CHECK code switch is defined. If this is defined it will assert if
an error is detected. It is up to the developer to ensure that the assert macro is correctly enabled in
order to trap any error conditions that arise.
Example code:
Typical usage is to write the data, configure the frame control with starting buffer offset and frame
length and then enable transmission as follows:
dwt_writetxdata(fLength,dataBuffPtr,0); // write the frame data at offset 0
dwt_writetxfctrl(fLength+2,0,0); // set the frame control register
dwt_starttx(DWT_START_TX_IMMEDIATE); // send the frame
5.3.3 dwt_starttx
This function initiates transmission of the frame. The mode parameter is described below.
Parameters:
This is a bit mask defining the operation of the function, see notes and
uint8_t mode
Table 13.
Return Parameters:
Type Description
Notes:
This function is called to start the transmission of a frame.
In performing a delayed transmission, if the host microprocessor is late in invoking the dwt_starttx()
function, (i.e. so that the IC’s system clock has passed the specified starttime and would have to
complete almost a whole clock count period before the start time is reached), then the transmission
is aborted (transceiver off) and the dwt_starttx() function returns the -1 error indication.
Table 13: Mode parameter to dwt_starttx() function
Mask
Mode Description
Value
DWT_START_TX_IMMEDIATE 0x0 The transmitter starts sending frame immediately.
The transmitter will start sending a frame once the programmed
DWT_START_TX_DELAYED 0x1 starttime is reached.
See dwt_setdelayedtrxtime().
Response is expected, once the frame is sent the transceiver will
enter receive mode to wait for response message. See
DWT_RESPONSE_EXPECTED 0x2 dwt_setrxaftertxdelay(). NOTE all of the START_TX commands
can include DWT_RESPONSE_EXPECTED to enable receiver after
completed transmission event.
The transmitter will start sending a frame at specified time
(which is the sum of time in DREF_TIME register + any time in
DWT_START_TX_DLY_REF 0x4
DX_TIME register, i.e. programmed refttime and starttime) See
dwt_setreferencerxtime() and dwt_setdelayedtrxtime().
The transmitter will start sending a frame at specified time
(which is the sum of RX timestamp + any time in DX_TIME
DWT_START_TX_DLY_RS 0x8
register, i.e. last received timestamp and starttime) See
dwt_readrxtimestamphi32()and dwt_setdelayedtrxtime().
The transmitter will start sending a frame at specified time
(which is the sum of TX timestamp + any time in DX_TIME
DWT_START_TX_DLY_TS 0x10
register, i.e. last transmitted timestamp and starttime) See
dwt_readtxtimestamphi32() and dwt_setdelayedtrxtime().
The transmitter will start sending a frame if no preamble is
DWT_START_TX_CCA 0x20 detected within PTO time (as configured in preamble timeout
register see dwt_setpreambledetecttimeout())
Example code:
Typical usage is to write the data, configure the frame control with starting buffer offset and frame
length and then enable transmission as follows:
dwt_writetxdata(fLength,dataBuffPtr,0); // write the frame data at offset 0
dwt_writetxfctrl(fLength,0,0); // set the frame control register
dwt_starttx(DWT_START_TX_IMMEDIATE); // send the frame
5.3.4 dwt_setdelayedtrxtime
This function sets a send time to use in delayed send or the time at which the receiver will turn on (a
delayed receive). This function should be called to set the required send time before invoking the
dwt_starttx() function (above) to initiate the transmission (in DELAYED_TX mode), or dwt_rxenable()
(below) with delayed parameter set to 1.
Parameters:
uint32_t starttime The TX or RX start time. The 32-bit value is the high 32-bits of the
system time value at which to send the message, or at which to
turn on the receiver. The low order bit of this is ignored. This
essentially sets the TX or RX time in units of approximately 8 ns.
(or more precisely 512/(499.2e6*128) seconds)
Return Parameters:
none
Notes:
This function is called to program the delayed transmit or receive start time. The starttime parameter
specifies the time at which to send/start receiving, when the system time reaches this time (minus
the times it needs to send preamble etc.) then the sending of the frame begins. The actual time at
which the frame’s RMARKER transits the antenna (the standard TX timestamp event) is given by the
starttime + the transmit antenna delay. If the application wants to embed this time into the message
being sent it must do this calculation itself.
The system time counter is 40 bits wide, giving a wrap period of 17.20 seconds.
NOTE: Typically, delayed sending might be used to give a fixed response delay with respect to an
incoming message arrival time, or, because the application wants to embed the message send time
into the message itself. The delayed receive might be used to save power and turn the receiver on
only when response message is expected.
Example code:
Typical usage is to write the data, configure the frame control with starting buffer offset and frame
length and then enable transmission as follows:
In this example the previous frame’s TX timestamp time is used, and a new frame is sent with 100 ms
delay from the previous TX time. The full 40-bit representation of 100 ms would be 0x17CDC0000,
however as the delay register uses high 32 bits only a value of 0x17CDC00 is used.
5.3.5 dwt_setreferencerxtime
This function sets a reference time to which any delay time is added (as specified by starttime in
dwt_setdelayedtrxtime()). The sum of both will be used as a delayed send time or the time at which
the receiver will turn on (a delayed receive). This function should be called to set the required
reference time before invoking the dwt_starttx() function (above) to initiate the transmission (in
DELAYED_TX mode), or dwt_rxenable() (below) with delayed parameter set to 1.
Parameters:
Return Parameters:
none
Notes:
This function is called to save the delayed transmit or receive reference time. The reftime parameter
specifies a time at which for example a “sync or beacon” frame was sent, and which will be used as a
reference w.r.t. which other frames will be sent/received.
The system time counter is 40 bits wide, giving a wrap period of 17.20 seconds.
NOTE: Typically, delayed sending might be used to give a fixed response delay with respect to an
incoming message arrival time, or, because the application wants to embed the message send time
into the message itself. The delayed receive might be used to save power and turn the receiver on
only when response message is expected.
Example code:
Typical usage is to write the data, configure the frame control with starting buffer offset and frame
length and then enable transmission as follows:
In this example consider a reference “sync or beacon” frame is sent at reference time. This time is
saved in the reference register. Then, sometime later, we wish to transmit a frame 100 ms after this
time, perhaps a next beacon frame. The full 40-bit representation of 100ms would be 0x17CDC0000,
however as the reference time register contains only the high 32 bits a value of 0x17CDC00 is used.
(The TX timestamp value should be read after a TX done interrupt triggers.)
{
// start TX was late, TX has been aborted.
// Application should take appropriate recovery activity
}
5.3.6 dwt_readtxtimestamp
This function reads the actual time at which the frame’s RMARKER transits the antenna (the
standard TX timestamp event). This time will include any TX antenna delay if programmed via the
dwt_gettxantennadelay() API function. The function returns a 40-bit timestamp value in the buffer
passed in as the input parameter.
Parameters:
The pointer to the buffer into which the timestamp value is read.
uint8_t* timestamp (The buffer needs to be at least 5 bytes long.) The low order byte
is the first element.
Return Parameters:
none
Notes:
This function can be called after the transmission complete event, DWT_INT_TFRS (see dwt_isr()
function).
5.3.7 dwt_readtxtimestamplo32
uint32_t dwt_readtxtimestamplo32(void);
This function returns the low 32-bits of the 40-bit transmit timestamp ( dwt_readtxtimestamp()).
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called after the transmission complete event, DWT_INT_TFRS (see dwt_isr()
function).
5.3.8 dwt_readtxtimestamphi32
uint32_t dwt_readtxtimestamphi32(void);
This function returns the high 32-bits of the 40-bit transmit timestamp.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called after the transmission complete event, DWT_INT_TFRS (see dwt_isr()
function).
5.3.9 dwt_readrxtimestamp
This function returns the time at which the frame’s RMARKER is received, including the antenna
delay adjustments if this is programmed via the dwt_setrxantennadelay() API function. The function
returns a 40-bit value.
Parameters:
uint8_t* timestamp The pointer to the buffer into which the timestamp value is read.
(The buffer needs to be at least 5 bytes long.) The low order byte
is the first element.
Return Parameters:
none
Notes:
This function can be called after the frame received event, DWT_INT_RFCG (see dwt_isr() function).
Which means we have a good FCS and a valid timestamp.
5.3.10 dwt_readrxtimestamp_ipatov
This function returns the time at which the frame’s RMARKER is received, including the antenna
delay adjustments if this is programmed via the dwt_setrxantennadelay() API function, w.r.t. Ipatov
CIR. The function returns a 40-bit value.
Parameters:
uint8_t* timestamp The pointer to the buffer into which the timestamp value is read.
(The buffer needs to be at least 5 bytes long.) The low order byte
is the first element.
Return Parameters:
none
Notes:
This function can be called after the frame received event, DWT_INT_RFCG (see dwt_isr() function).
Which means we have a good FCS and a valid timestamp.
5.3.11 dwt_readrxtimestamp_sts
This function returns the time at which the frame’s RMARKER is received, including the antenna
delay adjustments if this is programmed via the dwt_setrxantennadelay() API function, w.r.t. STS CIR.
It is only valid if packet with STS is used, see dwt_configure(). The function returns a 40-bit value.
Parameters:
uint8_t* timestamp The pointer to the buffer into which the timestamp value is read.
(The buffer needs to be at least 5 bytes long.) The low order byte
is the first element.
Return Parameters:
none
Notes:
This function can be called after the frame received event, DWT_INT_RFCG (see dwt_isr() function).
Which means we have a good FCS and a valid timestamp.
5.3.12 dwt_readrxtimestampunadj
This function returns the raw time at which the frame’s RMARKER is received before any CIA first
path algorithm adjustments. This will be the high 32-bits of the 40-bit system time.
Parameters:
uint8_t* timestamp The pointer to the buffer into which the timestamp value is read.
(The buffer needs to be at least 4 bytes long.) The low order byte
is the first element.
Return Parameters:
none
Notes:
5.3.13 dwt_readrxtimestamplo32
uint32_t dwt_readrxtimestamplo32(void);
This function returns the low 32-bits of the 40-bit received timestamp ( dwt_readrxtimestamp()).
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called after the frame received event, DWT_INT_RFCG (see dwt_isr () function).
Which means we have a good FCS and a valid timestamp.
This API should not be used when using Double RX buffer mode (see dwt_setdblrxbuffmode ()), as it
will not return a valid RX time. dwt_readrxtimestamp_ipatov() or dwt_readrxtimestamp_sts() should
be used instead.
5.3.14 dwt_readrxtimestamphi32
uint32_t dwt_readrxtimestamphi32(void);
This function returns the high 32-bits of the 40-bit received timestamp ( dwt_readrxtimestamp()).
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called after the frame received event, DWT_INT_RFCG (see dwt_isr() function).
Which means we have a good FCS and a valid timestamp.
This API should not be used when using Double RX buffer mode (see dwt_setdblrxbuffmode()), as it
will not return a valid RX time. dwt_readrxtimestamp_ipatov() or dwt_readrxtimestamp_sts() should
be used instead.
5.3.15 dwt_readsystime
This function returns the system time, which is a high 32-bit value of internal 40-bit system counter.
The time will only be valid when the IC is in IDLE, TX or RX states because the system timer is
running, the timer is disabled in IDLE_RC or SLEEP states.
Parameters:
uint8_t* timestamp The pointer to the buffer into which the timestamp value is read.
(The buffer needs to be at least 4 bytes long.) The low order byte
is the first element. The low order bit will always be 0, as the
system timer runs in units of approximately 8 ns. (more precisely
512/(499.2e6*128) seconds or 63.8976GHz).
Return Parameters:
none
Notes:
This function can be called to read the system time, when the IC is not in the INIT state.
DW3000 note: once this register is read the system time value is latched and any subsequent read
will return the same value. To clear the current value in the register an SPI write transaction is
necessary, the following read of the SYS_TIME register will return a new value.
5.3.16 dwt_readsystimestamphi32
uint32_t dwt_readsystimestamphi32(void);
This function returns the high 32-bits of the 40-bit system time. The LSB will always be 0, as the
system timer runs in units of approximately 8 ns. (more precisely 512/(499.2e6*128) seconds or
63.8976GHz).
Parameters:
none
Return Parameters:
Type Description
Notes:
This function can be called to read the IC system time.
DW3000 note: once this register is read the system time value is latched and any subsequent read
will return the same value. To clear the current value in the register an SPI write transaction is
necessary, the following read of the SYS_TIME register will return a new value.
5.3.17 dwt_reset_system_counter
void dwt_reset_system_counter(void);
This function will reset the internal system time counter. The counter will be momentarily reset to 0,
and then will continue counting as normal. The system time/counter is only available when device is
in IDLE or TX/RX states.).
Parameters:
none
Return Parameters:
none
Notes:
5.3.18 dwt_forcetrxoff
void dwt_forcetrxoff(void);
This function may be called at any time to disable the active transmitter or the active receiver and
put the IC back into idle mode (transceiver off).
Parameters:
none
Return Parameters:
none
Notes:
The dwt_forcetrxoff() function can be called any time and it will disable the active transmitter or
receiver and put the device in IDLE mode. It issues a transceiver off command to the IC and also
clears status register event flags, so that there should be no outstanding/pending events for
processing.
5.3.19 dwt_rxenable
This function turns on the receiver to wait for a receive frame. The mode parameter is a bit field
that allows for selection of number of different RX operations as defined in Table 14. In delayed RX
modes the receiver is not turned on until as specific time, set via dwt_setdelayedtrxtime() and
dwt_setreferencerxtime(). This facility is useful to save power in the case when the timing of a
response is known. The mode parameter also controls whether the receiver is enabled in case of
error, i.e. the delayed RX being late, see notes below for details.
Parameters:
This is a bit mask defining the operation of the function, see notes
int mode
and
Return Parameters:
Type Description
Notes:
This function can be called any time to enable the receiver. The device should be initialised and have
its RF configuration set.
In performing a delayed RX, the host microprocessor can be late in invoking the dwt_rxenable(), (i.e.
the system clock has passed the starttime specified in the call to the dwt_setdelayedtrxtime()
function). The IC has a status flag warning when the specified start time is more than a half period (of
the system clock) away. If this is the case, since the clock has a period of over 17 seconds, it is
assumed that such a long RX delay is not needed, and the delayed RX is cancelled. The receiver is
then either immediately enabled or left off depending on whether DWT_IDLE_ON_DLY_ERR was set
in the supplied “mode” parameter, and error flag is returned indicating that the RX on was late. It is
up to the application to take whatever remedial action is needed in the case of this late error.
Table 14: Mode parameter to dwt_rxenable() function
Mask
Mode Description
Value
DWT_START_RX_IMMEDIATE 0x00 The receiver is activated immediately.
The receiver, otherwise the receiver will be turned on when
DWT_START_RX_DELAYED 0x01 the time reaches the starttime set through the
dwt_setdelayedtrxtime().
This applies only when a delayed start is determined to be
late (see notes above). If this is set the receiver will not be
DWT_IDLE_ON_DLY_ERR 0x02
enabled in case of a late error, i.e. the IC will be left in IDLE
mode. Otherwise, the receiver will be enabled
The receiver will be enabled at specified time (which is the
sum of time in DREF_TIME register + any time in DX_TIME
DWT_START_RX_DLY_REF 0x04
register, i.e. programmed refttime and starttime) See
dwt_setreferencerxtime() and dwt_setdelayedtrxtime().
Mask
Mode Description
Value
The receiver will be enabled at specified time (which is the
sum of RX timestamp + any time in DX_TIME register, i.e.
DWT_START_RX_DLY_RS 0x08
last received timestamp and starttime) See
dwt_readrxtimestamphi32()and dwt_setdelayedtrxtime().
The receiver will be enabled at specified time (which is the
sum of TX timestamp + any time in DX_TIME register, i.e.
DWT_START_RX_DLY_TS 0x10
last transmitted timestamp and starttime) See
dwt_readtxtimestamphi32() and dwt_setdelayedtrxtime().
5.3.20 dwt_setsniffmode
When the receiver is enabled, it begins looking for preamble sequence symbols, and by default, in this
preamble-hunt mode the receiver is continuously active. This dwt_setsniffmode() function allows the
configuration of a lower power preamble-hunt mode. In SNIFF mode the receiver (RF and digital) is not on all
the time, but rather is sequenced on and off with a specified duty-cycle. Using SNIFF mode causes a reduction
in RX sensitivity depending on the ratio and durations of the on and off periods. See “Low-Power SNIFF mode”
chapter in the User Manual [2] for more details.
Parameters:
The receiver ON time in PACs (as per the rxPAC parameter in the
dwt_config_t structure parameter to the dwt_configure() API
uint8_t timeOn function call). The minimum value for correct operation is 2, giving
an on time of 2 PACs. The maximum value is 15.
Return Parameters:
none
Notes:
This function can be called as part of device receiver configuration.
By default (where this API is not invoked) the IC will operate its receiver in normal reception mode. If
this API is used to enable SNIFF mode this will be maintained until a reset or it is disabled or re-
configured by another call to this dwt_setsniffmode() function. The SNIFF mode setting is not
affected by the dwt_configure() function.
5.3.21 dwt_setdblrxbuffmode
Return Parameters:
none
Notes:
The dwt_setdblrxbuffmode() function is used to configure the receiver in double buffer mode. This
should not be done when the receiver is enabled. It should be selected in idle mode before the
dwt_setdblrxbuffmode() function is called.
Once the data for the received frame is read, the host should call the dwt_signal_rx_buff_free() to let
the device know the buffer is free again, the host will then be ready to read the next received frame.
This is done in the dwt_isr() which handles the IRQ.
The reader is referred to “Double Receive Buffer” chapter in the User Manual [2] for more details.
5.3.22 dwt_signal_rx_buff_free
This function signals to the DW3xxx that the host is finished with current buffer and the buffer is free
for the DW3xxx to receive into again. This function is only relevant if device has double RX buffer
mode enabled.
Parameters:
none
Return Parameters:
none
Notes:
5.3.23 dwt_setrxtimeout
The dwt_setrxtimeout() function sets the receiver to timeout (and disable) when no frame is
received within the specified time. This function should be called before the dwt_rxenable()
function is called to turn on the receiver. The time parameter used here is in 1.0256 us (UWB
microseconds, i.e. 512/499.2 MHz) units. The maximum RX timeout is ~ 1.0754s.
Parameters:
uint32_t time Timeout time in microseconds (1.0256 us). If this is 0, the timeout
will be disabled. The max value is 0xFFFFF.
Return Parameters:
none
Notes:
If RX timeout is being employed then this function should be called before dwt_rxenable() to
configure the frame wait timeout time, and enable the frame wait timeout.
5.3.24 dwt_setrxaftertxdelay
This function sets the delay in turning the receiver on after a frame transmission has completed. The
delay, rxDelayTime, is in UWB microseconds (1 UWB microsecond is 512/499.2 microseconds). It is a
20-bit wide field. This should be set before start of frame transmission after which a response is
expected, i.e. before invoking the dwt_starttx() function (above) to initiate the transmission (in
DWT_RESPONSE_EXPECTED mode). E.g. transmission of a frame with an ACK request bit set.
Parameters:
Return Parameters:
none
Notes:
This function is used to set the delay time before automatic receiver enable after a frame
transmission. The smallest value that can be set is 0. If 0 is set the IC will turn the receiver on as soon
as possible, which approximately takes 6.2 µs. If setting a value smaller than 6.2 µs, the device will still
take 6.2 µs to switch to receive mode.
5.3.25 dwt_setpreambledetecttimeout
This dwt_setpreambledetecttimeout() API function sets the receiver to timeout (and disable) when
no preamble is received within the specified time. This function should be called before the
dwt_rxenable() function is called to turn on the receiver. The time parameter units are PACs (as per
the rxPAC parameter in the dwt_config_t structure parameter to the dwt_configure() API function
call).
Parameters:
uint16_t timeout This is the preamble detection timeout duration. If preamble is not
detected within this time, counted from the time the receiver is
enabled, the receiver will be turned off.
The time here is specified in multiples of PAC size, (as per the rxPAC
parameter in the dwt_config_t structure parameter to the
dwt_configure() API function call). The IC automatically adds 1 to
the configured value. A value of 0 disables the timer and timeout.
Return Parameters:
none
Notes:
If preamble detection timeout is being employed, then this function should be called before
dwt_rxenable() is called.
5.3.26 dwt_readrxdata
This function reads a number, len, bytes from the IC receive data buffer, beginning at the specified
offset, bufferOffset, into the given buffer, buffer.
Parameters:
uint8_t* buffer The pointer to the buffer into which the data will be read.
Return Parameters:
none
Notes:
This function should be called on the reception of a good frame to read the received frame data. The
offset might be used to skip parts of the frame that the application is not interested in or has read
previously.
5.3.27 dwt_read_rx_scratch_data
This is used to read the data from the RX scratch buffer, from an offset location given by offset
parameter.
Parameters:
uint8_t* buffer The pointer to the buffer into which the data will be read.
Return Parameters:
none
Notes:
This function should be called on the reception of a good frame to read the received frame data. The
offset might be used to skip parts of the frame that the application is not interested in or has read
previously.
5.3.28 dwt_write_rx_scratch_data
Parameters:
uint8_t* buffer The pointer to the buffer into which the data will be read.
Return Parameters:
none
5.4.1 dwt_readaccdata
This API function reads data from the IC’s accumulator memory. This data represents the channel
impulse response (CIR) of the RF channel. Reading this data is not required in normal operation but it
may be useful for diagnostic purposes. The accumulator contains complex values, each comprised of
an 18-bit real integer and an 18-bit imaginary integer, for each tap of the accumulator. Each complex
value represents a 1 ns sample interval (or more precisely half a period of the 499.2 MHz fundamental
frequency).
When STS mode is enabled there are two separate accumulations and two CIRs: one during the Ipatov
sequence and one during the STS, both may be read using this dwt_readaccdata() API function. The
Ipatov sequence begins at offset 0 and has a span of one symbol time (This is 992 samples for the
nominal 16 MHz mean PRF, or, 1016 samples for the nominal 64 MHz mean PRF). The STS begins at
offset 1024 and has a span of half a symbol time (512 samples irrespective of PRF setting). If PDOA
mode 3 is used, the STS CIR will be split into two. One half of STS symbols and corresponding CIR will
be received through one antenna port and saved into CIR memory from 1024 to 1535, and the second
half of STS symbols will be received through the other antenna port and saved into CIR memory from
1536 to 2047.
The dwt_readaccdata() function reads, len, bytes of accumulator buffer data, from a given offset,
sampleOffset, into the memory pointed to by the supplied buffer parameter. Each 18-bit complex
sample has 3 bytes of real and 3 bytes of imaginary data (delivered by the IC as signed 24-bit numbers).
The accumulator data starts from buffer[1]. The first byte written to buffer[0] is always a dummy byte,
and to allow for this the specified length should always be 1 bigger than the length required.
When reading from CIR memory with an offset less than 127, a normal SPI read can be used, however
to read data from CIR memory with offset greater than 127, an indirect SPI read has to be done. To
perform an indirect SPI read indirect pointers need to be used: PTR_ADDR_A or PTR_ADDR_B. Firstly
the register address needs to be programmed into e.g. indirect pointer A (PTR_ADDR_A) and offset
into PTR_OFFSET_A and then the indirect pointer register (INDIRECT_PRT_A) needs to be read as
normal to read out the required data. Please see more details on this in DW3XXX User Manual [2].
For example to read the first 2 complex samples of the CIR the function should be done as shown in
the example below:
Example code:
uint8_t cir_buiffer[xx] ;
Note that the length is in bytes while the offset is in complex samples.
Both accumulators can be read together in this case length should be 1536*6 + 1 bytes.
Parameters:
uint8_t* buffer The pointer to the destination buffer into which the read
accumulator data will be written.
uint16_t len The length of data to be read (in bytes). Since each complex
value occupies six octets, the value used here should naturally
be a multiple of six, plus 1 for the dummy byte as described
above. Maximum length is 9217
uint16_t bufferOffset The offset at which to start to read the data. Offset 0 should
be used when reading the full accumulator.
Return Parameters:
none
Notes:
dwt_readaccdata() may be called after frame reception to read the accumulator data for diagnostic
purposes. The accumulator is not double buffered so this access must be done before the receiver is
re-enabled otherwise the accumulator data may be overwritten during the reception of the next frame.
The data returned in the buffer has the following format (for bufferOffset input of zero):
0 Dummy Octet
1 Low 8 bits of real part of accumulator sample index 0
2 Mid 8 bits of real part of accumulator sample index 0
3 High 8 bits of real part of accumulator sample index 0
4 Low 8 bits of imaginary part of accumulator sample index 0
5 Mid 8 bits of imaginary part of accumulator sample index 0
6 High 8 bits of imaginary part of accumulator sample index 0
7 Low 8 bits of real part of accumulator sample index 1
8 Mid 8 bits of real part of accumulator sample index 1
9 High 8 bits of real part of accumulator sample index 1
10 Low 8 bits of imaginary part of accumulator sample index 1
: :
In examining the CIR it is normal to compute the magnitude of the complex values.
5.4.2 dwt_configciadiag
This function can be used to enable full or partial CIA diagnostic calculations in the IC during
reception processing of frame. Note partial diagnostics are enabled by default in the IC.
Parameters:
Return Parameters:
none
Notes:
Turing on diagnostics, means that the reception of a frame consumes some more power and takes
more time while the IC performs the calculations to generate the diagnostic values. The diagnostic
values may be read, as part of the RX callback for instance, using the dwt_readdiagnostics() API.
5.4.3 dwt_readdiagnostics
dwt_rxdiag_t* diagnostics Pointer to the diagnostics structure which will contain the
read data.
typedef struct
{
uint8_t ipatovRxTime[5] ;
uint8_t ipatovRxStatus ;
uint16_t ipatovPOA ;
uint8_t stsRxTime[5] ;
uint16_t stsRxStatus ;
uint16_t stsPOA;
uint8_t sts2RxTime[5];
uint16_t sts2RxStatus;
uint16_t sts2POA;
uint8_t tdoa[6];
int16_t pdoa;
int16_t xtalOffset ;
uint32_t ciaDiag1 ;
uint32_t ipatovPeak ;
uint32_t ipatovPower ;
uint32_t ipatovF1 ;
uint32_t ipatovF2 ;
uint32_t ipatovF3 ;
uint16_t ipatovFpIndex ;
uint16_t ipatovAccumCount ;
uint32_t stsPeak ;
uint32_t stsPower ;
uint32_t stsF1 ;
uint32_t stsF2 ;
uint32_t stsF3 ;
uint16_t stsFpIndex ;
uint16_t stsAccumCount ;
uint32_t sts2Peak;
uint32_t sts2Power;
uint32_t sts2F1;
uint32_t sts2F2;
uint32_t sts2F3;
uint16_t sts2FpIndex;
uint16_t sts2AccumCount;
}dwt_rxdiag_t ;
Return Parameters:
none
Notes:
This function is used to read the received frame diagnostic data. They can be read after a frame is
received (e.g. after DWT_SIG_RX_OKAY event reported in the RX call-back function called from
dwt_isr()). CIA diagnostic level must be configured with the dwt_configciadiag() otherwise only the
minimum diagnostics will be available, please see DW3XXX User Manual [2].
ipatovRxTime 40-bit RX timestamp from Ipatov sequence, arranged as array of octets, with
least significant octet first.
stsRxTime 40-bit RX timestamp from the STS, arranged as array of octets, with least
significant octet first.
sts2RxTime 40-bit RX timestamp from the 2nd STS, arranged as array of octets, with least
significant octet first. (this is used in PDOA mode 3, when the STS is split)
sts2RxStatus 16-bit RX status info for the 2nd STS (this is used in PDOA mode 3, when the
STS is split)
ciphe2rPOA POA from the 2nd STS CIR (this is used in PDOA mode 3, when the STS is split)
tdoa TDOA from two STS RX timestamps (valid when PDOA mode 3 is configured)
xtalOffset Estimated crystal offset of remote device. This is PPM x16, i.e. divide integer
number by 16 to get the value in PPM.
ipatovPower channel area allows estimation of channel power for the Ipatov sequence
ipatovF1 First path amplitude for the Ipatov sequence value reporting the magnitude
for the sample at the index 1 after the reported first path index value.
ipatovF2 First path amplitude for the Ipatov sequence value reporting the magnitude
for the sample at the index 2 after the reported first path index value.
ipatovF3 First path amplitude for the Ipatov sequence value reporting the magnitude
for the sample at the index 3 after the reported first path index value.
stsPower channel area allows estimation of channel power for the STS
stsF1 First path amplitude for the STS value reporting the magnitude for the
sample at the index 1 after the reported first path index value.
stsF2 First path amplitude for the STS value reporting the magnitude for the
sample at the index 2 after the reported first path index value.
stsF3 First path amplitude for the STS value reporting the magnitude for the
sample at the index 3 after the reported first path index value.
sts2Peak index and amplitude of peak sample in the 2 nd STS CIR, (valid when PDOA
mode 3 is configured)
sts2Power channel area allows estimation of channel power for the 2nd STS, (valid when
PDOA mode 3 is configured)
sts2F1 First path amplitude for the 2nd STS value reporting the magnitude for the
sample at the index 1 after the reported first path index value. (valid when
PDOA mode 3 is configured)
sts2F2 First path amplitude for the 2nd STS value reporting the magnitude for the
sample at the index 2 after the reported first path index value. (valid when
PDOA mode 3 is configured)
sts2F3 First path amplitude for the 2nd STS value reporting the magnitude for the
sample at the index 3 after the reported first path index value. (valid when
PDOA mode 3 is configured)
sts2FpIndex First path index for the 2nd STS, (valid when PDOA mode 3 is configured)
sts2AccumCount Number accumulated symbols for the 2 nd STS, (valid when PDOA mode 3 is
configured)
5.4.4 dwt_readpdoa
This function is used to read the PDOA result, it will return either the phase difference between
Ipatov and STS POAs, or the two STS POAs, depending on the PDOA mode of operation.
Parameters:
none
Return Parameters:
Type Description
int16_t The PDOA result in radians (signed number [1:-11]). To convert to degrees:
pdoa_deg = ((pdoa_rad/1<<11))*180/π
Notes:
5.4.5 dwt_readtdoa
This function is used to read the TDOA (Time Difference Of Arrival). The TDOA value that is read from
the register is 41-bits in length. However, 6 bytes (or 48 bits) are read from the register. The
remaining 7 bits at the 'top' of the 6 bytes that are not part of the TDOA value should be set to zero
and should not interfere with rest of the 41-bit value. However, there is no harm in masking the
returned value.
Parameters:
uint8_t* tdoa Time difference on arrival - buffer of 6 bytes that will be filled
with TDOA value by calling this function.
Return Parameters:
none
Notes:
5.4.6 dwt_get_dgcdecision
uint8_t dwt_get_dgcdecision(void);
This function is used to read the DGC_DECISION index when RX_TUNING is enabled, this value is
used to adjust the RX level and FP level estimation.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.7 dwt_configeventcounters
This function enables event counters (TX, RX, error counters) in the IC.
Parameters:
Return Parameters:
none
Notes:
This function is used to enable counters that count the number of frames transmitted, and received,
and various types of error events.
5.4.8 dwt_readeventcounters
This function reads the event counters (TX, RX, error counters).
Parameters:
Typedef struct
{
uint16_t PHE ; //number of received header errors
uint16_t RSL ; //number of received frame sync loss events
uint16_t CRCG ; //number of good CRC received frames
uint16_t CRCB ; //number of bad CRC (CRC error) received frames
uint8_t ARFE ; //number of address filter rejections
uint8_t OVER ; //number of RX overflows (used in double buffer mode)
uint16_t SFDTO ; //number of SFD timeouts
uint16_t PTO ; //number of preamble timeouts
uint8_t RTO ; //number of RX frame wait timeouts
uint16_t TXF ; //number of transmitted frames
uint8_t HPW ; //number of half period warnings
uint8_t CRCE; //number of SPI CRC write errors
uint16_t PREJ; //number of preamble rejections
uint16_t SFDD; //number of SFD detection events (only valid in QM33120)
uint8_t STSE; //number of STS error + warning events
} dwt_deviceentcnts_t ;
Return Parameters:
none
Notes:
This function is used to read the internal counters. These count the number of frames transmitted,
received, and also number of errors received/detected.
SFDT SFD timeout errors counter is a 12-bit counter of SFD timeout error events.
CRCE SPI CRC write error is an 8-bit counter of “SPI write CRC error” events.
5.4.9 dwt_readclockoffset
This function can be used to read the estimated clock offset between the local clock and the remote.
The value is calculated as part of the reception of the frame. It relates to last received frame and
© Decawave Ltd 2021 Version 2.2 Page 82 of 155
DW3XXX API GUIDE
Type Description
Signed 16-bit clock offset value. To convert to ppm the value should be divided by
int16_t
2^26 and multiplied by 10e6.
Notes:
Positive value means that the local receiver’s clock is running faster than that of the remote
transmitter.
If the CIA is not running, this function will return 0 and cannot be used to read the clock offset.
5.4.10 dwt_readcarrierintegrator
int32_t dwt_readcarrierintegrator(void);
The dwt_readcarrierintegrator() API function reads the receiver carrier integrator value and returns
it as a 32-bit signed value. The receive carrier integrator value is valid at the end of reception of a
frame, (and before the receiver is re-enabled). It reflects the frequency offset of the remote
transmitter with respect to the local receive clock. A positive carrier integrator value means that the
local receive clock is running slower than that of the remote transmitter device.
Parameters:
none
Return Parameters:
Type Description
Notes:
This dwt_readcarrierintegrator() API may be called after receiving a frame to determine the clock
offset of the remote transmitter the sent the frame. The receive frame should be valid (i.e. with good
CRC) otherwise the clock offset information may be incorrect. The following constants are defined to
allow the returned carrier integrator be converted to a frequency offset in Hertz and from that to a
clock offset in PPM (which depends on the channel centre frequency): FREQ_OFFSET_MULTIPLIER,
and HERTZ_TO_PPM_MULTIPLIER_CHAN_5.
The HERTZ_TO_PPM_xxx multipliers are negative quantities, so when the resultant clock offsets are
positive it means that the local receiver’s clock is running slower than that of the remote transmitter.
Example code:
int32_t ci ;
float clockOffsetHertz ;
float clockOffsetPPM ;
5.4.11 dwt_readstsquality
This function may be used in any STS mode. It reads the STS quality index and also returns an
indication of whether the STS reception quality is good or bad. After a frame is received the
dwt_readstsquality() API can be used to assess the quality of the STS and hence decide whether to
trust the RX timestamp.
The STS is considered good when the (STS) quality index is greater than a specified threshold value,
which is a percentage of the configured STS length. These thresholds have been set as hard coded
values in the device driver code.
Parameters:
Return Parameters:
Type Description
int This value is the STS quality index minus the threshold value which depends on the
configured STS PRF and the configured STS length. If this return value is > 0 this indicates
that the STS quality is good, however if this return value is negative this indicates that
the received frame has bad quality STS and the resulting timestamps are less
trustworthy
Notes:
5.4.12 dwt_readstsstatus
This function may be used in any STS mode. It will read the STS status register in order to show if
there are any errors present in the STS signals. It can be used in conjunction with the
dwt_readstsquality() API after a packet/frame is received.
A 16-bit buffer is passed into the function and is populated with a ‘1’ or ‘0’ depending on whether
the 9 different STS statuses are set high or not. The remaining upper 7 bits of the 16 bits are ignored.
Only bits 8 through to 0 are set.
Parameters:
Return Parameters:
Type Description
Notes:
The available STS statuses that are available to read as part of the stsStatus are described in the table
below:
Table 16: stsStatus values
5.4.13 dwt_readctrdbg
uint32_t dwt_readctrdbg(void);
This function is used to read CTR_DBG_ID register. This should be done after packet reception,
please see User Manual for more details on this register.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.14 dwt_readdgcdbg
uint32_t dwt_readdgcdbg(void);
This function is used to read DGC_DBG_ID register. This should be done after packet reception,
please see User Manual for more details on this register.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.15 dwt_readCIAversion
uint32_t dwt_readCIAversion(void);
This function is used to read the internal CIA version. Is generally used in logging/diagnostic
applications.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.16 dwt_getcirregaddress
This function is used to return ACC_MEM_ID register address. Is generally used in logging/diagnostic
applications when logging CIR data following packet reception, see also dwt_readaccdata().
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.17 dwt_get_reg_names
register_name_add_t* dwt_get_reg_names(void);
This function returns a list of register name/value pairs, to enable debug output / logging in external
applications e.g. DecaRanging. The implementation is device specific, i.e. DW3000 device values are
different from QM331XX devices. This API is not enabled unless _DGB_LOG is defined.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.4.18 dwt_nlos_alldiag
Parameters:
dwt_nlos_alldiag_t all_diag Pointer to the all diagnostics structure which will contain
* the read data.
typedef struct
{
uint32_t accumCount ;
uint32_t F1 ;
uint32_t F1 ;
uint32_t F1 ;
uint32_t cir_power ;
uint8_t D ;
dwt_diag_type_e diag_type ;
uint8_t result ;
} dwt_nlos_alldiag_t ;
Return Parameters:
Type Description
Notes:
This function is used to read the received frame diagnostic data. They can be read after a frame is
received. CIA diagnostic level must be configured with the dwt_configciadiag(
DW_CIA_DIAG_LOG_ALL) otherwise the diagnostic registers will read back as zero, please see
DW3XXX User Manual [2] section 8.2.13.
diag_type enum to select which diagnostic type to be read: 0x0 for IP_DIAG, 0x1 for
STS_DIAG and 0x2 for STS1_DIAG
5.4.19 dwt_nlos_ipdiag
Parameters:
typedef struct
{
uint32_t index_fp_u32 ;
uint32_t index_pp_u32 ;
} dwt_nlos_ipdiag_t;
Return Parameters:
none
Notes:
This function is used to read the received frame Ipatov diagnostic data. They can be read after a
frame is received. CIA diagnostic level must be configured with the dwt_configciadiag(
DW_CIA_DIAG_LOG_ALL) otherwise the diagnostic registers will read back as zero, please see
DW3XXX User Manual [2] section 8.2.13, “IP_DIAG_0” for peak path index and “IP_DIAG_8” for first
path index.
5.5.1 dwt_calibratesleepcnt
The dwt_calibratesleepcnt() function calibrates the low-power oscillator. It returns the number of
XTAL cycles per one low-power oscillator cycle.
Parameters:
none
Return Parameters:
Type Description
uint16_t This is number of XTAL cycles per one low-power oscillator cycle.
Notes:
The IC’s internal L-C oscillator has an oscillating frequency which is between approximately 15,000
and 34,000 Hz depending on process variations within the IC and on temperature and voltage. To do
more precise setting of sleep times its calibration is necessary. See also example code given under
the dwt_configuresleepcnt() function. This function need to be run before
dwt_configuresleepcnt() in order to ascertain the counter units required to calculated the sleep
time.
5.5.2 dwt_configuresleepcnt
The dwt_configuresleepcnt() function configures the sleep counter to a new value. This function needs
to be run before dwt_entersleep() if sleep mode is used.
Parameters:
uint16_t sleepcnt This is the sleep count value to set. The high 16-bits of 28-bit
counter. See note below for details of units and code example for
configuration detail.
Return Parameters:
none
Notes:
The units of the sleepcnt parameter depend on the oscillating frequency of the IC’s internal L-C
oscillator, which is between approximately 15,000 and 34,000 Hz depending on process variations
within the IC and on temperature and voltage. This frequency can be measured using the
dwt_calibratesleepcnt() function so that sleep times can be more accurately set.
The sleepcnt is actually setting the upper 16 bits of a 28-bit counter, i.e. the low order bit is equal to
4096 counts. So, for example, if the L-C oscillator frequency is 15000 Hz then programming the
sleepcnt with a value of 24 would yield a sleep time of 24 × 4096 ÷ 15000, which is approximately 6.55
seconds.
Example code:
This example shows how to calibrate the low-power oscillator and set the sleep time to 10 seconds.
Double t;
uint32_t sleep_time = 0;
uint16_t lp_osc_cal = 0;
uint16_t sleepTime16;
lp_osc_cal = dwt_calibratesleepcnt();
5.5.3 dwt_configuresleep
The dwt_configuresleep() function may be called to configure the activity of DEEPSLEEP or SLEEP
modes. Note TX and RX configurations are maintained in DEEPSLEEP and SLEEP modes so that upon
"waking up" there is no need to reconfigure the devices before initiating a TX or RX, although as the
TX data buffer is not maintained the data for transmission will need to be written before initiating
transmission.
Parameters:
uint16_t mode A bit mask which configures which configures the SLEEP parameters,
see Table 17.
uint8_t wake A bit mask that configures the wakeup event. As defined in Table 18
Return Parameters:
none
Notes:
This function is called to configure the sleep and on wake parameters.
The DEEPSLEEP state is the lowest power state except for the OFF state. In DEEPSLEEP all internal
clocks and LDO are off and the IC consumes approximately 100 nA. To wake the IC from DEEPSLEEP
an external pin needs to be activated for the “power-up duration” approximately 300 to 500 μs. This
can be either be the SPICSn line pulled low or the WAKEUP line driven high. The duration quoted
here is dependent on the frequency of the low power oscillator (enabled as the IC comes out of
DEEPSLEEP) which will vary between individual IC and will also vary with changes of battery voltage
and different temperatures. To ensure the IC reliably wakes up it is recommended to either apply the
wakeup signal until the 500 μs has passed, or to use the SPIRDY event status bit (in Register file: 0x0F
– System Event Status Register) to drive the IRQ interrupt output line high to confirm the wake-up.
Once the IC has detected a “wake up” it progresses into the WAKEUP state. While in DEEPSLEEP
power should not be applied to GPIO, SPICLK or SPIMISO pins as this will cause an increase in leakage
current.
a) By driving the WAKEUP pin (pin 23) high for a period > 500 µs (as per the Data Sheet [1])
b) Driving SPICSn low for a period > 500 µs. This can also be achieved by an SPI read (of register 0,
offset 0) of sufficient length
c) If the IC is sleeping using its own internal sleep counter it will be awoken when the timer expires.
This is configured by setting the wake parameter to 0x10 (+ 0x1 – to enable sleep).
d) By resetting the device, setting RSTn pin to low.
Example code:
This example shows how to configure the device to enter DEEPSLEEP mode after some event e.g.
frame transmission. The mode parameter into the dwt_configuresleep() function has value 0x01
which configures QM33120 to load IC configurations. The wake parameter value, 0x29, which
enables the sleeping with SPICSn as the wakeup signal, and also sets the preserve sleep bit setting.
dwt_configuresleep(0x01, 0x29); //configure sleep and wake parameters
// then ... later... after some event we can instruct the IC to go into
// DEEPSLEEP mode
/// then ... later ... when we want to wake up the device
dwt_spicswakeup(buffer, len);
5.5.4 dwt_entersleep
This function is called to put the device into DEEPSLEEP or SLEEP mode.
NOTE: dwt_configuresleep() needs to be called before calling this function to configure the sleep and
on wake parameters.
(Before entering DEEPSLEEP, the device should be programmed for TX or RX, then upon “waking up"
the TX/RX settings will be preserved and the device can immediately perform the desired action
TX/RX see dwt_configuresleep()).
Parameters:
int idle_rc If this is set to DWT_DW_IDLE_RC, the auto INIT2IDLE bit will be
cleared prior to going to sleep. Thus, after wake-up, device will stay
in IDLE_RC state.
Return Parameters:
none
Notes:
This function is called to enable (put the device into) DEEPSLEEP mode. The dwt_configuresleep()
should be called first to configure the sleep/wake parameters. (See code example in the
dwt_configuresleep() function).
5.5.5 dwt_entersleepaftertx
The dwt_entersleepaftertx() function configures the “enter sleep after transmission completes” bit.
If this is set, the device will automatically go to DEEPSLEEP/SLEEP mode after a TX event.
Parameters:
int enable If set the “enter DEEPSLEEP/SLEEP after TX” bit will be set, else it will
be cleared.
Return Parameters:
none
Notes:
When this mode of operation is enabled the IC will automatically transition into SLEEP or DEEPSLEEP
mode (depending on the sleep mode configuration set in dwt_configuresleep()) after transmission
of a frame has completed so long as there are no unmasked interrupts pending. See
dwt_setinterrupt() for details of controlling the masking of interrupts.
To be effective dwt_entersleepaftertx() function should be called before dw_starttx() function and
then upon TX event completion the device will enter sleep mode.
Example code:
This example shows how to configure the device to enter DEEP_SLEEP mode after frame transmission.
dwt_configuresleep(0x01, 0x25); //configure the on-wake parameters
//(upload the IC config settings)
// disable TX interrupts
dwt_setinterrupt(
DWT_INT_TXFRS_BIT_MASK | \
DWT_INT_TXPHS_BIT_MASK | \
DWT_INT_TXPRS_BIT_MASK | \
DWT_INT_TXFRB_BIT_MASK,
0, DWT_DISABLE_INT
);
// won’t be able to enter sleep if any other unmasked events are pending
dwt_spicswakeup(buffer, len);
5.5.6 dwt_entersleepafter
The dwt_entersleepafter() function makes the device automatically enter deep sleep or sleep mode
after a frame transmission and/or reception.
Parameters:
Return Parameters:
none
Notes:
The IC will only transition to sleep or deep sleep mode if no interrupt events are active. See
dwt_setinterrupt() for details of controlling the masking of interrupts.
To be effective the dwt_entersleepafter() function should be called before calling the dw_starttx() or
dwt_rxenable() function and then upon TX or RX event completion the device will enter sleep mode.
Example code:
This example shows how to configure the device to enter DEEP_SLEEP mode after frame reception.
dwt_configuresleep(0x01, 0x25); // configure the on-wake parameters
// (upload the IC config settings)
// won’t be able to enter sleep if any other unmasked events are pending
dwt_setrxtimeout(0);
5.5.7 dwt_spicswakeup
The dwt_spicswakeup() function uses an SPI read to wake up the IC from SLEEP or DEEPSLEEP.
Parameters:
uint8_t* buff This is the pointer to a buffer where the data from SPI read will be
read into.
Return Parameters:
Type Description
Notes:
When the IC is in DEEPSLEEP or SLEEP mode, this function can be used to wake it up, assuming SPICSn
has been configured as a wakeup signal in the dwt_configuresleep()) call. This is done using an SPI read.
The duration of the SPI read, keeping SPICSn low, has to be long enough to provide the low for a period
> 500 µs.
dwt_spicswakeup(buffer, len);
5.5.8 dwt_readwakeuptemp
uint8_t dwt_readwakeuptemp(void);
This function reads the IC temperature sensor value that was sampled during IC wake-up. This
should be only used with QM331XX as it does not work on DW3000 – see DW3000 errata.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function may be used to read the temperature sensor value that was sampled by the IC on wake
up, assuming the DWT_TANDV bit in the mode parameter was set in a call to dwt_configuresleep()
before entering sleep mode. If the wakeup sampling of the temperature sensor was not enabled
then the value returned by dwt_readwakeuptemp() will not be valid.
5.5.9 dwt_readwakeupvbat
uint8_t dwt_readwakeupvbat(void);
This function reads the battery voltage sensor value that was sampled during IC wake-up.
Parameters:
none
Return Parameters:
Type Description
Notes:
This function may be used to read the battery voltage sensor value that was sampled by the IC on
wake up, assuming the DWT_TANDV bit in the mode parameter was set in the call to
dwt_configuresleep() before entering sleep mode. If the wakeup sampling of the battery voltage
sensor was not enabled then the value returned by dwt_readwakeupvbat() will not be valid.
5.5.10 dwt_wakeup_ic
void dwt_wakeup_ic(void);
This function will wake up the device by toggling the correct IO pin. DW3xxx SPI_CS or WAKEUP pins
can be used for this.
Parameters:
none
Return Parameters:
none
Notes:
This function is platform dependent. This is due to the fact that each platform may configure IO pins
differently. Please view the source code of this function to see how it can be ported to other
platforms.
5.5.11 dwt_ds_en_sleep
With this function, each host can prevent the device going into SLEEP/DEEPSLEEP state. By default, it
is possible for either host to place the device into SLEEP/DEEPSLEEP. This may not be desirable, thus
a host once it is granted access can set a SLEEP_DISABLE bit in the register to prevent the other host
from putting the device to sleep once it gives up its access. This does not exist in DW3000.
Parameters:
dwt_host_sleep_en_e host_sleep_en Sets or clears the bit to prevent or allow the device to
go to sleep respectively.
Return Parameters:
None
Notes:
5.6.1 dwt_setcallbacks
This function is used to configure the TX/RX callback function pointers, and SPI CRC error callback
function pointer. These callback functions will be called when TX, RX or SPI error events happen and
the dwt_isr() is called to handle them (See dwt_isr() description below for more details about the
events and associated callback functions).
Parameters:
dwt_cb _t cbRxOk Function pointer for the cbRxOk function. See type description below.
dwt_cb _t cbRxTo Function pointer for the cbRxTo function. See type description below.
dwt_cb _t cbRxErr Function pointer for the cbRxErr function. See type description below.
dwt_cb_t cbSPIErr Function pointer for the cbSPIErr function. See type description below.
typedef enum
{
DWT_CB_DATA_RX_FLAG_RNG = 0x01, // Ranging bit
DWT_CB_DATA_RX_FLAG_ND = 0x02, // No data mode
DWT_CB_DATA_RX_FLAG_CIA = 0x04, // CIA done
DWT_CB_DATA_RX_FLAG_CER = 0x08, // CIA error
DWT_CB_DATA_RX_FLAG_CPER = 0x10, // STS error
} dwt_cb_data_rx_flags_e;
Return Parameters:
none
Notes:
This function is used to set up the TX and RX events call-back functions.
status The status parameter holds the initial value of the SYS_STATUS_ID register as
read on entry into the ISR.
status_hi The status_hi parameter holds the initial value of the SYS_STATUS_HI_ID
register as read on entry into the ISR.
datalength The datalength parameter specifies the length of the received frame. Only
valid for RX events and only if not SP3 packet.
rx_flags The rx_flags parameter is a bit field value valid only for received frames. It is
interpreted as follows:
- Bit 0: 1 if the ranging bit was set for this frame, 0 otherwise.
- Bit 1: 1 if no data STS mode (no RX data but timestamps are valid)
- Bit 2: CIA done (the RX timestamps and diagnostics are valid)
- Bit 3: CIA error (the RX timestamps are not valid)
- Bit 4: STS error (the STS status is a non-zero value)
- 5-7: Reserved.
For more detailed information on interrupt events and especially for details on which status events
trigger each one of the different callback functions, see dwt_isr() function description below.
5.6.2 dwt_setinterrupt
This function sets the events which will generate an interrupt. The bit mask parameters may be used
to enable or disable single events or multiple events at the same time. Table 19 shows the main
events that are typically configured as interrupts:
Parameters:
Return Parameters:
none
Notes:
For the transmitter, it is generally sufficient to enable the SY_STAT_TFRS event which will trigger
when a frame has been sent. For the receiver, it is generally sufficient to enable the good frame
reception event (DWT_INT_RFCG) and also any error events which will disable the receiver.
Table 19: bitmask_lo values for control of common event interrupts
5.6.3 dwt_setinterrupt_db
This function sets the events which enables the specified double RX buffer to trigger an interrupt.
This function sets the events which will generate an interrupt. The bit mask parameter may be used
to enable or disable single events or multiple events at the same time. Table 20 shows the main
events that are typically configured as interrupts:
Parameters:
Return Parameters:
none
Notes:
This function is only available in QM331XX devices.
5.6.4 dwt_checkirq
uint8_t dwt_checkirq(void);
Type Description
uint8_t 1 if the IC interrupt line is active (IRQS bit in STATUS register is set), 0 otherwise.
Notes:
This function is typically intended to be used in a PC based system using (Cheetah or ARM) USB to SPI
converter, where there can be no interrupts. In this case we can operate in a polled mode of
operation by checking this function periodically and calling dwt_isr() if it returns 1.
5.6.5 dwt_isr
void dwt_isr(void);
This function processes device events, (e.g. frame reception, transmission). It is intended that this
function be called as a result of an interrupt from the IC – the mechanism by which this is achieved is
target specific. Where interrupts are not supported this function can be called from a simple
runtime loop to poll the status register and take the appropriate action, but this approach is not as
efficient and may result in reduced performance depending on system characteristics.
The dwt_isr() function makes use of call-back functions in the application to indicate that received
data is available to the upper layers (application) or to indicate when frame transmission has
completed. The dwt_setcallbacks() API function is used to configure the call back functions.
The dwt_isr() function reads the status register and recognises the following events:
Table 21: List of events handled by the dwt_isr() function and signalled in call-backs
SPI write CRC error SPICRCERR This means that the CRC byte written by the host
detected as the last byte of SPI write transaction did not
(cbSPIErr callback) match the CRC generated by the IC on the header
and data bytes. This will only be generated when
IC is using SPI CRC mode.
Device powered on SPIRDY/ RCINIT This callback is used to check if the device has
or wake-up powered up or has woken up from a sleep state.
(cbSPIRdy callback) It checks for the SPI to be ready and that the
device has gone from wakeup to the RXINIT state.
When an event is recognised and processed the status register bit is cleared to clear the event
interrupt. Figure 7 shows the dwt_isr() function flow diagram.
Parameters:
none
Return Parameters:
none
Notes:
The dwt_isr() function should be called from the microprocessor’s interrupt handler that is used to
process the IC interrupt.
It is recommended to read the User Manual [2], especially chapters 3, 4, and 5 to become familiar
with IC events and their operation.
In addition, if the microprocessor is not fast enough and two events are set in the status register, the
order in which they are processed is as shown in Figure 7. This may not be the order in which they
were triggered.
YES
DWT_INT_RXFR bit set Clear the event and call RX OK call-back
and No Data mode?
NO
YES
DWT_INT_RFCG Clear the event and call RX OK call-back
bit set ?
NO
DWT_INT_TFRS YES
Clear the event and call TX DONE call-back
bit set ?
NO
YES
DWT_INT_RFTO or
Clear the event and call RX TO call-back
DWT_INT_RXPTO
bits set ?
NO
YES
Any RX error Clear the event and call RX ERR call-back
bits set ?
NO
YES
Clear the event and call SPIRDY call-back
SPIRDY bit set ?
NO
YES
SPI CRC error Clear the event and call SPICRC call-back
bits set ?
NO
NO
exit
5.6.6 dwt_writesysstatuslo
This function writes a value to the system status register (lower). Host can do this to clear events in
the status register and any associated interrupts.
Parameters:
Return Parameters:
none
5.6.7 dwt_writesysstatushi
This function writes a value to the system status register (higher). Host can do this to clear events in
the status register and any associated interrupts.
Parameters:
Return Parameters:
None
Notes:
Be aware that the size of this register varies per device
DW3000 devices only require a 16-bit mask value typecast to 32-bit register
5.6.8 dwt_readsysstatuslo
uint32_t dwt_readsysstatuslo(void);
This function reads the current value of the system status register (lower 32 bits).
Parameters:
None
© Decawave Ltd 2021 Version 2.2 Page 108 of 155
DW3XXX API GUIDE
Return Parameters:
Type Description
uint32_t A uint32_t value containing the value of the system status register (lower 32 bits)
5.6.9 dwt_readsysstatushi
uint32_t dwt_readsysstatushi(void);
This function reads the current value of the system status register (higher bits).
Parameters:
None
Return Parameters:
Type Description
uint32_t A uint32_t value containing the value of the system status register (higher bits)
Notes:
Be aware that the size of this register varies per device
DW3000 devices only require a 16-bit mask value typecast to 32-bit register
5.6.10 dwt_writerdbstatus
Parameters:
Return Parameters:
None
5.6.11 dwt_readrdbstatus
uint8_t dwt_readrdbstatus(void);
This function reads the current value of the receiver double buffer register.
Parameters:
None
Return Parameters:
Type Description
uint8_t A uint8_t value containing the value of the receiver double buffer register
5.7.1 dwt_setpanid
This function sets the PAN ID value. These are typically assigned by the PAN coordinator when a
node joins a network. This value is only used by the IC for frame filtering. See the
dwt_configureframefilter() function.
Parameters:
Return Parameters:
none
Notes:
This function can be called to set device’s PANID for frame filtering use, it does not need to be set if
frame filtering is not being used. Insertion of PAN ID in the TX frames is the responsibility of the
upper layers calling the dwt_writetxdata() function.
5.7.2 dwt_setaddress16
This function sets the 16-bit short address values. These are typically assigned by the PAN
coordinator when a node joins a network. This value is only used by the IC for frame filtering. See
the dwt_configureframefilter() function.
Parameters:
Return Parameters:
none
Notes:
This function is called to set device’s short (16-bit) address, it does not need to be set if frame filtering
is not being used. Insertion of short (16-bit) address, in the TX frames is the responsibility of the upper
layers calling the dwt_writetxdata() function.
5.7.3 dwt_seteui
Return Parameters:
none
Notes:
This function may be called to set a long (64-bit) address used for address filtering. If address filtering
is not being used, then this register does not need to be set.
It is possible for a 64-bit address to be programmed into the IC’s one-time programmable memory
(OTP memory) during customers’ manufacturing processes and automatically loaded into this register
on power-on reset or wake-up from sleep. dwt_seteui() may be used subsequently to change the
value automatically loaded.
5.7.4 dwt_geteui
Return Parameters:
none
Notes:
This function may be called to get the EUI value. The value will be 0xFFFFFFFF00000000 if it has not
been programmed into OTP memory or has not been set by a call to dwt_seteui() function.
It is possible for a 64-bit address to be programmed into the IC’s one-time programmable memory
(OTP memory) during customers’ manufacturing processes and automatically loaded into this register
on power-on reset or wake-up from sleep. dwt_seteui() may be used subsequently to change the
value automatically loaded.
5.7.5 dwt_configureframefilter
This dwt_configureframefilter() function enables frame filtering according to the mask parameter.
Parameters:
uint16_t filtermode This enables a particular frame filter options, see Table 22.
Return Parameters:
none
Notes:
This function is used to enable frame filtering, the device address and pan ID should be configured
beforehand.
Table 22: Bitmask values for frame filtering enabling/disabling
5.7.6 dwt_configure_le_address
This function is used to write a 16 bit address to a desired Low-Energy device (LE) address. For frame
pending to function when the correct bits are set in the frame filtering configuration via the
dwt_configureframefilter(). See dwt_configureframefilter() for more details.
Parameters:
int leIndex The Low-Energy device (LE) address to write to. There are four
options for this index: 0, 1, 2 & 3. The index the LE_PEND_01
register with offset 0 (LE_ADDR0), LE_PEND_01 register with
offset 16 (LE_ADDR1), LE_PEND_23 register with offset 0
(LE_ADDR2) and LE_PEND_23 with offset 16 (LE_ADDR3)
respectively.
Return Parameters:
none
5.7.7 dwt_enableautoack
This function enables automatic ACK to be automatically sent when a frame with ACK request is
received. The ACK frame is sent after a specified responseDelayTime (in preamble symbols, max is
255). It can also be enabled or disabled depending on how the enable parameter is set.
Parameters:
uint8_t responseDelayTime The delay between the ACK request reception and ACK
transmission.
int enable This argument enables the Auto-ACK feature with ‘1’ and
disables it with ‘0’.
Return Parameters:
none
Notes:
This dwt_enableautoack() function is used to enable the automatic ACK response. It is recommended
that the responseDelayTime is set as low as possible consistent with the ability of unit requesting the
ACK to turn around and be ready to receive the response. If the host system is using the
DWT_RESPONSE_EXPECTED mode (with rxDelayTime in dwt_setrxaftertxdelay() function set to 0) in
the dwt_starttx() function then the responseDelayTime can be set to 3 symbols (3 µs) without loss of
preamble symbols in the receiver awaiting the ACK.
5.7.8 dwt_getframelength
uint16_t dwt_getframelength(void);
This function will read the length of the last received frame. This function presumes that a good
frame or packet has been received.
Parameters:
None
Return Parameters:
Type Description
uint16_t A uint16_t value with the number of octets in the received frame.
5.8.1 dwt_readtempvbat
uint16_t dwt_readtempvbat(void);
This function reads the temperature and battery voltage. Note: the DW3XXX needs to be in IDLE_PLL
mode or the call will return 0.
Parameters:
none
Return Parameters:
Type Description
uint16_t The low 8-bits are voltage value, and the high 8-bits are temperature value.
Notes:
This function can be called to read the battery voltage and temperature. It enables the IC’s internal
convertors to sample the current IC temperature and battery. Must be called when DW3xxx is in IDLE.
5.8.2 dwt_convertrawtemperature
This function takes a raw temperature value and applies the conversion factor to return a
temperature in degrees.
Parameters:
Return Parameters:
Type Description
Notes:
This function is called to convert the raw IC temperature to degrees, the conversion is given by:
5.8.3 dwt_convertrawvoltage
This function takes a raw voltage value and applies the conversion factor to return a voltage in volts.
Parameters:
Return Parameters:
Type Description
Notes:
This function is called to convert the raw IC voltage to volts, the conversion is given by:
5.9.1 dwt_otpread
This function is used to read a number (given by length) of 32-bit values from the IC’s OTP memory,
starting at given address. The given array will contain the read values.
Parameters:
uint32_t address This is starting address in the OTP memory from which to read
This is the 32-bit array that will hold the read values. It should
uint16_t* array
be of at least length 32-bit words long.
Return Parameters:
none
Notes:
None
5.9.2 dwt_otpwriteandverify
uint32_t value this is the 32-bit value to be programmed into OTP memory
this is the 16-bit OTP memory address into which the 32-bit
uint16_t address
value is programmed
Return Parameters:
Type Description
Notes:
The IC has a small amount of one-time-programmable (OTP) memory intended for device specific
configuration or calibration data. Some areas of the OTP memory are used to save device calibration
values determined during IC testing, while other OTP memory locations are intended to be set by the
customer during module manufacture and test.
Programming OTP memory is a one-time only activity, any values programmed in error cannot be
corrected. Also, please take care when programming OTP memory to only write to the designated
areas – programming elsewhere may permanently damage the IC’s ability to function normally.
The OTP memory locations are as defined in Table 23. The OTP memory locations are each 32-bits
wide; OTP addresses are word addresses, so each increment of address specifies a different 32-bit
word.
Table 23: OTP memory map
Addre Size Byte [3] Byte [2] Byte [1] Byte [0] Programmed
ss (Used By
Bytes)
0x00 4
64 bit EUID Customer
0x01 4
0x02 4
Alternative 64bit EUID (Selected via reg/SR register) Customer
0x03 4
0x04 4
LDOTUNE_CAL Prod Test
0x05 4
0x06 4 {“0001,0000,0001”, “CHIP ID 5 nibbles (20 bits)”} Prod Test
0x07 4 {“0001” , “LOT ID – 7 nibbles (28bits)”} Prod Test
0x08 4 - Vbat @ 3.0 V Vbat @ 3.62 V Vbat @ 1.62 V
[23:16] [15:8] [7:0] Prod Test
0x09 2 Temp @ 22 °C
+/- 2 °C [7:0] Prod Test
0x0A 0 BIASTUNE_CAL Prod Test
0x0B 4 Antenna Delay – RFLoop
Prod Test
0x0C 4 AoA Iso CH9 AoA Iso CH9 AoA Iso CH5 AoA Iso CH5
RF2->RF1 RF1->RF2 RF2 -> RF1 RF1->RF2
Prod Test
0x0D 0 W.S. Lot ID [3] W.S. Lot ID [2] W.S. Lot ID [1] W.S. Lot ID [0] Prod Test
0x0E 0 W.S. Lot ID [5] W.S. Lot ID [4]
Prod Test
0x0F 0 W.S. Wafer
W.S. Y Loc W.S. X Loc
Number Prod Test
0x10 4 Customer
0x11 4 Customer
0x12 4 Customer
0x13 4 Customer
0x14 4 Customer
0x15 4 Customer
0x16 4 Customer
0x17 4 Customer
0x18 4 Customer
0x19 4 Customer
0x1A 4 Customer
0x1B 4 Customer
0x1C 4 Customer
0x1D 4 Customer
0x1E 1 XTAL_Trim[6:0] Customer
0x1F 1 OTP Revision Customer
0x20 4 RX_TUNE_CAL: DGC_CFG0 Prod Test
0x21 4 RX_TUNE_CAL: DGC_CFG1 Prod Test
0x22 4 RX_TUNE_CAL: DGC_CFG2 Prod Test
0x23 4 RX_TUNE_CAL: DGC_CFG3 Prod Test
0x24 4 RX_TUNE_CAL: DGC_CFG4 Prod Test
0x25 4 RX_TUNE_CAL: DGC_CFG5 Prod Test
0x26 4 RX_TUNE_CAL: DGC_CFG6 Prod Test
0x27 4 RX_TUNE_CAL: DGC_LUT_0 – CH5 Prod Test
0x28 4 RX_TUNE_CAL: DGC_LUT_1 – CH5 Prod Test
0x29 4 RX_TUNE_CAL: DGC_LUT_2 – CH5 Prod Test
0x2A 4 RX_TUNE_CAL: DGC_LUT_3 – CH5 Prod Test
0x2B 4 RX_TUNE_CAL: DGC_LUT_4 – CH5 Prod Test
0x2C 4 RX_TUNE_CAL: DGC_LUT_5 – CH5 Prod Test
0x2D 4 RX_TUNE_CAL: DGC_LUT_6 – CH5 Prod Test
0x2E 4 RX_TUNE_CAL: DGC_LUT_0 – CH9 Prod Test
0x2F 4 RX_TUNE_CAL: DGC_LUT_1 – CH9 Prod Test
0x30 4 RX_TUNE_CAL: DGC_LUT_2 – CH9 Prod Test
0x31 4 RX_TUNE_CAL: DGC_LUT_3 – CH9 Prod Test
0x32 4 RX_TUNE_CAL: DGC_LUT_4 – CH9 Prod Test
0x33 4 RX_TUNE_CAL: DGC_LUT_5 – CH9 Prod Test
0x34 4 RX_TUNE_CAL: DGC_LUT_6 – CH9 Prod Test
0x35 4 PLL_LOCK_CODE Prod Test
0x36 – UNALLOCATED
0x5F Customer
0x60 1 QSR Register (Special function register) Reserved
0x61 Q_RR Register
[7:0] Reserved
0x62 – 4 UNALLOCATED
0x77 Customer
0x78 4 AES_KEY[127:96] (big endian order) Customer
0x79 4 AES_KEY[95:64] (big endian order) Customer
0x7A 4 AES_KEY[63:32] (big endian order) Customer
0x7B 4 AES_KEY[31:0] (big endian order) Customer
The QSR (“Special function register”) is a 32-bit segment of OTP that is directly readable via
the register interface upon power up. To program the SR register follow the normal OTP
programming method but set the OTP address to 0x60. As this is part of OTP boot sequence
the new value will be present in the QSR register following the next boot up sequence.
For more information on OTP memory programming please consult the User Manual [2] and Data
Sheet [1].
5.9.3 dwt_otpwrite
This function is used to program 32-bit value into OTP memory. It will not validate/check the written
value (dwt_otpwriteandverify() checks if the value has been saved correctly).
Parameters:
uint32_t value this is the 32-bit value to be programmed into OTP memory
this is the 16-bit OTP memory address into which the 32-bit
uint16_t address
value is programmed
Return Parameters:
Type Description
Notes:
5.9.4 dwt_aon_read
The dwt_aon_read() function reads from the AON memory. It returns an 8-bit read from the given
AON memory address.
Parameters:
Return Parameters:
Type Description
Notes:
This function allows the user to read addresses from AON memory. Please see the implementation of
dwt_aon_read() for an example of how this function is utilised.
5.9.5 dwt_aon_write
The dwt_aon_write() function writes to the AON memory given a 16-bit address and 8-bit value. It
has no return values.
Parameters:
uint16_t aon_address This is the address of the memory location to write to.
uint8_t aon_write_data This is the 8-bit value that is written to the specified AON
address.
Return Parameters:
none
Notes:
This function allows the user to write a value to AON memory. Please see the implementation of
dwt_aon_write() for an example of how this function is utilised.
5.9.6 dwt_clearaonconfig
void dwt_clearaonconfig(void);
This function allows the user to clear the AON configuration. This will clear any previously
programmed configurations such as AON on-wake / wake-up configurations. Default values will be
restored.
Parameters:
none
Return Parameters:
none
Notes:
When this function is called, anything set in the AON_DIG_CFG register will be cleared. The same
applies for the ANA_CFG register. The default configuration will be loaded into the AON_CTRL register
also.
5.10.1 dwt_setfinegraintxseq
This is used to activate/deactivate fine grain TX sequencing. In some applications/use cases the fine
grain TX sequencing needs to be disabled, e.g. continuous wave mode or when driving an external
PA. Please refer to [2] for more details about those modes.
Parameters:
Return Parameters:
none
5.10.2 dwt_setxtaltrim
This function writes the crystal trim value parameter into the IC crystal trimming register.
Parameters:
Crystal trim value (in range 0x0 to 0x3F, 63 steps (~1.5ppm per
uint8_t value
step).
Return Parameters:
none
Notes:
This function can be called any time to set the crystal trim register value. This is used to fine tune and
adjust the XTAL frequency. Better long-range performance may be achieved when crystals are more
closely matched. Crystal trimming may allow this without using expensive TCXO devices. Please
consult the User Manual [2], Data Sheet [1] and application notes available on www.decawave.com.
5.10.3 dwt_configcwmode
void dwt_configcwmode(void);
This function configures the device to transmit a Continuous Wave (CW) at a specified channel
frequency. This may be of use as part of crystal trimming procedure. Please consult with Decawave’s
applications support team for details of crystal trimming procedures and considerations.
Parameters:
none
Return Parameters:
none
Notes:
Example code of how to use this function in conjunction with dwt_setxtaltrim() function is given by
the Example 04a: continuous wave mode sample example in the API package [5]
5.10.4 dwt_configcontinuousframemode
This function configures continuous frame mode. This facilitates measurement of the power in the
transmitted spectrum.
Parameters:
Return Parameters:
none
Notes:
This function is used to configure continuous frame (transmit power spectrum test) mode, used in TX
power spectrum measurements. This test mode is provided to help support regulatory approvals
spectral testing. Please consult with Decawave’s applications support team for details of regulatory
approvals considerations. The dwt_configcontinuousframemode() function enables a repeating
transmission of the data from the transmit buffer. To use this test mode, the operating channel,
preamble code, data length, offset, etc. should all be set-up as if for a normal transmission.
The framerepetitionrate parameter value is programmed in units of one quarter of the 499.2 MHz
fundamental frequency, (~ 8 ns). To send one frame per millisecond, a value of 124800 or
0x0001E780 should be set. A value <2 will not work properly, and a time value less than the frame
length will cause the frames to be sent back-to-back without any pause.
(a) Testing to figure out the TX power/pulse width to meet the regulations.
To end the test and return to normal operation the device can be rest with dwt_softreset() function.
Please see Example 04b: continuous frame mode, of the API package [5] for an example of the use of
this API function.
5.10.5 dwt_readpgdelay
uint8_t dwt_readpgdelay(void);
This is used to read the pulse generator delay value of the TX signal.
Parameters:
none
Return Parameters:
Type Description
Notes:
5.10.6 dwt_repeated_cw
This function will enable a repeated continuous waveform on the selected device given a pulse
generator channel and pulse generator coefficient.
Parameters:
Return Parameters:
none
Notes:
5.10.7 dwt_repeated_frames
This function enables repeated frames to be generated given a frame repetition rate.
Parameters:
uint32_t framerepetitionrate Value specifying the rate at which frames with be repeated.
If the value is less than the frame duration, the frames are
sent back-to-back.
Return Parameters:
none
Notes:
5.10.8 dwt_stop_repeated_frames
uint16_t dwt_stop_repeated_frames(void);
5.10.9 dwt_disablecontinuousframemode
void dwt_disablecontinuousframemode(void)
This function stops the continuous TX frame mode.
Parameters:
none
Return Parameters:
none
5.10.10 dwt_calcbandwidthadj
This function runs a bandwidth compensation algorithm that adjusts the bandwidth of the output
spectrum to correct for the effects of different temperatures. This ensures that the bandwidth is
constant at any temperature. The target count parameter is a reference value taken at a known
temperature for a known good bandwidth using the dwt_calcpgcount() API call, which relates
directly to the bandwidth of the spectrum.
Parameters:
Return Parameters:
Type Description
uint8_t This is an 8-bit value that represents a pulse generator delay (PG_DELAY) value
Notes:
See the app note in [4] for more details. The return value is automatically set into DW3xxx PG delay
register, but it is also returned here so host knows what it was set to.
5.10.11 dwt_calcpgcount
This function returns a pulse generator count value that is used as a reference for bandwidth
compensation over temperature. The pulse generator delay value that is passed in should be the
current bandwidth setting.
Parameters:
Return Parameters:
Type Description
This is a 16-bit value that represents the pulse generator count value for the current
uint16_t
pulse generator delay. It is directly related to the bandwidth.
Notes:
See the app note in [4] for more details. The return value should be stored as a reference to be used
with dwt_configuretxrf().
5.11.1 dwt_configure_aes
This function initializes the AES_CFG register that is responsible for the tag size, key size, etc.
© Decawave Ltd 2021 Version 2.2 Page 125 of 155
DW3XXX API GUIDE
Parameters:
typedef struct {
dwt_aes_otp_sel_key_block_e aes_otp_sel_key_block; //!< Select OTP
//key, first 128 or 2nd 128
//bits
dwt_aes_key_otp_type_e aes_key_otp_type;
dwt_aes_core_type_e aes_core_type; //!< Core type
dwt_mic_size_e mic; //!< Message integrity code
//size
dwt_aes_key_src_e key_src; //!< Location of the key:
//either as programmed in
//registers(128 bit) or in the
//RAM
dwt_aes_key_load_e key_load; //!< Loads key from RAM
uint8_t key_addr; //!< Address offset of AES key
//in AES key RAM
dwt_aes_key_size_e key_size; //!< AES key length
//configuration corresponding
//to AES_KEY_128/192/256bit
dwt_aes_mode_e mode; //!< Operation type
//encrypt/decrypt
} dwt_aes_config_t ;
Return Parameters:
none
Notes:
Further information on the structures that make up the dwt_aes_config_t structure can be found
within the source code.
5.11.2 dwt_set_keyreg_128
This function sets the AES key – 128 bits. It updates the AES_KEY0 – AES_KEY3.
Parameters:
This struct contains all the keys values that is needed for the
dwt_aes_key_t key
initialization.
Return Parameters:
none
5.11.3 dwt_do_aes
This function responsible for data encryption/decryption, filling the relevant buffer (in case of
decryption) or updating the TX buffer with encrypted data (in case of encryption). The function also
checks for errors and updates the nonce.
Parameters:
This option refers to the AES core type used by the IC.
dwt_aes_core_type_e core_type The options are either GCM core type (0) or CCM core
type (1).
Return Parameters:
Type Description
Negative value on error or AES_STS reg value. AES_STS reg value will be checked in
int8_t
the calling function
5.11.4 dwt_mic_size_from_bytes
This function gets mic size in bytes and returns the MIC size to fit into AES_CFG-AES_TAG_SIZE reg.
Parameters:
Return Parameters:
dwt_mic_size_e – Enum that contains the right value for the AES reg.
5.12.1 dwt_timers_reset
void dwt_timers_reset(void);
This function will reset the timers block. It will reset both timers. It can be used to stop a timer
running in repeat mode. Only available in QM33120 device.
Parameters:
none
Return Parameters:
none
Notes:
5.12.2 dwt_timers_read_and_clear_events
void dwt_timers_read_and_clear_events(void);
This function will read the timers' event counts. When reading from this register the values will be
reset/cleared, thus the host needs to read both timers' event counts the events relating to TIMER0
are in bits [7:0] and events relating to TIMER1 in bits [15:8]. Only available in QM33120 device.
Parameters:
none
Return Parameters:
none
Notes:
5.12.3 dwt_configure_timer
This function configures selected timer (TIMER0 or TIMER1) as per configuration structure passed in.
Only available in QM33120 device.
Parameters:
typedef enum
{
DWT_TIMER0 = 0,
DWT_TIMER1
} dwt_timers_e;
typedef enum
{
DWT_TIM_SINGLE = 0,
DWT_TIM_REPEAT
} dwt_timer_mode_e;
typedef enum
{
DWT_XTAL = 0, // 38.4 MHz
DWT_XTAL_DIV2 = 1, // 19.2 MHz
DWT_XTAL_DIV4 = 2, // 9.6 MHz
DWT_XTAL_DIV8 = 3, // 4.8 MHz
DWT_XTAL_DIV16 = 4, // 2.4 MHz
DWT_XTAL_DIV32 = 5, // 1.2 MHz
DWT_XTAL_DIV64 = 6, // 0.6 MHz
DWT_XTAL_DIV128 = 7 // 0.3 MHz
} dwt_timer_period_e;
typedef struct
{
dwt_timers_e timer; // Select the timer to use.
dwt_timer_period_e timer_div; // Select the timer frequency (divider).
dwt_timer_mode_e timer_mode; // Select the timer mode.
uint8_t timer_gpio_stop; // Set to '1' to halt GPIO on interrupt.
uint8_t timer_coexout; // Configure GPIO for WiFi co-ex.
} dwt_timer_cfg_t;
Return Parameters:
none
Notes:
The tim_cfg parameter points to a dwt_timer_cfg _t structure that has various fields to select and
configure different parameters within the IC. The fields of the dwt_timer_cfg _t structure are
identified are individually described below:
The timer parameter selects the timer to configure. QM33120 has two timers
timer namely TIMER0 and TIMER1. The timer is selected with setting this to either
DWT_TIMER0 or DWT_TIMER1.
The timer_mode is used to select either a single expiry timer or configure the
timer_mode timer for continuous/repeat operation.
If this is set to 1 then the timer will stop when GPIO interrupt is raised. See
timer_gpio_stop more details about GPIO interrupt configuration in User Manual [2]
This is used to configure the timer for WiFi coexistence mode. On timer expiry
timer_coexout WiFi coex GPIO (4 or 5) is toggled. See also dwt_configure_wificoex_gpio()
5.12.4 dwt_configure_wificoex_gpio
This function configures the GPIOs (4 and 5) for COEX_OUT. Only available in QM33120 device.
Parameters:
Return Parameters:
none
Notes:
5.12.5 dwt_set_timer_expiration
This function sets timer expiration period, it is a 22-bit number. Only available in QM33120 device.
Parameters:
Return Parameters:
none
Notes:
5.12.6 dwt_timer_enable
This function enables the timer. In order to enable, the timer enable bit [0] for TIMER0 or [1] for
TIMER1 needs to transition from 0->1. Only available in QM33120 device.
Parameters:
Return Parameters:
none
Notes:
These functions are platform specific SPI read and write functions, external to the driver code, used
by the device driver to send and receive data over the SPI interface to and from the IC. The device
driver abstracts the target SPI device by calling it through generic functions writetospi() and
readfromspi(). In porting the device driver, to different target hardware, the body of these SPI
functions should be written, re-written, or provided in the target specific code to drive the target
microcontroller device’s physical SPI hardware. The initialisation of the target host controller’s
physical SPI interface mode and its data rate is considered to be part of the target system and is
done in the host code outside of the device driver functions.
5.13.1 writetospi
int writetospi (uint16_t hLen, const uint8_t *hbuff, uint32_t bLen, const uint8_t *buffer);
This function is called by the device driver code (from the dwt_xfer3xxx() function) when it wants to
write to the IC’s SPI interface (registers) over the SPI bus.
Parameters:
uint16_t hLen This is gives the length of the header buffer (hbuff)
This is a pointer to the header buffer byte array. The LSB is the first
uint8_t* hbuff
element.
uint32_t bLen This is gives the length of the data buffer (buffer), to write.
This is a pointer to the data buffer byte array. The LSB is the first
uint8_t* buffer
element. This holds the data to write.
Return Parameters:
Type Description
Notes:
The return values can be used to notify the upper application layer that there was a problem with SPI
write. The writetospi() function has a return value, however it should be noted that the device driver
itself does not take any notice of success/error return value but instead assumes that SPI accesses
succeed without error.
5.13.2 writetospiwithcrc
int writetospiwithcrc(uint16_t hLen, const uint8_t *hbuff, uint32_t bLen, const uint8_t *buffer,
uint8_t crc);
When the IC is configured to use SPI with 8-bit CRC mode, this function is called by the device driver
code (from the dwt_xfer3xxx() function) to write to the SPI interface (registers) over the SPI bus. In
this mode the IC is expecting an 8-bit CRC to be sent as the last byte of the write SPI transaction. If
the CRC it receives from the host does not match a CRC it generates internally, then the IC will set
SPI CRC error bit which will generate an interrupt if this status event has been masked enabled by
the dwt_enablespicrccheck() function.
Parameters:
uint16_t hLen This is gives the length of the header buffer (hbuff)
This is a pointer to the header buffer byte array. The LSB is the first
uint8_t* hbuff
element.
uint32_t bLen This is gives the length of the data buffer (buffer), to write.
This is a pointer to the data buffer byte array. The LSB is the first
uint8_t* buffer
element. This holds the data to write.
This is the 8-bit CRC generated from the header and data bytes,
uint8_t crc
which needs to be at the end of the SPI transaction
Return Parameters:
Type Description
Notes:
The return values can be used to notify the upper application layer that there was a problem with SPI
write. The writetospiwithcrc() function has a return value, however it should be noted that the device
driver itself does not take any notice of success/error return value but instead assumes that all SPI
accesses succeed without error.
5.13.3 readfromspi
int readfromspi (uint16_t hLen, const uint8_t *hbuff, uint32_t bLen, uint8_t *buffer);
This function is called by the device driver code (from the dwt_xfer3xxx() function) when it wants to
read from the IC’s SPI interface (registers) over the SPI bus.
Parameters:
uint16_t hLen This is gives the length of the header buffer (hbuff)
uint8_t* hbuff This is a pointer to the header buffer byte array. The LSB is the first
element.
uint8_t* buffer This is a pointer to the data buffer byte array. The LSB is the first
element. This holds the data being read.
Return Parameters:
Type Description
Notes:
The return values can be used to notify the upper application layer that there was a problem with SPI
read. The readfromspi() function has a return parameter, however it should be noted that the device
driver itself does not take any notice of success/error return value but instead assumes that each SPI
access succeeds without error.
The purpose of these functions is to provide for microprocessor interrupt enable/disable, which is
used for ensuring mutual exclusion from critical sections in the device driver code where interrupts
and background processing may interact. The only use made of this is to ensure SPI accesses are
non-interruptible.
The mutual exclusion API functions are decamutexon() and decamutexoff(). These are external to the
driver code but used by the device driver when it wants to ensure mutual exclusion from critical
sections. This usage is kept to a minimum and the disable period is also kept to a minimum (but is
dependent on the SPI data rate). A blanket interrupt disable may be the easiest way to provide this
mutual exclusion functionality in the target system, but at a minimum those interrupts coming from
the device should be disabled/re-enabled by this activity.
In implementing the decamutexon() and decamutexoff() functions in a particular microprocessor
system, the implementer may choose to use #defines to map these calls transparently to the target
system. Alternatively the appropriate code may be embedded in the functions provided in the
deca_mutex.c source file.
5.14.1 decamutexon
This function is used to turn on mutual exclusion (e.g. by disabling interrupts). This is called at the
start of the critical section of SPI access. The decamutexon() function should operate to read the
current system interrupt status in the target microcontroller system’s interrupt handling logic with
respect to the handling of the IC’s interrupt. Let’s call this “IRQ_State” Then it should disable the
interrupt relating to the IC, and then return the original IRQ_State.
Parameters:
none
Return Parameters:
Type Description
This is the state of the target microcontroller’s interrupt logic with respect to
decaIrqStatus_t the handling the IC’s interrupt, as it was on entry to the decamutexon()
function before it did any interrupt disabling.
Notes:
The decamutexon() function returns the IC’s interrupt status, which can be noted and appropriate
action taken. The returned status is intended to be used in the call to decamutexoff() function to be
used to restore the interrupt enable status to its original pre-decamutexon() state.
5.14.2 decamutexoff
This function is used to restore the IC’s interrupt state as returned by decamutexon() function. It is
used to turn off mutual exclusion (e.g. by enabling interrupts if appropriate). This is called at the end
of the critical section of SPI access. The decamutexoff() function should operate to restore the
system interrupt status in the target microcontroller system’s interrupt handling logic to the state
indicated by the input “IRQ_State” parameter, state.
Parameters:
decaIrqStatus_t state This is the state of the target microcontroller’s interrupt logic with
respect to the handling of the IC’s interrupt, as it was on entry to
the decamutexon () function before it did any interrupt disabling.
Return Parameters:
none
Notes:
The state parameter passed into decamutexoff() function should be used to appropriately
set/restore the system interrupt status in the target microcontroller system’s interrupt handling logic.
The purpose of this function is to provide a platform dependent implementation of sleep feature, i.e.
waiting for a certain amount of time before proceeding with the application’s next step.
This is an external function used by the driver code to wait for the end of a process, e.g. the
stabilization of a clock or the completion of a write command. This function is provided in the
deca_sleep.c source file.
5.15.1 deca_sleep
This function is used to wait for a given amount of time before proceeding to the next step of the
calling function.
Parameters:
Return Parameters:
None
Notes:
The implementation provided here is designed for a simple single-threaded system and is blocking,
i.e. it will prevent the system from doing anything else during the waiting time.
5.15.2 deca_usleep
This function is used to wait for a given amount of time before proceeding to the next step of the
calling function.
Parameters:
Return Parameters:
None
Notes:
The implementation provided here is designed for a simple single-threaded system and is blocking,
i.e. it will prevent the system from doing anything else during the waiting time.
These functions are used to provide low-level access to individually numbered registers and buffers
(or register files). These may be needed to access IC functionality not included in the main API
functions above.
5.16.1 dwt_writetodevice
This function is used to write to the IC’s registers and buffers. The regID specifies the main address
of the register or parameter block being accessed, e.g. a regID of DX_TIME selects the delay TX or RX
start time register. The index parameter selects a sub-address within the register file. An index
value of 0 is used for most of the accesses employed in the device driver. The length parameter
specifies the number of bytes to write, and the buffer parameter points at the bytes to actually
write. If DWT_API_ERROR_CHECK code switch is defined, this function will check input parameters
and assert if an error is detected.
Parameters:
uint16_t index Byte index into register file or buffer being accessed.
Return Parameters:
None
5.16.2 dwt_readfromdevice
This function is used to read from the IC’s registers and buffers. The parameters are the same as for
the dwt_writetodevice() function above except that the buffer parameter points at a location where
the bytes being read are placed by the function call. If DWT_API_ERROR_CHECK code switch is
defined, this function will check input parameters and assert if an error is detected. It is up to the
developer to ensure that the assert macro is correctly enabled in order to trap any error conditions
that arise.
Parameters:
uint16_t index Byte index into register file or buffer being accessed.
Return Parameters:
None
5.16.3 dwt_xfer3xxx
This function is used to read from or write to the IC’s registers and buffers. The parameters specify
the register address to access, the byte index at which to access said register address, the number of
bytes being read/written, the buffer to read to / write from and the particular SPI mode used
respectively. The SPI modes are specified in Table 24. If DWT_API_ERROR_CHECK code switch is
defined, this function will check input parameters and assert if an error is detected. It is up to the
developer to ensure that the assert macro is correctly enabled in order to trap any error conditions
that arise.
Parameters:
uint16_t index Byte index into register file or buffer being accessed.
spi_modes_e spi_modes Mode of SPI transaction (read or write). See Table 24 for more
details.
Return Parameters:
None
Notes:
The implementation provided here is designed for a simple single-threaded system and is blocking,
i.e. it will prevent the system from doing anything else during the waiting time.
Both dwt_writetodevice() and dwt_readfromdevice() will use this function with their specified SPI
modes to perform their respective SPI writes and reads.
Table 24: spi_modes_e enum values (SPI read/write modes)
5.16.4 dwt_read32bitreg
5.16.5 dwt_read32bitoffsetreg
This function is used to read a 32-bit IC register that is part of a sub-addressed block.
5.16.6 dwt_write32bitreg
This function is used to write a 32-bit IC register that is part of a sub-addressed block.
5.16.7 dwt_write32bitoffsetreg
This function is used to write to a 32-bit IC register that is part of a sub-addressed block.
5.16.8 dwt_read16bitoffsetreg
This function is used to read a 16-bit IC register that is part of a sub-addressed block.
5.16.9 dwt_write16bitoffsetreg
This function is used to write a 16-bit IC register that is part of a sub-addressed block.
5.16.10 dwt_read8bitoffsetreg
This function is used to read an 8-bit IC register that is part of a sub-addressed block.
5.16.11 dwt_write8bitoffsetreg
This function is used to write an 8-bit IC register that is part of a sub-addressed block.
5.16.12 dwt_modify32bitoffsetreg
This function is used to clear or set individual bits in a 32-bit register. The andmask will be AND-ed
with the register value, and the ormask OR-ed. Single or multiple bits can be set in a single SPI
transaction.
5.16.13 dwt_modify16bitoffsetreg
This function is used to clear or set individual bits in a 16-bit register. The andmask will be AND-ed
with the register value, and the ormask OR-ed. Single or multiple bits can be set in a single SPI
transaction.
5.16.14 dwt_modify8bitoffsetreg
This function is used to clear or set individual bits in an 8-bit register. The andmask will be AND-ed
with the register value, and the ormask OR-ed. Single or multiple bits can be set in a single SPI
transaction.
5.16.15 dwt_writefastCMD
This function is used to write a single byte special 5-bit command word to the device. The supported
commands are listed below:
Table 25: List of supported commands
5.16.16 dwt_readfastCMD
This function is used to read a single byte special 5-bit command word from the device and return
one byte (4-bit) from that address.
5.16.17 dwt_read_reg
This function allows read from the DW3xxx device 32-bit register.
Parameters:
Return Parameters:
Type Description
5.16.18 dwt_write_reg
This function allows read from the DW3xxx device 32-bit register.
Parameters:
Return Parameters:
None
All these examples have been designed to be as simple as possible. The main idea is to make the
code self-explanatory and include the least possible amount of code not directly involved in the
achievement of the example-related feature. One of the consequences of this design is that the
examples output very little (or even no) debug information and are designed so that the application
flow can be followed using a debugger to examine run-time operations.
On the hardware side, the examples have been designed to run on an DW3XXX Arduino-type shield.
The base layers included in this package (see detail below) provide specific implementations for this
HW.
API
dwt_uwb_driver/
nRF52840-DK STM_Nucleo_F429 examples MAC_802_15_8
libdwt_uwb_driver
All example applications are named after the feature or set of features they implement.
All examples provide a specific ex_<example number>_<example name>.c source file with a single
project build configuration. To build and run the code, just unzip the source code and import the
project as “Existing Projects into Workspace” into your ST Workbench IDE. If ST Workbench IDE is
already installed on your machine, you should be able to simply double-click the “.cproject” file and
the project will load into the IDE.
Once the project is loaded into the IDE, select the example to build by editing the
“..\API\Src\example_selection.h” header file. Each simple example has a corresponding “#define”
(pre-processor macro definition) in this header file. For example, to build the
ST Workbench IDE (SW4STM32) and CubeMX project generator can be downloaded from ST
website. [6]
As all examples have been designed to be self-explanatory and quite straightforward to read. The
following is a list of all the examples provided with a brief description of the function of each.
This example is the most basic example which just reads the QM33120 device ID register. This can be
used to test that the SPI communications between host MCU and QM33120 are working correctly.
This example application repeatedly sends a hard-coded standard blink frame. Hard-coded delay
between frames is 1 second.
This is a variation of example 1a, where the IC is commanded to sleep and then awoken after the
delay between each frame.
There are two flavours of this example “tx_sleep” and “sleep_idleRC”. In the latter the device
remains in IDLE_RC state after wakeup, and only transitions to IDLE prior to transmission of the
message, staying in IDLE_RC during the programming of TX data and frame control means QM33120
is in a lower power state, and consumes less power than if it was in IDLE state (as in the former
example).
This is a variation of example 1b where the IC automatically goes to sleep after the transmission of a
frame. The IC is still commanded to wake up after the desired sleep period has elapsed before
sending the next frame.
This is a variation of example 1c where the IC automatically wakes up using an internal sleep timer.
Before the IC is put to sleep for the first time, the internal low-power oscillator driving the sleep
counter is calibrated so that the desired sleep time can be properly set through the sleep timer
counter.
Here we implement a simple Clear Channel Assessment (CCA) mechanism before frame
transmission. The CCA can be used to avoid collisions with other frames on the air.
Note this example is not doing CCA the way a continuous carrier radio would do it by looking for
energy/carrier in the band. It is only looking for preamble so will not detect PHR or data phases of
the frame. In a UWB data network it is advised to also do a random back-off before re-transmission
in the event of not receiving acknowledgement to a data frame transmission.
This example is very similar to Example 1a, 6.3.1 above, except that it is using STS configuration.
This example is very similar to Example 1a, 6.3.1 above, except that it is using TX configuration for
PDOA.
This example is very similar to Example 1a, 6.3.1 above, except that it is using AES encryption of the
data payload (of 802.15.8 sample frame). The encrypted data is fixed bytes array, but the header is
changing according to the nonce (changing according to counter) and frame sequence number. This
payload is then decrypted by the 6.3.17 companion example.
This example application waits indefinitely for an incoming frame. When a frame is received, it is
read into a local buffer where it can be examined and then the application re-enables the receiver to
start waiting for another frame. It is intended that the simple TX examples (like that in 6.3.1 above)
should be used as a source of frames when running these simple RX examples.
There are two flavours of this example “simple_rx” and “simple_rx_nlos”. In the latter, after the
frame is received and validated based on the diagnostics logged, diagnostic register values are read
and calculations for First Path Power based on the section 4.7.1 and estimating the receive signal
power based on 4.7.2 of the User Manual [2]. The probability of signal being Line of Sight or Non-
Line of Sight is calculated based on the Application Notes "APS006 PART 3” [8] revision (1.1).
This is a variation of example 2a where RX frame diagnostic information (first path index, channel
impulse response power) and accumulator (channel impulse response) values are read for each
received frame. This information is read into a local structure where it can be examined.
This is a variation of example 2a where the RX SNIFF mode of QM33120 is used. When the receiver
is enabled, it begins preamble-hunt mode with the receiver on. In SNIFF mode, the receiver is not on
all the time, but is sequenced on and off, with a defined duty-cycle. In this example, these durations
are defined to give roughly a 50% duty-cycle, which allows a corresponding reduction in the
preamble-hunt power consumption while still being able to receive frames. It is suggested that the
simple TX example, from 6.3.1 above, is used as a source of frames to test this.
Note: SNIFF mode reduces RX sensitivity depending on the on and off period configurations. Please
see the QM33120 User Manual [2] for more details
This example keeps listening for any incoming frames, storing in a local buffer any frame received
before going back to listening. This example activates interrupt handling and the double buffering
feature of the DW IC (either auto or manual re-enable of receiver can be used). Frame processing is
performed in the RX good frame call-back.
This is an example of a receiver that measures the clock offset of a remote transmitter and then uses
the XTAL trimming function to modify the local clock to achieve a target clock offset. Note: To keep a
system stable it is recommended to only adjust trimming at one end of a link.
This example is very similar to Example 2a, 6.3.10 above, except that it is using STS configuration.
This example is very similar to Example 2a, 6.3.10 above, except that it is using PDOA configuration.
This example application waits indefinitely for an incoming frame (is expects a 802.15.8 sample
frame from companion 6.3.9 example). When a frame is received, it starts to examine the frame
residing in the RX buffer. It checks sizes validity and then extract the header from this buffer.
According to this header and header size, it builds the nonce and get the payload size, before
attempting to decrypt the payload.
This example application is a combination of examples 1a and 2a. This example sends a frame then
waits for a response (with receive timeout enabled). If a response is received, it is stored in a local
buffer for examination and then flow proceeds to the transmission of the next frame. If a response is
not received, the timeout will trigger, and the application will proceed to the next transmission.
This example application is the complement of example 3a. It waits indefinitely for a frame. When a
frame is received, it is stored in a local buffer. If the received frame is the one transmitted by the
example 3a application, then a response is sent. In any case, when the received frame is processed
this simple example application re-enables the receiver to start waiting again for another frame.
This is a variation of example 3a where interrupts and call-backs are used to process received
frames, reception errors and timeouts and transmission confirmation instead of polling with an
infinite loop.
This example application activates continuous wave mode for 2 minutes with a predefined
configuration. On a correctly configured spectrum analyser (use configuration values on the picture
below), the output should look like this:
This example application activates continuous frame mode for 2 minutes with a predefined
configuration. On a correctly configured spectrum analyser (use configuration values on the picture
below), the output should look like this:
This is a simple code example that acts as the initiator in a DS TWR distance measurement exchange.
This application sends a “poll” frame (recording the TX time-stamp of the poll), and then waits for a
“response” message expected from the “DS TWR responder” example code (companion to this
application – see section 6.3.24 below). When the response is received its RX time-stamp is recorded
and we send a “final” message to complete the exchange. The final message contains all the time-
stamps recorded by this application, including the calculated/predicted TX time-stamp for the final
message itself. The companion “DS TWR responder” example application works out the time-of-
flight over-the-air and, thus, the estimated distance between the two devices.
Included in this directory in the examples source code is another version of the code described
above that uses STS Mode 1 frames instead of STS Mode 0 frames. This means that the frames that
are sent and received use an STS to compute distance measurements. For more details on STS,
please read the IEEE 802.15.4z documentation.
This is a simple code example that acts as the responder in a DS TWR distance measurement
exchange. This application waits for a “poll” message (recording the RX time-stamp of the poll)
expected from the “DS TWR initiator” example code (companion to this application), and then sends
a “response” message recording its TX time-stamp, after which it waits for a “final” message from
the initiator to complete the exchange. The final message contains the remote initiator’s time-
stamps of poll TX, response RX and final TX. With this data and the local time-stamps, (of poll RX,
response TX and final RX), this example application works out a value for the time-of-flight over-the-
air and, thus, the estimated distance between the two devices, which it writes to the LCD.
Included in this directory in the examples source code is another version of the code described
above that uses STS Mode 1 frames instead of STS Mode 0 frames. This means that the frames that
are sent and received use an STS to compute distance measurements. For more details on STS,
please read the IEEE 802.15.4z documentation.
6.3.25 Example 05c: double-sided two-way ranging with STS (DS TWR STS) initiator
This is an extension based on example 5a (see section 6.3.23 above), except that the STS mode is
also configured. Thus when good frame reception occurs, STS quality is checked and validated before
the STS timestamps are used to work out the range. The companion to this example is DS TWR STS
responder is described in section 6.3.26 below.
6.3.26 Example 05d: double-sided two-way ranging with STS (DS TWR STS)
responder
This is a companion example to DW TWR STS initiator (see section 6.3.25 above) and is based on DW
TWR responder example (see section 6.3.24 above) with the addition of STS.
This is a simple code example that acts as the initiator in a SS TWR distance measurement exchange.
This application sends a “poll” frame (recording the TX time-stamp of the poll), after which it waits
for a “response” message from the “SS TWR responder” example code (companion to this
application) to complete the exchange. The response message contains the remote responder’s
time-stamps of poll RX, and response TX. With this data and the local time-stamps, (of poll TX and
response RX), this example application works out a value for the time-of-flight over-the-air and, thus,
the estimated distance between the two devices, which it writes to the LCD.
Heretofore, we would have recommended use of double-sided TWR (as per examples 5a and 5b)
instead of this single-sided two-way ranging because the SS-TWR time-of-flight estimation typically
suffers poor accuracy due to the clock offset between the two nodes participating in the TWR
exchange. However since driver version 4.0.6 we are now making use of the carrier integrator
diagnostic from the IC (accessible via the new dwt_readcarrierintegrator() API function) to measure
the clock offset and improve the accuracy SS-TWR range estimate calculation.
Included in this directory in the examples source code is another version of the code described
above that uses STS Mode 1 frames instead of STS Mode 0 frames. This means that the frames that
are sent and received use an STS to compute distance measurements. For more details on STS,
please read the IEEE 802.15.4z documentation.
Also included in this directory in the examples source code is another version of the code described
above that uses STS Mode 3 packets instead of STS Mode 0 frames. The “poll” and “response”
messages contain no payload and are only used for computing timestamps using STS. An STS Mode 0
frame is sent from the receiver to the initiator which contains the required timestamp data to
compute distance values in this particular transaction of signals. For more details on STS, please read
the IEEE 802.15.4z documentation.
This is a simple code example that acts as the responder in a SS TWR distance measurement
exchange. This application waits for a “poll” message (recording the RX time-stamp of the poll)
expected from the “SS TWR initiator” example code (companion to this application), and then sends
a “response” message to complete the exchange. The response message contains all the timestamps
recorded by this application, including the calculated/predicted TX time-stamp for the response
message itself. The companion “SS TWR initiator” example application works out the time-of-flight
over-the-air and, thus, the estimated distance between the two devices.
Included in this directory in the examples source code is another version of the code described
above that uses STS Mode 1 frames instead of STS Mode 0 frames. This means that the frames that
are sent and received use an STS to compute distance measurements. For more details on STS,
please read the IEEE 802.15.4z documentation.
Also included in this directory in the examples source code is another version of the code described
above that uses STS Mode 3 packets instead of STS Mode 0 frames. The “poll” and “response”
messages contain no payload and are only used for computing timestamps using STS. An STS Mode 0
frame is sent from the receiver to the initiator which contains the required timestamp data to
compute distance values in this particular transaction of signals. For more details on STS, please read
the IEEE 802.15.4z documentation.
6.3.29 Example 06e: single-sided two-way ranging (SS TWR) initiator with AES
This is a simple code example that acts as the initiator in a SS TWR distance measurement exchange.
This application sends a “poll” frame (recording the TX time-stamp of the poll), after which it waits
for a “response” message from the “SS TWR responder” example code (companion to this
application) to complete the exchange. The response message contains the remote responder’s
timestamps of poll RX, and response TX. With this data and the local time-stamps, (of poll TX and
response RX), this example application works out a value for the time-of-flight over-the-air and, thus,
the estimated distance between the two devices, which it writes to the LCD.
This example uses a simple MAC frame – 802.15.4. It has a source address; destination address and
key index for encryption.
The responder will replay with its own encrypted rx_resp_msg, but this time with a different key
index and it will switch between the source address and destination address.
Both Initiator and responder will check if the data is for them, meaning data is encrypted and with
the right source and destination address. The responder puts its time signature results in the first 8
bytes of the rx_resp_msg.
Heretofore, we would have recommended use of double-sided TWR (as per examples 5a and 5b)
instead of this single-sided two-way ranging because the SS-TWR time-of-flight estimation typically
suffers poor accuracy due to the clock offset between the two nodes participating in the TWR
exchange. However since driver version 4.0.6 we are now making use of the carrier integrator
diagnostic from the IC (accessible via the new dwt_readcarrierintegrator() API function) to measure
the clock offset and improve the accuracy SS-TWR range estimate calculation.
6.3.30 Example 06f: single-sided two-way ranging responder (SS TWR) with AES
This is a simple code example that acts as the responder in a SS TWR distance measurement
exchange. This application waits for a “poll” message (recording the RX time-stamp of the poll)
expected from the “SS TWR initiator” example code (companion to this application), and then sends
a “response” message to complete the exchange. The response message contains all the time-
stamps recorded by this application, including the calculated/predicted TX time-stamp for the
response message itself. The companion “SS TWR initiator” example application works out the time-
of-flight over-the-air and, thus, the estimated distance between the two devices.
This example uses a simple MAC frame – 802.15.4. It has a source address, destination address and
key index for encryption.
The responder replay will be with a different key index and it will switch between the source address
and destination address.
Both Initiator and responder will check if the data is for them, meaning data is encrypted and with
the right source and destination address. The responder puts its time signature results in the first 8
bytes of the rx_resp_msg.
This example, with its companion example 8b below, demonstrates the operation of the IC’s auto-
ACK function. The code here is based on example 3a, except that in this case the transmitted frame
has the AR (acknowledgement request) bit set in the frame control field of the MAC header,
(following the MAC frame definitions of IEEE 802.15.4 [3]), and the turn-around to await response is
immediate, reflecting the ACK response timing of the IC.
This complement to example 8a. Here the Auto ACK feature of IC is activated so that frames sent by
companion example 8a are automatically acknowledged.
This example demonstrates how to enable the GPIO lines as inputs and output
This example illustrates how a user can write and verify data to addresses in the OTP memory.
This example illustrates how a user can utilise the “LE Pend” (Low-Energy Pending) features of the
QM331XX device. A TX device will transmit a frame to an RX device. The RX device will acknowledge
this frame (with an ACK frame) if the following conditions are met:
This example will test that the PLL will recalibrate and relock when a significant change in
temperature is detected.
This example will record the initial PG count (emulating what should be done in factory). The
example will recalibrate the bandwidth given this reference PG count value in a loop over time. The
example should be run in a temperature chamber over a range of operating temperatures. The
device will output a continuous frame for bandwidth monitoring on a spectrum analyser.
This example demonstrates how to enable one of DW IC internal timers. In this example TIMER0 is
configured in the repeating mode with period set to approx. 1s. Every second host count of timer
events is printed. Every 20 seconds both host count and DW count of timer event is printed.
This example demonstrates how the power adjustment API can be used to perform some
adjustment of TX power depending on TX frame duration.
This example demonstrates how the use the AES engine to encrypt/decrypt using the AES-CCM*
standard that is defined in the IEEE 802.15.4 standard [3]. It uses test vectors defined in that
standard also.
7 APPENDIX 2 – BIBLIOGRAPHY:
The Decawave DW3000 and QM33120 Data Sheet, which is available on available on
[1]
www.decawave.com.
8 DOCUMENT HISTORY
Table 28: Document History
9 MAJOR CHANGES
9.1 Release 2.0
10ABOUT DECAWAVE
Decawave is a pioneering fabless semiconductor company whose flagship product, the QM33120, is a
complete, single chip CMOS Ultra-Wideband IC based on the IEEE 802.15.4 standard UWB PHY. This
device is the first in a family of parts.
The resulting silicon has a wide range of standards-based applications for both Real Time Location
Systems (RTLS) and Ultra Low Power Wireless Transceivers in areas as diverse as manufacturing,
healthcare, lighting, security, transport, and inventory and supply-chain management.
For further information on this or any other Decawave product contact a sales representative as
follows: -
Decawave Ltd,
Adelaide Chambers,
Peter Street,
Dublin D08 T6YA,
Ireland.
mailto:sales@decawave.com
http://www.decawave.com/