[Tinyos-devel] binary vs. decimal clock units

Eric Decker cire831 at gmail.com
Mon Mar 28 09:47:04 PDT 2011

On Mon, Mar 28, 2011 at 6:21 AM, Vlado Handziski <handziski at tkn.tu-berlin.de
> wrote:

> On Mon, Mar 21, 2011 at 09:06, Eric Decker <cire831 at gmail.com> wrote:
>> But I think there are good reasons to stay with powers of 2.   But I do
>> think we want to be clearer about what
>> we mean with the units we are using in the code.   So I would propose the
>> following....
>> These are modelled on SI  powers of 10 vs. IEC binary prefixes.  ie.  1 GB
>> = 10^9 bytes and 1 GiB = 2^30 bytes.
>> Time units:
>> 1 mis = 1 binary millisec   = 1/2^10 sec = 1/1024 secs
>> 1 uis = 1 binary microsec  = 1/2^20 sec = 1/(1024*1024) secs
>> frequency:
>> 1 KiHz = 1024 Hz
>> 1 MiHz = 1024*1024 Hz
>> 1 GiHz = 1024*1024*1024 Hz
> We had this discussion some time ago (
> http://mail.millennium.berkeley.edu/pipermail/tinyos-2.0wg/2006-October/002533.html).
> The consensus back then was that this would be more trouble than it's worth.

I'm not proposing we change the meaning of Tmilli and Tmicro or T32khz.
 That is what that discussion was about.  I agree with Phil and others? that
changing Tmilli and friends would be more trouble then it is worth.   As
Phil said:

I dunno. The Milbi thing is neat and all, but I think all it's going
to do is make readers go "Huh?" Martin's concern (correct me if I'm
wrong) came mostly from measurement, in particular for scientific
work. The same issues arise in all other system measurements, e.g.,
megabytes, gigabytes, etc., yet the community hasn't collapsed.

I think that keeping it as TMilli and T32khz is the right thing to
do. We should mention milbi in the documentation, TMilbi,
particularly when we get to 32khz, seems more trouble than it's worth.

Our developers will just somehow have to come to terms with the historical
artifact that Tmilli is in units of binary
milliseconds (mis).   They'll live.  :-)   (the world continues to spin in
greased grooves).

It also implies a level of precision which is not necessarily offered by the
> HW (i.e. even our current decimal definitions are "sloppy", so
> differentiating between binary and decimal is moot).

Actually, this isn't moot but very operational, which is why I decided I
need to do something about it.  I am saying we need to be accurate (not
necessarily precise) when talking about frequency in the programming of the
clocks on the chips.  The terminology has an effect on how this is done.
 And I'm saying converging on a more accurate terminology is a good thing.

TI has defined for the x2 series of processors timing constants for setting
the clocks up.    But these constants are decimal.  Now since then they have
also added binary constants for the x5 family.   Anyway the Z1 folks were
using those and setting the main clock up for 8000000.

The Z1 was setting up clocks using TI's calibration constants buried in info
memory (ROM) on the msp430 chips.   There are a number of problems with

1) Using 8MHZ to mean 8000000 and 8MHZ to mean 8388608 is very confusing.
we should avoid confusion when we can.

2) The CALIB_DCO constants aren't necessarily present.  For example, I have
a Z1 that doesn't have the constants (they got erased somehow).

3) The CALIB_DCO constants assume 3.0V 25 C.    Which may or may not be

4) No syncronization to the 32KiHz clock was done.

I've done a number of things to correct this in the msp430 integration
branch which Antonio and I are pulling together...

I've adopted the naming convention KHZ = 1000 HZ and KiHZ/KIHZ = 1024HZ to
lend accuracy to various elements including the documentation.  I'm putting
that out there to help familarize folks before they see it in the
msp430_integration branch that Antonio and I are working on.

Now I've done the following (instantiated in the msp430.git
(msp430_intergration branch) working repository.

1) I've converted DCO constants to HZ.  This was done to avoid any confusion
about units and at least one platform is using a non-power of 2, or decimal
main clock.  (EPIC?)

2) I've changed documentation that refers to frequency to reflect what is
actually being done.   Meaning I've made the documentation more accurate.

3) I've changed the Z1 to use binary 8MiHz for its main clock speed.  This
is also reflected in having a single set of baud tables (defines in
msp430usci.h rather then multiple frequencies, ie one for 800000 and one for
8388608, gag).

4) I've changed the Z1 so it now knows how to calibrate the DCO to ACLK like
other msp430s.  (Still only do this once on boot, I will definitely get
around to making this work periodically because I need it for my

But I agree that the documentation should be improved and that developers
> should double check their inline comments and clear the meaning of the units
> they use.

My point here is that it isn't just documentation but operational.
Convergence and accuracy is a good thing.


> Vlado

Eric B. Decker
Senior (over 50 :-) Researcher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20110328/1782ce2e/attachment.htm 

More information about the Tinyos-devel mailing list