First, for some reason the mica designers shifted the INTn's down by 4
so what is INT4 on the ATMEGA pinout is labeled INT0 in mica-world.
If you don't know which pins are available I have a cheat sheet at:
http://www.etantdonnes.com/Motes/ATMEGApins.txt

Second, the iom128.h file shifts the vector number down by 1 from
what it says on the pg 59 (of my pdf) manual: Table 23. Reset and
Interrupt Vectors. So SIG_INPUT_CAPTURE3 in TOS-world is vector 25,
but is labeled TIMER3 CAPT vector 26 in ATMEGA-land. And, of course,
there is no cross reference, nor is "TIMER3 CAPT" used anywhere else
in the manual. So you pretty much have to guess. This is where the
degree in hermeneutics comes in...

I don't quite understand the second half of the question...if you
don't use a pin, don't muck with it. But if you are using it as
an Interrupt IN you should set it to input mode. Getting a pin
configured as an interrupt will probably require some more register
banging as well, and again you have to carefully interpret every
reference in the manual to see exactly which bits of which registers
are relevant to the kind of controller function of interest.

I forget the labels for EI* that you ref. You need to have ints
enabled globally, and then there may be a hierarchy of sub-enables
for any specific interrupt squirreled away in various registers.
I don't think there is a general mask area for all the ints. But
at least the registers are often devoted to similar functions so
you don't have to go way far afield to find them. In the case of
my refed code this bit turns on the CAPTURE3 interrupt after the
init() sets up the pin and counter config:
  async command void HPLT3capture.intEnable()   { sbi(ETIMSK, TICIE3);

The vector locations are assigned in hardware if that is what you
are asking. When you do, e.g., TOSH_INTERRUPT(SIG_INPUT_CAPTURE3)
it installs a pointer to your code in the relevant vector. I wouldn't
try changing the defines because my small brain can't hold more than
one remapping at any one time...

Hope this helps...
MS


liangjing wrote:
Hi Michael

  Thank you for your reply and code .
  I read atmega-128 manual and found that some questions.
  In pin configurations page, the PIN 25 is defined as  (SCL/INT0)
PD0 and I wonder if the number 25 is relevant to  #define
SIG_INPUT_CAPTURE3  _VECTOR(25) ,if not, where could I know which pin
the  SIG_INPUT_CAPTURE3  is relevant to ? And I am confused how to
differentiate (SCL/INTO) , for example when I don't use INT0 , do I
need to assign the PD0 to input or output PIN, and if I need to use
PD0 as interrupt PIN, how could I declare the PD0 PIN as interrupt PIN
?
 And I am confused about whether #define SIG_INTERRUPT0  _VECTOR(1)
is equal to INT0, #define SIG_INTERRUPT1  _VECTOR(2) is equal to INT1
and so on . Is it a default configuration or could I change this
connection?
 Finally, do I need to set the EIMSK / EICRA / EICRB / EIFR registers
? And I think the register's every bit is configured as INT0/1/2/.../7
according to the atmega-128 manual, am I right ? If so, the available
interrupts are only 8, but there are 34 interrupt vectors defined in
\usr\local\avr\include\avr\iom128.h, could you explain it further ?
 Thank you for your guidance.
 Best Regards


                                   Jing
2007/5/9, Michael Schippling <[EMAIL PROTECTED]>:
I have an example of using the timer3 interrupt in ATMEGA T1 here:
    http://www.etantdonnes.com/Motes/AVR128timers.zip

Look for "TOSH_INTERRUPT" in HPLT3captureM.nc. That installs a
pointer to the following code in the interrupt vector list at the
"SIG_INPUT_CAPTURE3" location. The vectors are defined in
     \usr\local\avr\include\avr\iom128.h
You need to figure out which one you are using for your button,
and how to enable it in the controller. The ATMEGA-128 manual
is the thing to look at for that. (Actually, if you are not
using the CAPTURE3 pin for the timers you can probably just
use it for your input...)

Also note that a mechanical button is going to bounce so you
will probably get multiple interrupts for each operation.

MS


liangjing wrote:
> Hi Steve ,
>   I have read the TEP 117 and found that it is a tinyos 2.0 version ,
> but our platform is mica2 and a tinyos 1.0 version . I am sorry that I
> don't write this in advance and I don't find Low-Level I/O
> documentation in www.tinyos.net/tinyos-1.x/doc so the code doesn't
> seem to fit with our platform,  maybe I need to write our own button
> interface and module comparable with HplMsp430GeneralIOC and
> GpioInterruptC in your code, is that right ? Thank you again for your
> specific advice.
>
> Best Wishes
> Jing
>
> 2007/5/7, Steve McKown <[EMAIL PROTECTED]>:
>> Hi Jing,
>>
>> On Monday 07 May 2007 02:18, liangjing wrote:
>> > Thank you for your reply. And I have some doubt about the interface
>> > Int. The demo gives some code defining command Init.init() and async
>> > event void Int.fired(),but I still don't know how to trigger the
>> > event, and I don't find it in the configuration file either. Could you
>> > help me explain it further?
>>
>> Perhaps I misunderstood what you wanted to do?  I though you wanted to
>> perform
>> some action when a button on the mote was pressed.  Therefore,
>> Int.fired()
>> is
>> signalled by the button. Have you read TEP 117? It describes how TinyOS
>> handles low level IO and is available as a link from the
>> www.tinyos.net home
>> page.  If it is unclear, perhaps you should make a test program out of
>> the
>> code snippet and do some experimentation on your own.
>>
>> Here's a summary of what the code snippet I sent is doing:
>>
>> HplMsp430GeneralIOC provides an msp430 specific interface for every
>> digital
>> IO
>> available on the uC hardware.  HplMsp430InterruptC provides an msp430
>> specific interface for every digital IO which is capable of generating an
>> interrupt on state change of its pin.
>>
>> The example assumes the button is connected to the msp430's P2.0 pin,
>> which
>> is
>> associated with bit 0 of port 2 of the msp430 (sometimes called port20 or >> port2.0, etc.). The physical button is configured such that the button >> presents an active high state to the pin normally and active low when the
>> button is pressed.  The hardware could be configured differently, of
>> course.
>>
>> SomeButtonC instantiates one each of GeneralIOC (Pin) and GpioInterruptC
>> (Int)
>> components that convert the respective msp430 specific interfaces into
>> platform independent ones.
>>
>> The boot process calls SomeButtonP's Init.init(), which configures the
>> iopin.
>> This function first makes the iopin an input, then sets the interrupt to
>> fire
>> on its rising edge (i.e. a low to high transition of the pin's input
>> state).
>>
>> Given the hardware assumption above, this means the interrupt actually
>> fires
>> as the button is released.
>>
>> Code present in core TinyOS and the configuration in SomeButtonC
>> ensure that
>> when the interrupt is fired, the SomeButtonP's Int.fired() event is
>> signalled.  This code can then deal with the event as is appropriate
>> for the
>> application.
>>
>> Steve
>>
>> > 2007/4/30, Steve McKown <[EMAIL PROTECTED]>:
>> > > Hi Jing,
>> > >
>> > > On Monday 30 April 2007 01:13, liangjing wrote:
>> > > > In the experiment we want to trigger an event or task that
>> implement
>> > > > the related work after switching off the button ? I don't know if
>> > > > there exists an interrupt procedure in Tinyos since I don't find
>> some
>> > > > app using the kind of interrupt.Please help me.
>> > >
>> > > In tos, to handle an interrupt from a button, create and configure a
>> > > GpioInterrupt component and wire it to the io pin to which the
>> button is
>> > > attached. Here's an example for msp430 platform where the button is >> > > connected to port 2.0 of the uC. Other arches are probably similar.
>> > >
>> > > configuration SomeButtonC {
>> > >   provides interface Init;
>> > >   provides interface ...
>> > > }
>> > > implementation
>> > > {
>> > >   components SomeButtonP;
>> > >   Init = SomeButtonP;
>> > >
>> > >   components HplMsp430GeneralIOC, new Msp430GpioC() as UserImpl;
>> > >   UserImpl -> HplMsp430GeneralIOC.Port20;
>> > >   SomeButtonP.Pin = UserImpl;
>> > >
>> > > components HplMsp430InterruptC, new Msp430InterruptC() as UserInt;
>> > >   UserInt.HplInterrupt -> HplMsp430InterruptC.Port20;
>> > >   SomeButtonP.Int = UserInt;
>> > > }
>> > >
>> > > And the module code...
>> > >
>> > > module SomeButtonP {
>> > >   uses interface GeneralIO as Pin;
>> > >   uses interface GpioInterrupt as Int;
>> > >   provides interface Init;
>> > >   provides interface ...
>> > > }
>> > > implementation {
>> > >   command error_t Init.init()
>> > >   {
>> > >     call Pin.makeInput();
>> > >     call Int.enableRisingEdge();
>> > >     return SUCCESS;
>> > >   }
>> > >
>> > >   async event void Int.fired()
>> > >   {
>> > >     /* deal with button interrupt here, for example:
>> > >     signal SomeInterface.button();
>> > >       or
>> > >     post buttonFired();
>> > >       etc.
>> > >     */
>> > >   }
>> > > }
>> > >
>> > > You should think carefully about what constitutes a valid
>> interrupt from
>> > > a user button.  For simple "command type" user buttons, I usually
>> disable
>> > > the interrupt as soon as one is received (in Int.fired or its call
>> > > chain), then have the higher level code re-enable the interrupt
>> when it
>> > > is prepared to service another button press.
>> > >
>> > > Steve
>> >
>> > !DSPAM:463f2835136641565118635!
>>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to