[Tinyos-help] Modification of MicroTimerM.nc in micaz mote

mturon at xbow.com mturon at xbow.com
Thu Sep 15 11:05:34 PDT 2005


Hi,

1) iom128.h is correct

2) MICAZ and MICA2 use the same processor: ATmega128L
   As such, all timer related CONSTANTS behave the same.  
   The CPU clock speed is controlled by the software fuse settings.
   The default clock speed is 7.3728MHz external crystal.
   Another common setting for low power is 8MHz internal oscillator.

3) That looks okay at first glance, but you should really consult the
ATmega128L datasheet from http://www.atmel.com when working at such a low
level.

Regards,
Martin
__________________________________________________
Martin Turon  |  Crossbow Technology, Inc.

-----Original Message-----
From: S. Umesh Babu [mailto:sub at mech.iitkgp.ernet.in] 
Sent: Thursday, September 15, 2005 6:01 AM
To: mturon at xbow.com
Cc: aung2phyowai at pmail.ntu.edu.sg; tinyos-help at millennium.berkeley.edu
Subject: RE: [Tinyos-help] Modification of MicroTimerM.nc in micaz mote


Hello,

>From long time i am waiting for mail like this.Because i am very much in
need of microtimer for micaz and i was unable to modify the existing one.
I and using cygwin. I have following doubts.

1.I can see file in iom128.h in usr/local/avr/bin/include/avr
 instead of io128.h ,should i upgrade avr?

2.In Microtimer3M.nc  what should be the value at ?????

implementation {
#ifdef PLATFORM_MICA2
  enum { CYCLES_PER_MILLISECOND = 7373L };
#else if PLATFORM_MICAZ
  enum { CYCLES_PER_MILLISECOND = ????? };  <----what should be the value
#else
  enum { CYCLES_PER_MILLISECOND = 4000L };
#endif

3.In previous mail by Aung Phyo Wai there is a line
outp(overflow >> 8, OCR1AH); ---- OCR3AH -> OCR3BH
is it correct?

thankyou for your time

regards
Umesh



>  TOSH_SIGNAL(SIG_OUTPUT_COMPARE1A)
>
>
>
> Is a signal directly from the interrupt vector of the AVR.
>
> This is provided by the support libraries of avr-gcc
> (include/avr/io128.h).
>
> TinyOS basically captures this and signals an async event.
>
>
>
> Regarding Timer1 --> Timer3 code, yes, they are both 16-bit timers, so
> controlling them is very similar.  The current model in TinyOS 1.x is to
> duplicate similar code and give it a new name (MicroTimer3M.nc).  You see
> this in HPLUART0, HPLUART1,...
>
>
>
> TinyOS 2.x will take a new approach - and gets you out of assembly and
> into
> C registers - a real joy that only requires nesC 1.2 to be installed.
>
>
>
> Martin
>
> __________________________________________________
> Martin Turon  |  Crossbow Technology, Inc.
>
>   _____
>
> From: tinyos-help-bounces at Millennium.Berkeley.EDU
> [mailto:tinyos-help-bounces at Millennium.Berkeley.EDU] On Behalf Of #AUNG
> AUNG
> PHYO WAI#
> Sent: Wednesday, September 14, 2005 7:36 PM
> To: tinyos-help at Millennium.Berkeley.EDU
> Subject: [Tinyos-help] Modification of MicroTimerM.nc in micaz mote
>
>
>
> Hi all,
>
>
>
> I would like to know the purpose of this function  line found at the end
> of
> MicroTimerM.nc. I found the definition of TOSH_SIGNAL function in
> avrhardware.h but I did not understand what the purpose of this line
> because
> I dont have prior knowledge on microcontroller programming on avr
> hardware.
>
> /////////////////////////////////////////////
>
>  TOSH_SIGNAL(SIG_OUTPUT_COMPARE1A) {
>    signal MicroTimerM.fired();
>
>  }
>
> ////////////////////////////////////////////////
>
> I have already used MicroTimerM.nc on mica2 mote but I knew that If I use
> this module on micaZ mote, there is a conflict on Timer1. I need to chage
> Timer1 to Timer3 because micaz CC2420 Radio uses Timer1 and Timer2. I
> would
> like to know the above line in this file also related to Timer1? if
> related,
> what changes I still need to make?
>
>
>
> Is it OK to change the name of registers of Timer1 to Timer3 in
> MicroTimerM.nc module? I plan to make changes in the following lines of
> this
> module with name of registers from Timer3.  I also added my changes to the
> right side of each line or after ----------.
>
>
>
> ///////////////////////////////////////////////////-
>
>   outp(0, TCCR1A);     -------  TCCR1A -> TCCR3A
> #if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)
> #define CTC1 WGM12
> #endif
>
> -------
>
> #if defined(PLATFORM_MICAZ)
>
> #define CTC1 WGM32
>
> #endif
>
> ---------
>     outp(prescaler | 1 << CTC1, TCCR1B); // set prescaler  and overflow
> value  ----- TCCR1B->TCCR3B
>     outp(overflow >> 8, OCR1AH); ---- OCR3AH -> OCR3BH
>     outp(overflow, OCR1AL);  ----- OCR1AL -> OCR3AL
>     outp(0, TCNT1H);  // reset timer ---- TCNT1H -> TCNT3H
>     outp(0, TCNT1L);                  -------- TCNT1L -> TCNT3H
>     sbi(TIFR, OCF1A);  // clear pending interrupt  ------ sbi(ETIFR,
> OCF3A)
>     sbi(TIMSK, OCIE1A);  // enable overflow A interrupt
> ------------sbi(ETIMSK, OCIE3A)
>
>     return SUCCESS;
>   }
>
>   async command result_t MicroTimer.stop() {
>     result_t ok = FAIL;
>
>     atomic
>       if (running)
>  {
>    cbi(TIMSK, OCIE1A); // disable overflow A interrupt
> ----------cbi(ETIMSK, OCIE3A)
>    sbi(TIFR, OCF1A); // clear pending interrupt
> ----------------------sbi(ETIFR, OCF3A)
>    running = FALSE;
>    ok = SUCCESS;
>  }
>
>
///////////////////////////////////////////////////////////////////////////
>
>
>
> Thanks in advance for your help
>
>
>
>
>
> Regards,
>
>
>
> Aung Aung Phyo Wai
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>


S.Umesh Babu
Research Scholar (Ph.D)
Robotics and Intelligent Systems Lab
IIT Kharagpur,WB,INDIA. 721302

Vist Me at
http://www.geocities.com/umeshphd/


More information about the Tinyos-help mailing list