4.5.1 Interrupts

4.5.1.1 Introduction

The Interrupt Manager handles and prioritizes the interrupt requests from the different peripheral modules. It also provides APIs for users to control how global, peripheral, and external interrupts will be serviced.

4.5.1.2 Supported Device Families

PIC12/16F150xPIC12/16F155xPIC12/16F157xPIC12/16F161x
PIC12/16F184xPIC16F145xPIC16F151xPIC16F152x
PIC16F153xxPIC16F170xPIC16F171xPIC16F176x
PIC16F177xPIC16F178xPIC16F183xxPIC16F184xx
PIC16F188xxPIC16F191xx PIC16F193x PIC16F194x
PIC16LF156x PIC16LF190xPIC18F-K40PIC18F-Q10

4.5.1.3 Required header files

#include "mcc_generated_files/system/interrupt.h"

4.5.1.4 Module Documentation

4.5.1.4.1 INTERRUPT MANAGER

Driver Version

Interrupt Manager Driver Version 2.03
Definitions
  • #define INTERRUPT_GlobalInterruptEnable() (INTCONbits.GIE = 1)

    This macro will enable global interrupts.

  • #define INTERRUPT_GlobalInterruptDisable() (INTCONbits.GIE = 0)

    This macro will disable global interrupts.

  • #define INTERRUPT_GlobalInterruptStatus() (INTCONbits.GIE)

    This macro will return the global interrupt enable bit status.

  • #define INTERRUPT_PeripheralInterruptEnable() (INTCONbits.PEIE = 1)

    This macro will enable peripheral interrupts.

  • #define INTERRUPT_PeripheralInterruptDisable() (INTCONbits.PEIE = 0)

    This macro will disable peripheral interrupts.

  • #define EXT_INT_InterruptFlagClear() (PIR0bits.INTF = 0)

    This routine clears the interrupt flag for the external interrupt, INT.

  • #define EXT_INT_InterruptDisable() (PIE0bits.INTE = 0)

    This routine clears the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will not be serviced by the interrupt handler.

  • #define EXT_INT_InterruptEnable() (PIE0bits.INTE = 1)

    This routine sets the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will be serviced by the interrupt handler.

  • #define EXT_INT_risingEdgeSet() (INTCONbits.INTEDG = 1)

    This routine set the edge detect of the extern interrupt to positive edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a low to high level.

  • #define EXT_INT_fallingEdgeSet() (INTCONbits.INTEDG = 0)

    This routine set the edge detect of the extern interrupt to negative edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a high to low level.

Functions
  • void __interrupt ()

    This routine services the ISRs of enabled interrupts and is called everytime an interrupt is triggered.

  • void INTERRUPT_Initialize (void)

    Initializes Peripheral Interrupt priorities; Enables/disables priority vectors; and, Initializes External Interrupt.

  • void INT_ISR (void)

    This ISR will execute whenever the signal on the INT pin will transition to the preconfigured state.

  • void INT_CallBack (void)

    Allows for a specific callback function to be called in the INT ISR and allows for a non-specific interrupt handler to be called at runtime.

  • void INT_SetInterruptHandler (void(*InterruptHandler)(void))

    Allows selecting an interrupt handler for EXT_INT - INT at application runtime.

  • void INT_DefaultInterruptHandler (void)

    This is the default interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Variables
  • void(* INT_InterruptHandler )(void)

    This is the dynamic interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Definition Documentation

EXT_INT_fallingEdgeSet

#define EXT_INT_fallingEdgeSet( ) (INTCONbits.INTEDG = 0)

This routine set the edge detect of the extern interrupt to negative edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a high to low level.

Parameters:
void
Returns:

void

EXT_INT_InterruptDisable

#define EXT_INT_InterruptDisable( ) (PIE0bits.INTE = 0)

This routine clears the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will not be serviced by the interrupt handler.

Parameters:
void
Returns:

void

EXT_INT_InterruptEnable

#define EXT_INT_InterruptEnable( ) (PIE0bits.INTE = 1)

This routine sets the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will be serviced by the interrupt handler.

Parameters:
void
Returns:

void

EXT_INT_InterruptFlagClear

#define EXT_INT_InterruptFlagClear( ) (PIR0bits.INTF = 0)

This routine clears the interrupt flag for the external interrupt, INT.

Parameters:
void
Returns:

void

EXT_INT_risingEdgeSet

#define EXT_INT_risingEdgeSet( ) (INTCONbits.INTEDG = 1)

This routine set the edge detect of the extern interrupt to positive edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a low to high level.

Parameters:
void
Returns:

void

INTERRUPT_GlobalInterruptDisable

#define INTERRUPT_GlobalInterruptDisable( ) (INTCONbits.GIE = 0)

This macro will disable global interrupts.

Parameters:
void
Returns:

void

INTERRUPT_GlobalInterruptEnable

#define INTERRUPT_GlobalInterruptEnable( ) (INTCONbits.GIE = 1)

This macro will enable global interrupts.

Parameters:
void
Returns:

void

INTERRUPT_GlobalInterruptStatus

#define INTERRUPT_GlobalInterruptStatus( ) (INTCONbits.GIE)

This macro will return the global interrupt enable bit status.

Parameters:
void
Return values:
0

- Global Interrupt Disabled

1

- Global Interrupt Enabled

INTERRUPT_PeripheralInterruptDisable

#define INTERRUPT_PeripheralInterruptDisable( ) (INTCONbits.PEIE = 0)

This macro will disable peripheral interrupts.

Parameters:
void
Returns:

void

INTERRUPT_PeripheralInterruptEnable

#define INTERRUPT_PeripheralInterruptEnable( ) (INTCONbits.PEIE = 1)

