[Tinyos-help] Timestamp

Anton ageev at disi.unitn.it
Tue Feb 24 03:31:07 PST 2009


Hi,

I do timestamps in this way:


async event void RadioTimeStamping.transmittedSFD(uint16_t time, 
message_t* p_msg){

        //get the current time and replace the lower half-word with 
SFD-captured timer content:
        timertime=timeget();
       
 mytimebuf=(((((timertime&0x0000FFFFUL)>((uint32_t)time&0x0000FFFFUL))?timertime:(timertime-0x00010000UL))&0xFFFF0000UL)|((uint32_t)time&0x0000FFFFUL));
        transmittime=mytimebuf;
       
        //load the 32-bit timestamp to a uint8_t 4-elements' array:
        for(v=0;v<4;v++){
            mytime[v]=(uint8_t)((mytimebuf>>((3-v)*8))&0x000000FFUL);
        }
       
        //write the timestamp to the CC2420 RAM:
        call CC2420Transmit.modify( 
offsetof(ProtocolMsg,timeStamp)+sizeof(message_header_t), mytime, 4);
   }



This works. To use  "message_header_t" it is necessary to include 
"CC2420.h" in the program. "timeStamp" is a 4-byte field of my packet, 
which I put the timestamp in.

Anton.



More information about the Tinyos-help mailing list