Hi Sinan, The problem is not in the TinyOS code. The hardware you use (I assume TelosB or Sky?) does not support these timestamps by default. The timestamps are taken when the SFD line toggles. This line is connected to the TimerB, which is sourced from the 32kHz signal. Thus, you can not get microsecond timestamps with it.
You have two choices: - Change TimerB to use a high-speed clock (note, DCO is not stable enough, so your hardware has to have an external high-speed crystal or clock) and rewire TinyOS to use TimerA for the virtual timer subsystem. - connect the SFD line to a TimerA input line. Then, use this to capture the timestamps. Cheers, - Thomas 2010/8/4 Sinan Yildirim <[email protected]>: > Hello all, > > I have a problem on microsecond precision timestamps. I am using CC24 radio > chip and MSP430 microcontroller. As far as I understood, the packets are > timestamped at CC2420ReceiveP and CC2420TransmitP files. > > /***************** CC2420Receive Commands ****************/ > /** > * Start frame delimiter signifies the beginning/end of a packet > * See the CC2420 datasheet for details. > */ > async command void CC2420Receive.sfd( uint32_t time ) { > if ( m_timestamp_size < TIMESTAMP_QUEUE_SIZE ) { > uint8_t tail = ( ( m_timestamp_head + m_timestamp_size ) % > TIMESTAMP_QUEUE_SIZE ); > m_timestamp_queue[ tail ] = time; > m_timestamp_size++; > } > } > > > async event void CaptureSFD.captured( uint16_t time ) { > uint32_t time32; > uint8_t sfd_state = 0; > atomic { > > time32 = getTime32(time); > switch( m_state ) { > > case S_SFD: > m_state = S_EFD; > sfdHigh = TRUE; > // in case we got stuck in the receive SFD interrupts, we can reset > // the state here since we know that we are not receiving anymore > m_receiving = FALSE; > call CaptureSFD.captureFallingEdge(); > call PacketTimeStamp.set(m_msg, time32); > if (call PacketTimeSyncOffset.isSet(m_msg)) { > uint8_t absOffset = > sizeof(message_header_t)-sizeof(cc2420_header_t)+call > PacketTimeSyncOffset.get(m_msg); > timesync_radio_t *timesync = (timesync_radio_t > *)((nx_uint8_t*)m_msg+absOffset); > // set timesync event time as the offset between the event time > and the SFD interrupt time (TEP 133) > *timesync -= time32; > call CSN.clr(); > call TXFIFO_RAM.write( absOffset, (uint8_t*)timesync, > sizeof(timesync_radio_t) ); > call CSN.set(); > //restoring the event time to the original value > *timesync += time32; > } > > > My problem is, as far as I understood, the "time" parameter of these > functions are all in 32 KHz. I am currently implementing a time > synchronization protocol and I need microsecond precision. Current version > of TinyOs does not have interfaces that serves microsecond timestamps in my > platform. > > What are your suggestions? Is there a way to get microsecond precision? > > Thanks for your helps and thanks a lot... > > K. Sinan YILDIRIM > > Ege University > Computer Engineering Department > İzmir, TURKEY > > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
