DW1000 SS TWR Register Offset Read Issue

Hi all,

I’ve been trying to use SS TWR example with an SAM4S chip and noticed that whenever I try reading any registers with an offset using the DW1000 API, I consistently get 0xDEDE or 0xDE. I’ve read in the User Manual that any unused or reserved registers return 0xDEAD. However this shouldn’t be the case as the only times I am reading registers at an offset are in the supplied API such as dwt_starttx and dwt_readcarrierintegrator.

I doubt this is an SPI issue as every other register read works perfectly fine. The only change I made to dwt_starttx was to only check for HPDWARN, as even if TXPUTE was flagged, frame transmission will still continue. The definitions for 2 API functions I have issues with are posted below.

image

image

int dwt_starttx(uint8 mode)
{
int retval = DWT_SUCCESS ;
uint8 temp = 0x00;
uint16 checkTxOK = 0 ;

if (mode & DWT_RESPONSE_EXPECTED)
{
    temp = (uint8)SYS_CTRL_WAIT4RESP ; // Set wait4response bit
    pdw1000local->wait4resp = 1;
}

if (mode & DWT_START_TX_DELAYED)
{
    // Both SYS_CTRL_TXSTRT and SYS_CTRL_TXDLYS to correctly enable TX
    temp |= (uint8)(SYS_CTRL_TXDLYS | SYS_CTRL_TXSTRT);
    dwt_write8bitoffsetreg(SYS_CTRL_ID, SYS_CTRL_OFFSET, temp);
	
uint16 txpute = dwt_read8bitoffsetreg(DIG_DIAG_ID, EVC_TPW_OFFSET);  // offset 0x1A
uint16 hpdwarn = dwt_read8bitoffsetreg(DIG_DIAG_ID, EVC_HPW_OFFSET);  //offset 0x18
checkTxOK = dwt_read16bitoffsetreg(SYS_STATUS_ID, 3); // offset 3 to get the upper 2 bytes
uint32 check = dwt_read32bitoffsetreg(SYS_STATUS_ID, 0);

    if ((check & SYS_STATUS_HPDWARN) == 1) // Transmit Delayed Send set over Half a Period away or Power Up error (there is enough time to send but not to power up individual blocks).
    {
		// If HPDWARN or TXPUTE are set this indicates that the TXDLYS was set too late for the specified DX_TIME.
        // remedial action is to cancel delayed send and report error
        dwt_write8bitoffsetreg(SYS_CTRL_ID, SYS_CTRL_OFFSET, (uint8)SYS_CTRL_TRXOFF);
		printf("FAILED HPDWARN TRIGGERED\r\n");
        retval = DWT_ERROR ; //Failed!
    }
    else	//we bypass the err bc HPDWARN not triggered and TXPUTE cant read atm
			//TXPUTE is not enough to completely stop the transmission in but HPDWARN is 
    {
		retval = DWT_SUCCESS ; // may still have TXPUTE
    }
}
else
{
    temp |= (uint8)SYS_CTRL_TXSTRT ;
    dwt_write8bitoffsetreg(SYS_CTRL_ID, SYS_CTRL_OFFSET, temp);
	dwt_read32bitreg(SYS_CTRL_ID);
	dwt_read32bitreg(SYS_STATE_ID);
}

return retval;

} // end dwt_starttx()

int32 dwt_readcarrierintegrator(void)
{
uint32 regval = 0 ;
int j ;
uint8 buffer[DRX_CARRIER_INT_LEN] ;

/* Read 3 bytes into buffer (21-bit quantity) */

dwt_readfromdevice(DRX_CONF_ID, DRX_CARRIER_INT_OFFSET, DRX_CARRIER_INT_LEN, buffer) ;  //offset 0x28

for (j = 2 ; j >= 0 ; j --)  // arrange the three bytes into an unsigned integer value
{
    regval = (regval << 8) + buffer[j] ;
}

if (regval & B20_SIGN_EXTEND_TEST) {
    regval |= B20_SIGN_EXTEND_MASK ;    // sign extend bit #20 to whole word
}
else {
    regval &= DRX_CARRIER_INT_MASK ;    // make sure upper bits are clear if not sign extending
}

return (int32) regval ; // cast unsigned value to signed quantity.

}