[En-Nut-Discussion] external irq, wiki
harald.kipp at egnite.de
Tue Dec 20 11:24:22 CET 2011
On 20.12.2011 06:43, Klaus Kloos wrote:
> Im searching for an example of using an external irq using ethernut and SAM7x.
NutRegisterIrqHandler(&sig_INTERRUPT0, MyHandler, ¶m);
to register the interrupt routine MyHandler() for external interrupt 0.
Some CPUs provide interrupt triggering on simple GPIO pins. This is
supported by the signals sig_GPIOA, sig_GPIOB etc.
The interrupt handler is a simple C function, where the pointer to param
is passed as an argument.
static void MyHandler(void *arg)
When handling sig_GPIO interrupts for several pins, the handler must
determine the interrupt source.
to enable or disable this interrupt. In addition, the hardware may
require additional initialization like enabling clocks etc.
to set the interrupt mode, where mode may be
depending on the capabilities of your hardware.
All these functions work on all supported platforms. Your application
will be fully portable.
The backside of the coin is, that they add a significant amount of
overhead. If you need fast interrupt responses, you better implement
them in a native way. Nut/OS allows this. You'll probably find
sufficient infos in the web, e.g.
Note, that you cannot call most Nut/OS API functions from within
In general, avoid any lengthy code in the handler. The above call may
trigger a thread that sits at
and processes the interrupt when triggered.
But you can use stdio functions like putchar(), puts() and even printf()
for debugging, if stdout has been opened on the DEV_DEBUG device.
> On the page http://www.ethernut.de/nutwiki/Nut/OS_Examples there is a link to 'Digital Input Interrupt' which sounds very good, but it is red and using it gives an
> 'The action you have requested is limited to users in the group user.'.
Please see my next post.
More information about the En-Nut-Discussion