EmbeddedRelated.com
Forums
Memfault Beyond the Launch

how to timestamp packets with CC2420 and MSP430F1611

Started by Xiaohui Liu December 1, 2012
Hi everyone,

I'm working on a sensor project which uses
TelosB
based
on CC2420 and MSP430F1611 running TinyOS . And I want
to timestamp each incoming packet, whose reception time is indicated by the
SFD pin rising of CC2420. The SFD pin of CC2420 is connected to P4.1/TB1 of
MSP430F1611 as seen from the
schematic.
One straightforward way is to buffer the timestamps: whenever an SFD rising
edge is captured (e.g., by channel 1 of TimerB), store the captured
timestamp in a queue. When each packet is read out from RXFIFO, a timestamp
is dequeued and associated with it. This is actually what the default radio
driver does in TinyOS. There are several problems with this approach.

(1) Before a captured timestamp is placed into the queue, another packet
arrives and triggers a SFD rising edge, overwriting the previous timestamp.
There is no timestamp for the corresponding packet. What's worse, it's
unknown which remaining timestamp corresponds to which received packet. The
mapping from the packet and timestamp is messed up.

(2) Some packets are dropped by CC2420 (e.g., fail to pass address
recognition) and not placed into RXFIFO. Nevertheless, it still generates
SFD rising edge. There is no packet for the corresponding timestamp. Again,
the mapping is messy.

Can anyone please give me some hint on how to overcome these two issues and
timestamp packets correctly, especially under heavy load? My requirement
can be relaxed not to timestamp all packets correctly, but a fraction of
them. Your help will be sincerely appreciated.
--
-Xiaohui Liu
www.cs.wayne.edu/xliu/


Beginning Microcontrollers with the MSP430

Xiaohui Liu :

> Hi everyone,
>
> I'm working on a sensor project which uses
> TelosB > odules.html> based
> on CC2420 and MSP430F1611 running TinyOS . And I
> want to timestamp each incoming packet, whose reception time is
> indicated by the SFD pin rising of CC2420. The SFD pin of CC2420 is
> connected to P4.1/TB1 of MSP430F1611 as seen from the
> schematic > 09-27.pdf>. One straightforward way is to buffer the timestamps:
> whenever an SFD rising edge is captured (e.g., by channel 1 of TimerB),
> store the captured timestamp in a queue. When each packet is read out
> from RXFIFO, a timestamp is dequeued and associated with it. This is
> actually what the default radio driver does in TinyOS. There are several
> problems with this approach.
>
> (1) Before a captured timestamp is placed into the queue, another packet
> arrives and triggers a SFD rising edge, overwriting the previous
> timestamp. There is no timestamp for the corresponding packet. What's
> worse, it's unknown which remaining timestamp corresponds to which
> received packet. The mapping from the packet and timestamp is messed up.

Just do not overwrite timestamps, every time a edge is on SFD put the
timestamp in the next position of the queue....?

> (2) Some packets are dropped by CC2420 (e.g., fail to pass address
> recognition) and not placed into RXFIFO. Nevertheless, it still
> generates SFD rising edge. There is no packet for the corresponding
> timestamp. Again, the mapping is messy.

Also record the timestamps of the arrival of data in RXFIFO. Is there a
flag/interrupt that indicates RXFIFO is filled? I would assume, that the 2420
needs a fixed time to process a packet - so you can better associate the
timestamps from SFD rising edge with the timestamps from RXFIFO filled.
(Or just use the RXFIFO timestamps? How do you read RXFIFO, by polling?)

Another idea: Assuming there is a fixed time of receiving and processing of
packets in the CC2420 (fixed packet length). Once the SFD edge is detected
start a timer with e.g. 100us (the duration a packet), at timer interrupt try
to read the packet from RXFIFO; if there is no data in RXFIFO you can drop
this SFD timestamp...

M.

Hi,

Thanks for your reply. Still a few comments on problem (1) in line. Some
discussion can also be found
here
.

-Xiaohui

>
> On Mon, Dec 3, 2012 at 3:21 AM, Matthias Weingart wrote:
>
>> **
>> Xiaohui Liu :
>> > Hi everyone,
>> >
>> > I'm working on a sensor project which uses
>> > TelosB<
>> http://www.memsic.com/products/wireless-sensor-networks/wireless-m
>> > odules.html> based
>> > on CC2420 and MSP430F1611 running TinyOS . And I
>>
>> > want to timestamp each incoming packet, whose reception time is
>> > indicated by the SFD pin rising of CC2420. The SFD pin of CC2420 is
>> > connected to P4.1/TB1 of MSP430F1611 as seen from the
>> > schematic<
>> http://webs.cs.berkeley.edu/tos/hardware/telos/telos-revb-2004-
>> > 09-27.pdf>. One straightforward way is to buffer the timestamps:
>>
>> > whenever an SFD rising edge is captured (e.g., by channel 1 of TimerB),
>> > store the captured timestamp in a queue. When each packet is read out
>> > from RXFIFO, a timestamp is dequeued and associated with it. This is
>> > actually what the default radio driver does in TinyOS. There are several
>> > problems with this approach.
>> >
>> > (1) Before a captured timestamp is placed into the queue, another packet
>> > arrives and triggers a SFD rising edge, overwriting the previous
>> > timestamp. There is no timestamp for the corresponding packet. What's
>> > worse, it's unknown which remaining timestamp corresponds to which
>> > received packet. The mapping from the packet and timestamp is messed up.
>>
>> Just do not overwrite timestamps, every time a edge is on SFD put the
>> timestamp in the next position of the queue....?
>>
>> The overwrite occurs at the capture register, not at the presumptive
> queue. So there is not "next position."
>
>>
>> > (2) Some packets are dropped by CC2420 (e.g., fail to pass address
>> > recognition) and not placed into RXFIFO. Nevertheless, it still
>> > generates SFD rising edge. There is no packet for the corresponding
>> > timestamp. Again, the mapping is messy.
>>
>> This problem is resolved by moving address recognition from CC2420
> hardware to software. No packet is dropped by CC2420.
>
>> Also record the timestamps of the arrival of data in RXFIFO. Is there a
>> flag/interrupt that indicates RXFIFO is filled? I would assume, that the
>> 2420
>> needs a fixed time to process a packet - so you can better associate the
>> timestamps from SFD rising edge with the timestamps from RXFIFO filled.
>> (Or just use the RXFIFO timestamps? How do you read RXFIFO, by polling?)
>>
>> Another idea: Assuming there is a fixed time of receiving and processing
>> of
>> packets in the CC2420 (fixed packet length). Once the SFD edge is
>> detected
>> start a timer with e.g. 100us (the duration a packet), at timer interrupt
>> try
>> to read the packet from RXFIFO; if there is no data in RXFIFO you can
>> drop
>> this SFD timestamp...
>>
>> M.
>>
>>
>> --
> -Xiaohui Liu
>

--
-Xiaohui Liu
TelosB
TinyOS 2.1.2
www.cs.wayne.edu/xliu/



Memfault Beyond the Launch