NetBurner 3.5.6
PDF Version
External IRQ

External IRQ Example

Overview

This example application demonstrates how to configure and use external interrupt (IRQ) functionality on NetBurner embedded platforms. The program sets up a GPIO pin to trigger an external interrupt, allowing you to test interrupt handling in real-time through a simple serial terminal interface.

Supported Platforms

  • MOD5441x (MOD54415, MOD54417, SB800EX)
  • NANO54415
  • MODM7AE70
  • SBE70LC
  • SOMRT1061

Hardware Setup

Required Connection

A jumper wire must be placed between the GPIO output pin and the desired interrupt input pin for each platform:

MOD5441x Platforms

  • GPIO Output: J2.33
  • Available IRQ Inputs:
    • IRQ 1: J2.45
    • IRQ 2: J2.43
    • IRQ 3: J2.26 (default in code)
    • IRQ 6: J2.47

NANO54415

  • GPIO Output: Pin 12 (Dev board P2.12)
  • Available IRQ Inputs:
    • IRQ 2: Pin 50 (Dev board P1.50)
    • IRQ 3: Pin 49 (Dev board P1.49) (default in code)

MODM7AE70

  • GPIO Output: P2.15 (connected to first LED on MOD-DEV-70 board)
  • IRQ Input: P2.8 (configurable to any GPIO pin)

SBE70LC

  • GPIO Output: J1[4]
  • IRQ Input: J1[3]

SOMRT1061

  • GPIO Output: Pin 86 (connected to first LED on DEV-S61 board)
  • IRQ Input: Pin 14

How It Works

Interrupt Mechanism

  1. The application configures a GPIO pin as an output (initially high)
  2. Another pin is configured as an external interrupt input
  3. When you trigger an interrupt via the menu, the GPIO output goes low
  4. This transition triggers the external interrupt
  5. The Interrupt Service Routine (ISR) executes:
    • Sets the GPIO pin back to high
    • Increments the interrupt counter
  6. The main loop displays the current interrupt count

Interrupt Service Routine (ISR)

The ISR behavior varies by platform:

MCF5441x Platforms (MOD5441x, NANO54415):**

void ExternalISR()
{
// Set GPIO pin high and increment counter
IrqCounter++;
}

ARM Platforms (MODM7AE70, SBE70LC, SOMRT1061):**

void ExternalISR(int port, int portPin)
{
// Records which port/pin triggered the interrupt
gRxIrqPort = port;
gRxIrqPortPin = portPin;
IrqCounter++;
}

User Interface

The application provides a simple command-line menu accessible via serial terminal (MTTTY or similar):

Available Commands

  • T - Trigger interrupt by setting GPIO low
  • ? - Display the main menu
  • Enter - Display current interrupt count

Menu Output

----- Main Menu -----
T - Trigger interrupt by writing GPIO low
? - Display Menu
<enter> - Display interrupt count
Number of interrupts: [count]
Last Irq: port=[x], pin=[y] // ARM platforms only

Configuration Options

IRQ Priority Levels

  • MCF5441x: Fixed priority levels (1=lowest, 7=highest)
  • ARM Platforms: Configurable priority (1=highest, 7=lowest, default=4)

IRQ Trigger Modes (ARM Platforms)

#define IRQ_POLARITY_HIGH_LEVEL 2
#define IRQ_POLARITY_RISING_EDGE 1
#define IRQ_POLARITY_EITHER_EDGE 0
#define IRQ_POLARITY_FALLING_EDGE -1 // Used in example
#define IRQ_POLARITY_LOW_LEVEL -2

Building and Running

  1. Hardware Setup: Connect jumper wire between GPIO output and IRQ input pins
  2. Compile: Build the project using NetBurner development tools
  3. Deploy: Flash the application to your NetBurner module
  4. Connect: Use MTTTY or serial terminal (115200 baud) to interact
  5. Test: Use menu commands to trigger interrupts and monitor counts

Key Functions Used

  • SetPinIrq() - Configures pin for external interrupt detection
  • SetPortIrqPriority() - Sets interrupt priority level (ARM platforms)
  • GPIO pin configuration functions (platform-specific)

Important Notes

  • The Edge Port Flag Register is automatically cleared by the SetPinIrq() implementation
  • On ARM platforms, all GPIO pins on the same port share the same IRQ priority level
  • The example uses falling edge detection by default on ARM platforms
  • System diagnostics are enabled for debugging (remove for production)

Troubleshooting

  • No interrupts triggered: Verify jumper wire connections
  • Unexpected behavior: Check that only one IRQ input is uncommented in the code
  • Serial issues: Ensure correct baud rate (115200) and terminal settings

This example serves as a foundation for implementing external interrupt handling in your own NetBurner applications.