µTasker Forum

µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: Jacobo on March 02, 2009, 02:09:58 AM

Title: Intrruptions in port
Post by: Jacobo on March 02, 2009, 02:09:58 AM
Hi Mark!

in what place of the program can handle the state change interrupts on port.

Regards
Title: Re: Intrruptions in port
Post by: mark on March 02, 2009, 01:57:34 PM
Hi Jacobo

The M522XX supports Edge Ports (IRQ1..IRQ15, depending on exact part).

In application.c there is a demonstration of its use - see IRQ_TEST. This requires SUPPORT_EPORT to be active in app_hw_m5223x.h

Example of setting up a rising edge interrupt on IRQ4:

    INTERRUPT_SETUP interrupt_setup;                                     // interrupt configuration parameters
    interrupt_setup.int_type     = PORT_INTERRUPT;                       // identifier when configuring {25} - always initialise

    interrupt_setup.int_priority = (INTERRUPT_LEVEL_4);                  // interrupt priority level (this can not be modified for IRQ1..IRQ7 so the value is not really relevant)
    interrupt_setup.int_handler  = test_irq_4;                           // handling function
    interrupt_setup.int_port_bit = 4;                                    // the IRQ input connected
    interrupt_setup.int_port_sense = IRQ_RISING_EDGE;                    // interrupt on this edge
    fnConfigureInterrupt((void *)&interrupt_setup);                      // configure test interrupt


The possible interrupt types are:

IRQ_LEVEL_SENSITIVE
IRQ_FALLING_EDGE
IRQ_RISING_EDGE
IRQ_BOTH_EDGES


The user handler is called from the interrupt but doesn't need to handle interrupt handling details. The following shows the define user handler (test_irq_4()) being used to wake the local task due to the edge event, which can then perform further processing 'off-line'


static void test_irq_4(void)
{
    fnInterruptMessage(OWN_TASK, IRQ4_EVENT);
}


Regards

Mark