Hello everybody,

I'm working with tinyos 2.x on an IRIS platform. I need to wait for or 
set an alarm to 140 microseconds to get an energy detection value from 
the RF230 radio chip. As far as I understand TEP102 and some 
correspondence on this newsgroup 
(http://www.mail-archive.com/[email protected]/msg30161.html),
 
the atm128 on the IRIS mote by default is configured to expose its 
hardware timers 1 and 3 as "near microsecond" timers, using an external 
crystal running at 7.372800 MHz with a prescaler of 8 (resulting in 
921600 Hz). Thus I suppose I could configure start BusyWaitMicroC or 
AlarmMicro32C with a value of 140 * 0.9216 = 130 to wait at least 140 
microseconds. Please point out if my reasoning here is incorrect here at 
some point.

Now I also found the MeasureClockC component implementing the 
Atm128Calibrate interface that as far as I understand should help me to 
do exactly that conversion from/to microseconds from/to units I have to 
use with components like LocalTimeMicroC, AlarmMicro32C etc. that are 
parametrized with TMicro precision tag and using counters from hardware 
timers 1 or 3. However:

Atm128Calibrate.calibrateMicro(140) yields a quite surprising value of 
241 (instead of about 130)

Trying with values from 0 to 2000 in steps of 100 yields the following 
output with the tinyos printf tool (code used at the end)
i   / Atm128Calibrate.calibrateMicro(i) / 
Atm128Calibrate.actualMicro(Atm128Calibrate.calibrateMicro(i))
       0   112   242
   100   204   342
   200   296   442
   300   389   543
   400   481   643
   500   573   742
   600   665   842
   700   757   942
   800   850  1043
   900   942  1143
  1000  1034  1242
  1100  1126  1342
  1200  1219  1443
  1300  1311  1543
  1400  1403  1642
  1500  1495  1742
  1600  1587  1842
  1700  1680  1943
  1800  1772  2043
  1900  1864  2142
  2000  1956  2242

To me this seems to be quite far off everything I would expect, or am I 
terribly misstaken about something here? I thought this conversion 
function would have to be rather linear with a factor of about 0.9126 or 
1/0.9126 respectively? Thanks for any clarification on that topic.

Kind Regards,
Andreas


Code used to produce the output:
//module TimerTestC
#include "printf.h"
module TimerTestC {
  uses {
    interface Boot;
    interface Atm128Calibrate as Calibrate;
    interface Timer<TMilli> as Timer;
  }
}
implementation {
  uint32_t i = 0;

  uint32_t micro;
  uint32_t calibratedUnits;
  uint32_t microFromCalibratedUnits;

  event void Boot.booted() {
    call Timer.startPeriodic(20);
  }
 
  event void Timer.fired() {
      micro = i;
      calibratedUnits = call Calibrate.calibrateMicro(micro);
      microFromCalibratedUnits = call 
Calibrate.actualMicro(calibratedUnits);
      printf(" %5ld %5ld %5ld\n", micro, calibratedUnits, 
microFromCalibratedUnits);
      printfflush();
      i += 100;
      if (i > 2000) {   
        call Timer.stop();
      }
    }
}

// configuration TimerTestAppC
#include "printf.h"
configuration TimerTestAppC{
}
implementation {
  components TimerTestC as TimerTestApp;
  components MainC;
  components MeasureClockC;
  components new TimerMilliC() as Timer;

  TimerTestApp.Boot -> MainC;
  TimerTestApp.Calibrate -> MeasureClockC;
  TimerTestApp.Timer -> Timer;
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to