TDOA Delayed Tx 實現以及驗證


 

在博文:https://www.cnblogs.com/tuzhuke/p/11638221.html 中描述了delayed tx實現方法,這里貼出全部delayed tx 代碼以及對應驗證代碼

1 delayed tx 代碼

static uint32 final_tx_time;
static uint64 final_tx_ts;
void BPhero_Distance_Sync_Node(void)
{
    int address = 0;
    msg_f_send.destAddr[0] = 0xFF;
    msg_f_send.destAddr[1] = 0xFF;

    final_tx_time = dwt_readsystimestamphi32() +0x100000;
    dwt_setdelayedtrxtime(final_tx_time);

    final_tx_ts = (((uint64)(final_tx_time & 0xFFFFFFFE)) << 8) + TX_ANT_DLY;

    final_msg_set_ts(&msg_f_send.messageData[FIRST_TX],  final_tx_ts);// 2 3 4 5 6

    msg_f_send.seqNum = sync_seqnum;
    msg_f_send.messageData[0]='S';
    msg_f_send.messageData[1]=0;

    dwt_writetxdata(psduLength, (uint8 *)&msg_f_send, 0) ; // write the frame data
    dwt_writetxfctrl(psduLength, 0);
    dwt_starttx(DWT_START_TX_DELAYED);
    while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))
    { };

     /* Clear TX frame sent event. */
    dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_TXFRS);

   // dwt_forcetrxoff();
    if(++sync_seqnum == 256)
        sync_seqnum = 0;
}

 

2 delayed tx驗證方法

            h32_timestamp= final_tx_ts>>8;
            l8_timestamp = final_tx_ts&0xFF;
            sprintf(lcd_display_str, "%X%X",h32_timestamp,l8_timestamp);
            OLED_ShowString(0,4,(uint8_t *)lcd_display_str);

            last_tx_ts = get_tx_timestamp_u64();

            h32_timestamp= last_tx_ts>>8;
            l8_timestamp = last_tx_ts&0xFF;
            sprintf(lcd_display_str, "%X%X",h32_timestamp,l8_timestamp);
            OLED_ShowString(0,6,(uint8_t *)lcd_display_str);

驗證方法是把delayed tx timestamp打印出來,同時打印發送tx_timestamp,比較二者是否一致。

上述代碼將兩個時間放在液晶上顯示,觀察到兩個數據完全一樣,說明delayed tx  code 沒有問題

3注意問題:

final_tx_ts 所有40bit都是有效的,而last_tx_ts低9bit 一直為0,兩者比較的時候需要忽略低9bit

4其它問題:

64bit 顯示有如下問題,中間需要加變量,具體原因沒有去深入查資料,有明白的同學可以留言指導

last_rx_ts= 0x123456789A;
sprintf(lcd_display_str, "%X%X",last_rx_ts>>32,last_rx_ts);

液晶上顯示120

last_rx_ts= 0x123456789A; 
sprintf(lcd_display_str, "%X%X",last_rx_ts,last_rx_ts>>32);

液晶上顯示3456789A12

 更多內容參考藍點無限論壇bphero.com.cn 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM