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

#AUNG AUNG PHYO WAI# aung2phyowai at pmail.ntu.edu.sg
Wed Sep 14 19:35:56 PDT 2005


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/20050915/35a749b4/attachment.html


More information about the Tinyos-help mailing list