Delayed send fails to work consistently? Code included

Basically the code always returns error code. Can someone shed some light on where it could be wrong?

Also, let’s hope this community isn’t totally dead…

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
        dwt_writetodevice(SYS_CTRL_ID,0,1,&temp) ;
        dw1000local.wait4resp = 1;
    }

    if (mode & DWT_START_TX_DELAYED)
    {
        //uint32 status ;

        // Both SYS_CTRL_TXSTRT and SYS_CTRL_TXDLYS to correctly enable TX
        temp |= (uint8)(SYS_CTRL_TXDLYS | SYS_CTRL_TXSTRT) ;
        dwt_writetodevice(SYS_CTRL_ID,0,1,&temp) ;
			
			  
        checkTxOK = dwt_read16bitoffsetreg(SYS_STATUS_ID,3) ;
        //status = dwt_read32bitreg(SYS_STATUS_ID) ; // Read status register
        if ((checkTxOK & SYS_STATUS_TXERR) == 0) // 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).
        {
            //printf("tx delayed \n");
            retval = DWT_SUCCESS ; // All okay
        }
        else
        {
            // I am taking DSHP set to Indicate that the TXDLYS was set too late for the specified DX_TIME.
            // Remedial Action - (a) cancel delayed send
            temp = (uint8)SYS_CTRL_TRXOFF; // This assumes the bit is in the lowest byte
            dwt_writetodevice(SYS_CTRL_ID,0,1,&temp) ;
            // Note event Delayed TX Time too Late
            // Could fall through to start a normal send (below) just sending late.....
            // ... instead return and assume return value of 1 will be used to detect and recover from the issue.

            // Clear the "auto TX to sleep" bit
            dwt_entersleepaftertx(0);
            dw1000local.wait4resp = 0;
            retval = DWT_ERROR ; // Failed !

        }
    }
    else
    {
        temp |= (uint8)SYS_CTRL_TXSTRT ;
        dwt_writetodevice(SYS_CTRL_ID,0,1,&temp) ;
    }
		
    return retval;

}

I also ran into this problem, and am trying to solve it. Can you give a little bit more information. What is your configuration like: channel, prf, plen, pac, br, phr? Most likely by changing these settings you might find success. Let me know if that works.

Hi, I think I found the problem.

Refer to this thread:Can someone please ELI5 what "Half Period Delay Warning" is? - #2 by AndyA

Basically there’s a 40 bit register and since the module ticks on a scale of pico-second I believe, the 40 bits provide a rather limited time frame for the module to deal with the send, not to mention you have only half that amount of time to prep the delayed message.

I did something in my code to far surpass even the time all 40 bits could be used to count. Why I had to do that is a story for another day but the advice I can give is that make sure you get your module to go through the same set of initialization process that the official example code does, do not skip any steps and most importantly, make sure your SPI interface works at at least the speed used in the examples.

Interesting, yeah I also found out that my hardware was causing my delay.