Microchip® Advanced Software Framework

Quick Start Guide for the MEGARF ext int Driver

This is the quick start guide for the Global interrupt management , with step-by-step instructions on how to configure and use the driver for a specific use case.

The code examples can be copied into e.g the main application loop or any other function that will need to control the external interrupt.

Use cases

External Interrupt

This use case will prepare a external interrupt pin to trigger an interrupt when the there is a change in pin state. The interrupt is handled by a cutomisable callback function. We will setup the external interrupt in this mode:

  • Enable the interrupt for falling edge(for example)
  • Use the system clock as clock source
  • Enable the Global Interrupt

Setup steps

Prequisites

For the setup code of this use case to work, the following must be added to the project:

Example code

Add a callback function that will be executed when the interrupt trigger.

static void ext_int_callback(void)
{
// User code to execute when the interrupt occurs here
}

Add to, e.g., the main loop in the application C-file:

Workflow

  1. Enable the clock system:
  2. Enable External Interrupt INT0
  3. Set the callback function for interrupt
  4. Enable interrupts:

Usage steps

  • None. The code written in the call back function will execute each time external interrupt pin state changes to falling edge.

external pin change interrupt

This use case will prepare a external pin change interrupt to trigger an interrupt when the there is a change in pin state. The interrupt is handled by a cutomisable callback function.

We will setup the external interrupt in this mode:

  • Enable the pin change interrupt
  • Use the system clock as clock source
  • Enable the Global Interrupt

Setup steps

Prequisites

For the setup code of this use case to work, the following must be added to the project:

Example code

Add a callback function that will be executed when the interrupt trigger.

static void ext_pcint_callback(void)
{
// User code to execute when the interrupt occurs here
}

Add to, e.g., the main loop in the application C-file:

ext_int_set_interrupt_callback(PC_INT8, ext_pcint_callback);

Workflow

  1. Enable the clock system:
  2. Enable External Interrupt INT0
  3. Set the callback function for interrupt
  4. Enable interrupts:

Usage steps

  • None. The code written in the call back function will execute each time external interrupt pin state changes.