[Tinyos-commits] CVS: tinyos-1.x/tos/platform/msp430 TimerM.nc, 1.29, 1.30

Cory Sharp cssharp at users.sourceforge.net
Sat Feb 11 02:32:52 PST 2006


Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30851

Modified Files:
	TimerM.nc 
Log Message:
Brano Kusy notes MSP430 User's Guide, Section 12.2.1, Note says reading
a counter may return garbage if its clock source is async.  The noted
work around is to take a majority vote.  The code reads the timer
register until two consequtive readings agree.


Index: TimerM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/platform/msp430/TimerM.nc,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** TimerM.nc	30 Mar 2005 10:11:29 -0000	1.29
--- TimerM.nc	11 Feb 2006 10:32:50 -0000	1.30
***************
*** 272,275 ****
--- 272,289 ----
    }
  
+   // only call from within atomic context
+   uint16_t readTime()
+   {
+     // Brano Kusy notes MSP430 User's Guide, Section 12.2.1, Note says reading
+     // a counter may return garbage if its clock source is async.  The noted
+     // work around is to take a majority vote.  The code reads the timer
+     // register until two consequtive readings agree.
+ 
+     uint16_t t0;
+     uint16_t t1=call AlarmTimer.read();
+     do { t0=t1; t1=call AlarmTimer.read(); } while( t0 != t1 );
+     return t1;
+   }
+ 
    async command uint32_t LocalTime.read()
    {
***************
*** 281,291 ****
  
        uint16_t hinow = m_hinow;
!       uint16_t lonow = call AlarmTimer.read();
        if( call AlarmTimer.isOverflowPending() )
        {
  	hinow++;
! 	lonow = call AlarmTimer.read();
        }
!       now = (((uint32_t)m_hinow) << 16) | lonow;
      }
      return now;
--- 295,305 ----
  
        uint16_t hinow = m_hinow;
!       uint16_t lonow = readTime();
        if( call AlarmTimer.isOverflowPending() )
        {
  	hinow++;
! 	lonow = readTime();
        }
!       now = (((uint32_t)hinow) << 16) | lonow;
      }
      return now;



More information about the Tinyos-commits mailing list