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

mturon at xbow.com mturon at xbow.com
Wed Sep 14 20:38:30 PDT 2005


 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 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20050914/9a6e058e/attachment.htm


More information about the Tinyos-help mailing list