You'll need to clear the pin right before the mote goes to sleep (in
the scheduler) and set the flag in the beginning of each ISR. The pin
will be low while the mote sleeps. Of course, there might be some
instructions after the pin is cleared and before the pin is set -- you
will need to check the assembly code (with avr-objdump) and compensate
for these.

> The interrupt can happen any time
> when the MCU is sleeping or activating.
The condition that causes the interrupt can happen at any time, but
the interrupt will be handled only after the MCU wakes up. It is
explained pretty well in the datasheet.

Janos

On Mon, Jun 15, 2009 at 8:47 PM, 张荣雨<[email protected]> wrote:
> Tanks again.But I still have a question.The interrupt can happen any time
> when the MCU is sleeping or activating.Isn't it? How can I insert my code
> that turn on the output pin appropriately?Using a flag or something else?
>
> Thanks.
> --- 09年6月15日,周一, Janos Sallai <[email protected]> 写道:
>
> 发件人: Janos Sallai <[email protected]>
> 主题: Re: [Tinyos-help] Atmega1281 sleep and active time analysis
> 收件人: "张荣雨" <[email protected]>, "tinyos forum"
> <[email protected]>
> 日期: 2009年6月15日,周一,下午10:35
>
> It wakes up when an interrupt occurs. You need to put it in every
> interrupt handler. They are scattered all around the code. You need to
> look for AVR_ATOMIC_HANDLER and AVR_NONATOMIC_HANDLER in the sources.
>
> Janos
>
> On Sun, Jun 14, 2009 at 8:09 PM, 张荣雨<[email protected]> wrote:
>> Thanks for you reply.
>>
>> On you advice ,I study the chapter 13 in the atmega1281 datasheet,and set
>> the port values
>> directly as it suggests.But the primary problem is I still don't know when
>> the MCU wakes up and where can I turn on the Port A2 as you suggested.It
>> seems that it can be do in the ISR on platform Tinyos1.x,but I can't find
>> the ISR sorce code in Tinyos 2.x.
>>
>> Hope for more advice and thanks a lot for you help.
>> --- 09年6月12日,周五, Janos Sallai <[email protected]> 写道:
>>
>> 发件人: Janos Sallai <[email protected]>
>> 主题: Re: [Tinyos-help] Atmega1281 sleep and active time analysis
>> 收件人: "张荣雨" <[email protected]>, "tinyos forum"
>> <[email protected]>
>> 日期: 2009年6月12日,周五,下午11:17
>>
>> Since this is very time critical, I would set the port values
>> directly. Port A2 is the red led, that's a good point to start with.
>> See chapter 13 in the atmega1281 datasheet.
>>
>> Janos
>>
>> On Thu, Jun 11, 2009 at 7:56 PM, 张荣雨<[email protected]> wrote:
>>> Hi all:
>>>
>>> Now I am analysing the atemga1281 sleep and active time on tinyos-2.x
>>> platform,and I find a method in a paper using Oscilloscope: an output pin
>>> was turned on in each ISR when the processor woke up from a sleep
>>> mode,the
>>> TOSH_run_task() function turned off the output pin before executing the
>>> AVR
>>> sleep instructio. So I follow it to turn off the output pin in the
>>> Scheduler.taskLoop() of tinyos2.x  just before the McuSleep.sleep()
>>> instruction. But I do not know where to turn on the output pin on
>>> tinyos2.x
>>> platform.
>>>
>>> Can anyone help me? Or other ways to analysis the mcu sleep and active
>>> time?
>>>
>>> Thanks
>>>
>>>
>>> ________________________________
>>> 好玩贺卡等你发,邮箱贺卡全新上线!
>>> _______________________________________________
>>> Tinyos-help mailing list
>>> [email protected]
>>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>>
>>
>> ________________________________
>> 好玩贺卡等你发,邮箱贺卡全新上线!
>
> ________________________________
> 好玩贺卡等你发,邮箱贺卡全新上线!

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to