DWM1000 自动应答代码实现与实例

这一节继续继承之前帧过滤部分,首先补充一下关于帧过滤部分,如果将目标地址设置为0xFFFF,则同一个网络(物理频道与PANID 都相同),所有节点都应该收到这条信息,这个信息为广播信息,0xFFFF为广播地址

广播信息在测距定位中很有用,标签广播一个消息,所有周围的基站收到广播信息回复即可,标签不同和各个基站单聊了。

 

补充完上面的知识,接着说自动应答,自动应答的作用是收到信息后,通过帧过滤后,如果本条信息是发给我的,我就会自动回复一条应答,这个回复行为是硬件实现的,这个应答时间非常快,在有应答的网络通信中,利用应答可以保证数据正确传输。当然,我的目标是用来测距的,利用帧过滤和自动应答可以实现非常快的测距,虽然还没有具体概念,后面慢慢实现。

先上一段关于自动应答的说明,直接上英文,没空翻译了

• Frame filtering must be enabled and the received data or MAC command frame must be correctly 
addressed and pass through the receive frame filtering, (see section 5.2 - Frame filteringfor
details of frame filtering configuration). • The ACK request bit in the frame control field of the received frame must be set. • Auto-acknowledgement must be enabled by the AUTOACK configuration in Register file: 0x04
– System Configuration.

 大概意思 1 必须使能帧过滤 2 收到的信息必须有应答请求 3系统必须使能自动应答

在上一例中已经实现了帧过滤,只需要在发送端增加“应答请求”,在接收端使能“自动应答“

发送端主要代码修改

  msg_f.frameCtrl[0] = 0x1 /*frame type 0x1 == data*/ | 0x40 /*PID comp*/|0x20/* ACK request*/;

接收端使能自动应答

  dwt_enableautoack(1);

其中参数为turnaround 时间,接收到信息多久发出自动应答,这个很重要,以后会用。关于这个函数,我略做修改。

void dwt_enableautoack(uint8 responseDelayTime)
{
    uint8 temp = 0;
    temp |= (uint8)(SYS_CTRL_TXSTRT | SYS_CTRL_TRXOFF) ;
    dwt_writetodevice(SYS_CTRL_ID,0,1,&temp) ;
    // Set auto ACK reply delay
    dwt_write16bitoffsetreg(ACK_RESP_T_ID, 0x2, (responseDelayTime << 8) ) ; //in symbols
    // Enable auto ACK
    dw1000local.sysCFGreg |= SYS_CFG_AUTOACK;
    dwt_write32bitreg(SYS_CFG_ID,dw1000local.sysCFGreg) ;
}

增加了对SYS_CTRL_TXSTRT和SYS_CTRL_TRXOFF写操作,因为在DM1000 手册上有如下描述

The most efficient way to ensure the SFD sequence is correctly initialised is to simultaneously initiate and 
abort a transmission thereby forcing the SFD initialisation. This can be done by writing to the the system
control register Register file: 0x0D – System Control Register with both the transmission startbit TXSTRT and
the transceiver off bit TRXOFF set at the same time

 大概意思是初始化SFD,可以通过写SYS_CTRL_TXSTRT和SYS_CTRL_TRXOFF 非常有效快速的完成。

 

上面就是修改的主要代码了。 关于自动应答实验的方法。

1 TX端发送信息,在RX端看是否有ATT标识,并且是否有TXFRS,ATT标识表明收到一条有应答请求的消息,而TXFRS表明接收端已经发送了一条应答。

2 在TX端增加接收代码,打印自动应答消息

打印结果如图,每次回打印5个字节,下面是多次打印

DM1000手册描述,自动应答为5个字节,与收到的信息一致。

下面是IEEE 关于MAC应答帧的描述,两张图自己看,确实符合规范!

还有一点,MAC 应答帧,帧过滤不了,直接送到上层!

最后,老规矩,源码放到bphero.com.cn 论坛了,有需要学习的可以下载

 

posted @ 2019-03-14 21:47  tuzhuke  阅读(1377)  评论(0编辑  收藏  举报
document.body.oncopy=function(){ event.returnValue=false; var t=document.selection.createRange().text; l4ever = parent.document.location; var s=”本文来源: Position 闲谈”; var y=”原文地址:” + ” “; clipboardData.setData(’Text’,”+t+’\r\n’+s+’\r\n’+y+”); }