This macro will enable peripheral interrupts.

Parameters:
void
Returns:

void

Function Documentation

__interrupt()

void __interrupt ( )

This routine services the ISRs of enabled interrupts and is called everytime an interrupt is triggered.

Precondition:

Interrupt Manager is initialized.

Parameters:
void
Returns:

void

INT_CallBack()

void INT_CallBack (void )

Allows for a specific callback function to be called in the INT ISR and allows for a non-specific interrupt handler to be called at runtime.

Precondition:

Interrupt Manager is initialized.

Parameters:
void
Returns:

void

INT_DefaultInterruptHandler()

void INT_DefaultInterruptHandler (void )

This is the default interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Precondition:

Interrupt Manager is initialized.

Parameters:
void
Returns:

void

INT_ISR()

void INT_ISR (void )

This ISR will execute whenever the signal on the INT pin will transition to the preconfigured state.

Section: External Interrupt Handlers

Precondition:

Interrupt Manager is initialized.

Parameters:
void
Returns:

void

INT_SetInterruptHandler()

void INT_SetInterruptHandler (void(*)(void) InterruptHandler)

Allows selecting an interrupt handler for EXT_INT - INT at application runtime.

Precondition:

Interrupt Manager is initialized.

Parameters:
(*InterruptHandler)(void)

- InterruptHandler function pointer

Returns:

void

INTERRUPT_Initialize()

void INTERRUPT_Initialize (void )

Initializes Peripheral Interrupt priorities; Enables/disables priority vectors; and, Initializes External Interrupt.

Parameters:
void
Returns:

void

Variable Documentation

INT_InterruptHandler

void(* INT_InterruptHandler) (void)

This is the dynamic interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Precondition:

Interrupt Manager is initialized.

Parameters:
void
Returns:

void

4.5.1.5 File Documentation

4.5.1.5.1 source/interrupt.c File Reference

This file contains the driver code for Interrupt Manager.

#include "../../system/interrupt.h"
#include "../../system/system.h"

Functions

  • void INTERRUPT_Initialize (void)

    Initializes Peripheral Interrupt priorities; Enables/disables priority vectors; and, Initializes External Interrupt.

  • void __interrupt ()

    This routine services the ISRs of enabled interrupts and is called everytime an interrupt is triggered.

  • void INT_ISR (void)

    This ISR will execute whenever the signal on the INT pin will transition to the preconfigured state.

  • void INT_CallBack (void)

    Allows for a specific callback function to be called in the INT ISR and allows for a non-specific interrupt handler to be called at runtime.

  • void INT_SetInterruptHandler (void(*InterruptHandler)(void))

    Allows selecting an interrupt handler for EXT_INT - INT at application runtime.

  • void INT_DefaultInterruptHandler (void)

    This is the default interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Variables

  • void(* INT_InterruptHandler )(void)

    This is the dynamic interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Detailed Description

This file contains the driver code for Interrupt Manager.

Interrupt Manager Generated Driver File

Version: Interrupt Manager Driver Version 2.03

4.5.1.5.2 source/interrupt.h File Reference

Functions

  • void INTERRUPT_Initialize (void)

    Initializes Peripheral Interrupt priorities; Enables/disables priority vectors; and, Initializes External Interrupt.

  • void INT_ISR (void)

    This ISR will execute whenever the signal on the INT pin will transition to the preconfigured state.

  • void INT_CallBack (void)

    Allows for a specific callback function to be called in the INT ISR and allows for a non-specific interrupt handler to be called at runtime.

  • void INT_SetInterruptHandler (void(*InterruptHandler)(void))

    Allows selecting an interrupt handler for EXT_INT - INT at application runtime.

  • void INT_DefaultInterruptHandler (void)

    This is the default interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Macros

  • #define INTERRUPT_GlobalInterruptEnable() (INTCONbits.GIE = 1)

    This macro will enable global interrupts.

  • #define INTERRUPT_GlobalInterruptDisable() (INTCONbits.GIE = 0)

    This macro will disable global interrupts.

  • #define INTERRUPT_GlobalInterruptStatus() (INTCONbits.GIE)

    This macro will return the global interrupt enable bit status.

  • #define INTERRUPT_PeripheralInterruptEnable() (INTCONbits.PEIE = 1)

    This macro will enable peripheral interrupts.

  • #define INTERRUPT_PeripheralInterruptDisable() (INTCONbits.PEIE = 0)

    This macro will disable peripheral interrupts.

  • #define EXT_INT_InterruptFlagClear() (PIR0bits.INTF = 0)

    This routine clears the interrupt flag for the external interrupt, INT.

  • #define EXT_INT_InterruptDisable() (PIE0bits.INTE = 0)

    This routine clears the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will not be serviced by the interrupt handler.

  • #define EXT_INT_InterruptEnable() (PIE0bits.INTE = 1)

    This routine sets the interrupt enable for the external interrupt, INT, and thereafter external interrupts on this pin will be serviced by the interrupt handler.

  • #define EXT_INT_risingEdgeSet() (INTCONbits.INTEDG = 1)

    This routine set the edge detect of the extern interrupt to positive edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a low to high level.

  • #define EXT_INT_fallingEdgeSet() (INTCONbits.INTEDG = 0)

    This routine set the edge detect of the extern interrupt to negative edge, and thereafter interrupt flag will be set when the external interrupt pins level transitions from a high to low level.

Variables

  • void(* INT_InterruptHandler )(void)

    This is the dynamic interrupt handler which is called every time the INT ISR is executed and allows any function to be registered at runtime.

Detailed Description

Interrupt Manager Generated Driver API Header File