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 an 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.