Author Topic: Interrupt generation  (Read 6324 times)

Offline evgenik

  • Newbie
  • *
  • Posts: 18
    • View Profile
Interrupt generation
« on: June 19, 2008, 06:21:05 AM »
Hi Mark.

How I can generate Interrupt without external source? For exmple generate interrupt on Bit 7 of port GP?

Thanks.
Evgeni.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Interrupt generation
« Reply #1 on: June 19, 2008, 12:04:57 PM »
Hi Evgeni

The M5223X supports external interrupts on NQ and GP (IRQ1..IRQ15 - depending on exact package and chip).
In the demo project there is a set up test - in application.c activate it using #define IRQ_TEST.
In fnInitIRQ() it will configure some interrupts with different characteristics (falling edge, rising edge, both edges and level sensitive). The following is code for bit 7 of GP (IRQ15) to configure a falling edge interrupt:

Code: [Select]
    INTERRUPT_SETUP interrupt_setup;                                     // interrupt configuration parameters
    interrupt_setup.int_priority = (IRQ15_INTERRUPT_PRIORITY);           // set level and priority
    interrupt_setup.int_handler  = test_irq_15;                          // handling function
    interrupt_setup.int_port_bit = 15;                                   // The IRQ input connected (on all devices)
    interrupt_setup.int_port_sense = IRQ_RISING_EDGE;                    // Interrupt on this edge
    fnConfigureInterrupt((void *)&interrupt_setup);                      // configure test interrupt

Note that IRQ15_INTERRUPT_PRIORITY needs to be defined (see app_hw_m5223x.h for examples of others) so that it has a unique level and priority. You define the handling routine as follows. It is a callback so shouldn't be defined as an interrupt routine, but it is running from within the interrupt so should be kept as short as possible - eg:
static void test_irq_15(void)
{
    fnInterruptMessage(OWN_TASK, IRQ15_EVENT);  // send an event to wake a task
}


Note that there is a patch for the edge ports in SP7 - see the following:
http://www.utasker.com/forum/index.php?topic=265.msg1123#msg1123

The uTasker simulator allows the edge port interrupts to be tested - just toggle the input port accordingly to test the interrupt and your interrupt code.

Regards

Mark