News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Positron Board manual cover

Started by top204, Apr 10, 2021, 04:12 PM

Previous topic - Next topic

okaman

#20
There was also lochmaster among such programs
I guess it's just like that!

DWIN Sale Manager TURKEY
(info@kamantek.com)
http://www.kamantek.com/shop/index.php

Giuseppe

I wanted to ask
But by purchasing the proton license is it also valid for the new pdf and compiler?

Yasin

Hello to everyone. As far as I understand from the pictures, there will be PIC18F27K42 on the Positron board. This mcu also has no usb hardware. There is a usb connector on the PCB. In this case, which chip is preferred between mcu and usb connector. I wondered?
Best Regards.

Dompie

Wowwwwww coming home from vacation seeing this Positron thread.
Can't wait to order!
Les, good luck finishing this Positron project.

Johan

top204

#24
Many thanks Johan.

I'm currently busy with some projects for the Positron board's manual and some libraries for the PIC18F27K42, which is a "really" nice device with the compiler's optimisations for it!

How about this rotary encoder library that uses the Interrupt Manager library I created and IOC to make a standard rotary encoder work flawlessly, and simply, and never misses a rotation even if the main program is busy:

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Positron board rotary encoder reader, using an IOC (Interrupt On Change) interrupt.
' It never misses a rotation because the IOC always gets fired when a rotation happens.
'
' Written by Les Johnson for the Positron board, with the Positron8 BASIC compiler.
'
$define Handle_IOC_Int                                  ' Inform the Positron Interrupt Manager that we require an IOC interrupt handled

    Include "Positron Int Manager.inc"                  ' Load the Positron Interrupt Manager routines into the program
'
' Create some variables for the rotary encode routines
'
    Dim Enc_bPinStore   As Byte Access                  ' Stores the pin conditions when the IOC interrupt triggers
    Dim Enc_wCounter    As Word Access                  ' Increments or decrements depending on the direction of the rotary encoder
    Dim Enc_bIncDecValue As Byte Access                 ' The amount that Enc_wCounter will increment or decrement by when the encoder is moved
    Dim Enc_tTriggered  As Bit                          ' Holds the IOC triggered flag
    Dim Enc_tDir        As Bit                          ' Holds the direction of the rotary encoder

    Symbol Enc_cAntiClockwise = 0                       ' Signals that the encoder's rotation movement is anti-clockwise
    Symbol Enc_cClockwise = 1                           ' Signals that the encoder's rotation movement is clockwise

'------------------------------------------------------------------------------------------------
' Setup the library for the rotary encoder
'
Proc Enc_Setup()
    PinMode(Enc_Pin1, Input_PullUp)                     ' \ Make sure the encoder pins are inputs
    PinMode(Enc_Pin2, Input_PullUp)                     ' / And enable the internal pullup resistors on them

    Enc_bIncDecValue = 1                                ' Default to an increment or decrement of 1 per rotation movement
    Enc_wCounter = 0                                    ' Clear the rotation counter
    Enc_tTriggered = False                              ' Reset the rotated flag

    IOC_RB1_Edge(Falling)                               ' IOC Interrupt on a falling edge on pin PORTB.1
    IOC_RB1_ClearIntFlag()                              ' Clear the IOC interrupt flag for PORTB.1
    IOC_ClearIntFlag()                                  ' Clear the IOC interrupt flag
    IOC_IntEnable()                                     ' Enable IOC interrupts

    IntGlobal_Enable()                                  ' Enable global interrupts
EndProc

'--------------------------------------------------------------------------
' IOC (Interrupt On Change) Interrupt handler
' Input     : None
' Output    : Variable Enc_wCounter is incremented or decremented depending on the rotation direction
'           : Enc_tTriggered is True if there is a movement on the rotary encoder
'           : Enc_tDir holds 0 if the rotary encoder is travelling anti-clockwise, else holds 1 if travelling clockwise
' Notes     : Uses an IOC (Interrupt On Change) where one of the rotary encoder's pins are connected
'
ISR_IOC(Start)
    If IOC_RB1_IntFlag = True Then                              ' Is it an Interrupt On Change on PORTB.1?
        Enc_tTriggered = True                                   ' Yes. So set the rotation triggered flag
        Enc_bPinStore = %00000000                               ' Clear the variable Enc_bPinStore
        Enc_bPinStore.0 = Enc_Pin1                              ' Place the condition of pin Enc_Pin1 into bit-0 of Enc_bPinStore
        Enc_bPinStore.1 = Enc_Pin2                              ' Place the condition of pin Enc_Pin2 into bit-1 of Enc_bPinStore
        If Enc_bPinStore = %00000000 Then                       ' Is Enc_bPinStore 0?
            Enc_tDir = Enc_cClockwise                           ' Yes. So indicate that it is a clockwise movement
            If Enc_wCounter < 65535 Then                        ' \
                Enc_wCounter = Enc_wCounter + Enc_bIncDecValue  ' | Increment the rotation counter
            EndIf                                               ' /
        Else                                                    ' Otherwise...
            Enc_tDir = Enc_cAntiClockwise                       ' Indicate that it is an anti-clockwise movement
            If Enc_wCounter > 0 Then                            ' \
                Enc_wCounter = Enc_wCounter - Enc_bIncDecValue  ' | Decrement the rotation counter
            EndIf                                               ' /
        EndIf
        IOC_RB1_ClearIntFlag()                                  ' Clear the IOC flag for PORTB.1
    EndIf
ISR_IOC(Exit)

I've also incorporated it into a demo project for an Si4730-D60 radio chip that makes a LW/MW/SW/FM receiver using the Positron board and the rotary encoder to tune it. The Si473x library will be available for the Positron8 compiler as soon as the board and manual are released.

Giuseppe

For the usb chip you could use CH340X which does not need external quartz

top204

Thanks Guiseppe.

I have looked at the CH340E device that has an internal oscillator. However, they were more expensive than a CH340G device and the external crystal combined. :-)

If they come down in price, I will use a CH340E in future boards because the drivers are available for all Operating Systems.


Bob (G8GFA)

Looking good Les, such a neat device. Looking forward to getting a couple for myself!

gtvpic

Hello, I also want a pair
I hope you have a large order list so that we can all have at least a couple of these with the compiler and it will be a good deal for you. It's about time you made money Les.
By the way, I understand that the compiler and the boards will be available at the same time, right?
The list of orders I do not think is a bad idea, at least that those interested pay a part so that you do not have to advance all the money.
What do you think Les?

Yasin

I used CP2102. I have done many applications. Very resistant to stress. Small mistakes do not deteriorate immediately. I always like Silabs products. PC Driver is no problem. The old new version does not matter. It is fully compatible. I highly recommend it. CP2102 and its siblings also do not want external crystals.
Best regards.

top204

Many thanks Yasin. However, the CP2012 is a "lot" more expensive that any of the CH340 devices, and with this board, price of the components is very important, as well as reliabability.

The CH340G device works extremely well and I have had no problems with it at all. :-)

HAL

Will the boards be available via your "top 204" ebay site?
The cover for the manual looks great!

okaman

#32
dear Les,
what about the new positron compilers, boards and guides?
may we learn the release dates?

Can you at least give us a roughly estimated date?
DWIN Sale Manager TURKEY
(info@kamantek.com)
http://www.kamantek.com/shop/index.php

JonW

Quote from: top204 on May 03, 2021, 08:53 PMMany thanks Yasin. However, the CP2012 is a "lot" more expensive that any of the CH340 devices, and with this board, price of the components is very important, as well as reliabability.

The CH340G device works extremely well and I have had no problems with it at all. :-)

I recently used the CH9340DS in a project, from memory they were around $0.25 or less in 50k volumes and not much more in small qty and don't require any external crystal or resonator.  The only issue we had was compatibility with really old Windows builds.  Win 10 has no issues

You should look at JLCPCB for boards and fast turn SMT, they can also get hold of most devices and its a great resource to browse through their vendor list to see the Chinese counterparts to optimise cost.  https://jlcpcb.com/

They are dirt cheap and the boards are decent quality.  They are limited to FR4 substrates but their controlled impedance board stack can easily be pushed to 10GHz and beyond as long as your structures can cope with the DK variance

Jon

SebaG

Quote from: top204 on May 03, 2021, 09:42 AMMany thanks Johan.

I'm currently busy with some projects for the Positron board's manual and some libraries for the PIC18F27K42, which is a "really" nice device with the compiler's optimisations for it!

How about this rotary encoder library that uses the Interrupt Manager library I created and IOC to make a standard rotary encoder work flawlessly, and simply, and never misses a rotation even if the main program is busy:

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Positron board rotary encoder reader, using an IOC (Interrupt On Change) interrupt.
' It never misses a rotation because the IOC always gets fired when a rotation happens.
'
' Written by Les Johnson for the Positron board, with the Positron8 BASIC compiler.
'
$define Handle_IOC_Int                                  ' Inform the Positron Interrupt Manager that we require an IOC interrupt handled

    Include "Positron Int Manager.inc"                  ' Load the Positron Interrupt Manager routines into the program
'
' Create some variables for the rotary encode routines
'
    Dim Enc_bPinStore   As Byte Access                  ' Stores the pin conditions when the IOC interrupt triggers
    Dim Enc_wCounter    As Word Access                  ' Increments or decrements depending on the direction of the rotary encoder
    Dim Enc_bIncDecValue As Byte Access                 ' The amount that Enc_wCounter will increment or decrement by when the encoder is moved
    Dim Enc_tTriggered  As Bit                          ' Holds the IOC triggered flag
    Dim Enc_tDir        As Bit                          ' Holds the direction of the rotary encoder

    Symbol Enc_cAntiClockwise = 0                       ' Signals that the encoder's rotation movement is anti-clockwise
    Symbol Enc_cClockwise = 1                           ' Signals that the encoder's rotation movement is clockwise

'------------------------------------------------------------------------------------------------
' Setup the library for the rotary encoder
'
Proc Enc_Setup()
    PinMode(Enc_Pin1, Input_PullUp)                     ' \ Make sure the encoder pins are inputs
    PinMode(Enc_Pin2, Input_PullUp)                     ' / And enable the internal pullup resistors on them

    Enc_bIncDecValue = 1                                ' Default to an increment or decrement of 1 per rotation movement
    Enc_wCounter = 0                                    ' Clear the rotation counter
    Enc_tTriggered = False                              ' Reset the rotated flag

    IOC_RB1_Edge(Falling)                               ' IOC Interrupt on a falling edge on pin PORTB.1
    IOC_RB1_ClearIntFlag()                              ' Clear the IOC interrupt flag for PORTB.1
    IOC_ClearIntFlag()                                  ' Clear the IOC interrupt flag
    IOC_IntEnable()                                     ' Enable IOC interrupts

    IntGlobal_Enable()                                  ' Enable global interrupts
EndProc

'--------------------------------------------------------------------------
' IOC (Interrupt On Change) Interrupt handler
' Input     : None
' Output    : Variable Enc_wCounter is incremented or decremented depending on the rotation direction
'           : Enc_tTriggered is True if there is a movement on the rotary encoder
'           : Enc_tDir holds 0 if the rotary encoder is travelling anti-clockwise, else holds 1 if travelling clockwise
' Notes     : Uses an IOC (Interrupt On Change) where one of the rotary encoder's pins are connected
'
ISR_IOC(Start)
    If IOC_RB1_IntFlag = True Then                              ' Is it an Interrupt On Change on PORTB.1?
        Enc_tTriggered = True                                   ' Yes. So set the rotation triggered flag
        Enc_bPinStore = %00000000                               ' Clear the variable Enc_bPinStore
        Enc_bPinStore.0 = Enc_Pin1                              ' Place the condition of pin Enc_Pin1 into bit-0 of Enc_bPinStore
        Enc_bPinStore.1 = Enc_Pin2                              ' Place the condition of pin Enc_Pin2 into bit-1 of Enc_bPinStore
        If Enc_bPinStore = %00000000 Then                       ' Is Enc_bPinStore 0?
            Enc_tDir = Enc_cClockwise                           ' Yes. So indicate that it is a clockwise movement
            If Enc_wCounter < 65535 Then                        ' \
                Enc_wCounter = Enc_wCounter + Enc_bIncDecValue  ' | Increment the rotation counter
            EndIf                                               ' /
        Else                                                    ' Otherwise...
            Enc_tDir = Enc_cAntiClockwise                       ' Indicate that it is an anti-clockwise movement
            If Enc_wCounter > 0 Then                            ' \
                Enc_wCounter = Enc_wCounter - Enc_bIncDecValue  ' | Decrement the rotation counter
            EndIf                                               ' /
        EndIf
        IOC_RB1_ClearIntFlag()                                  ' Clear the IOC flag for PORTB.1
    EndIf
ISR_IOC(Exit)

I've also incorporated it into a demo project for an Si4730-D60 radio chip that makes a LW/MW/SW/FM receiver using the Positron board and the rotary encoder to tune it. The Si473x library will be available for the Positron8 compiler as soon as the board and manual are released.
Hello Les,

Where can I find the "Positron Int Manager.inc" file?

Seba

top204

#35
The Positron Int Manager file was going to be part of the Positron8 board's software, but it simply will not be able to compete with the Chinese items, or Microchip products (also made in China), so I have dropped it. :-(

The interrupt manager is only for PIC18F27K42 or PIC18F47K42 devices, and is listed below. It could be easily adapted for other devices, because it is using the SFRs and peripherals available for the device. I did, originally, create one for the Amicus18  device. i.e. PIC18F25K20, and within the Positron compiler's "Samples" folder, inside the Amicus18 folder, there are demos for the original Interrupt Manager. It gives a vectored interrupt type mechanism with full context saving/restoring built in, and is much, much better than the, very poor, hardware interrupt vector mechanism on the newer 18F devices. They simply do not have the RAM or the required hardware to store the contexts for all the individual interrupt vectors, unlike the PIC24 and dsPIC33 devices, which have a true RAM stack and the Positron16 compiler uses that for context storage because it expands and contracts naturally and is used by the microcontroller itself as well.

$ifndef _Positron_Int_Manager_
$define _Positron_Int_Manager_
'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
$if (_device <> _18F27K42) And (_device <> _18F47K42)
    $error "Positron Int Manager is only for 18F27K42 or 18F47K42 devices"
$endif
'
' High priority interrupt manager routines for a PIC18F27K42 device
' Written by Les Johnson for version 4.0.0.0 onwards of the Positron8 compiler
'
' Handler defines available
' Use one, or more, of these defines at the beginning of the main program to tell the Interrupt Manager what interrupts to manage
'
(*
$define Handle_IOC_Int
$define Handle_INT0_Int
$define Handle_INT1_Int
$define Handle_INT2_Int
$define Handle_RX_Int
$define Handle_TX_Int
$define Handle_RX1_Int
$define Handle_TX1_Int
$define Handle_RX2_Int
$define Handle_TX2_Int
$define Handle_SPI_Int
$define Handle_SPI1_Int
$define Handle_I2C_Int
$define Handle_I2C1_Int
$define Handle_I2C2_Int
$define Handle_CCP1_Int
$define Handle_CCP2_Int
$define Handle_CCP3_Int
$define Handle_CCP4_Int
$define Handle_TMR0_Int
$define Handle_TMR1_Int
$define Handle_TMR2_Int
$define Handle_TMR3_Int
$define Handle_TMR4_Int
$define Handle_TMR5_Int
$define Handle_TMR6_Int
$define Handle_ADC_Int
$define Handle_OSC_Int
$define Handle_CMP1_Int
$define Handle_CMP2_Int
$define Handle_NVM_Int
$define Handle_HLVD_Int
$define Handle_TMR1_Gate_Int
$define Handle_TMR3_Gate_Int
$define Handle_TMR5_Gate_Int
$define Handle_TMR2_Match_Int
$define Handle_TMR4_Match_Int
$define Handle_TMR6_Match_Int
$define Handle_CRC_Int
$define Handle_CSW_Int
$define Handle_SMT1PWM_Int
$define Handle_SMT1PRA_Int
$define Handle_SMT1_Int
$define Handle_ZCD_Int
$define Handle_SPI_RX_Int
$define Handle_SPI_TX_Int
$define Handle_SPI1_RX_Int
$define Handle_SPI1_TX_Int
$define Handle_DMA1_ABRT_Int
$define Handle_DMA1_OV_Int
$define Handle_DMA1_DCNT_Int
$define Handle_DMA1_SCNT_Int
$define Handle_DMA2_ABRT_Int
$define Handle_DMA2_OV_Int
$define Handle_DMA2_DCNT_Int
$define Handle_DMA2_SCNT_Int
$define Handle_CLC1_Int
$define Handle_CLC2_Int
$define Handle_CLC3_Int
$define Handle_CLC4_Int
$define Handle_CWG1_Int
$define Handle_CWG2_Int
$define Handle_CWG3_Int
$define Handle_NCO1_Int
*)
'
' Interrupt flag alias names for a PIC18F27K42
'
$define TMR0_IntFlag        PIR3bits_TMR0IF
$define TMR1_IntFlag        PIR4bits_TMR1IF
$define TMR2_IntFlag        PIR4bits_TMR2IF
$define TMR3_IntFlag        PIR6bits_TMR3IF
$define TMR4_IntFlag        PIR7bits_TMR4IF
$define TMR5_IntFlag        PIR8bits_TMR5IF
$define TMR6_IntFlag        PIR9bits_TMR6IF
$define INT0_IntFlag        PIR1bits_INT0IF
$define INT1_IntFlag        PIR5bits_INT1IF
$define INT2_IntFlag        PIR7bits_INT2IF
$define IOC_IntFlag         PIR0bits_IOCIF
$define RX_IntFlag          PIR3bits_U1RXIF
$define TX_IntFlag          PIR3bits_U1TXIF
$define RX1_IntFlag         PIR3bits_U1RXIF
$define TX1_IntFlag         PIR3bits_U1TXIF
$define RX2_IntFlag         PIR6bits_U2RXIF
$define TX2_IntFlag         PIR6bits_U2TXIF
$define SPI_IntFlag         PIR2bits_SPI1IF
$define SPI1_IntFlag        PIR2bits_SPI1IF
$define CCP1_IntFlag        PIR4bits_CCP1IF
$define CCP2_IntFlag        PIR7bits_CCP2IF
$define CCP3_IntFlag        PIR9bits_CCP3IF
$define CCP4_IntFlag        PIR10bits_CCP4IF
$define ADC_IntFlag         PIR1bits_ADIF
$define CMP1_IntFlag        PIR1bits_C1IF
$define CMP2_IntFlag        PIR5bits_C2IF
$define NVM_IntFlag         PIR0bits_NVMIF
$define I2C_IntFlag         PIR3bits_I2C1IF
$define I2C1_IntFlag        PIR3bits_I2C1IF
$define I2C2_IntFlag        PIR6bits_I2C2IF
$define HLVD_IntFlag        PIR0bits_HLVDIF
$define OSC_IntFlag         PIR0bits_OSFIF
$define TMR2_Match_IntFlag  PIR4bits_TMR2IF
$define TMR4_Match_IntFlag  PIR7bits_TMR4IF
$define TMR6_Match_IntFlag  PIR9bits_TMR6IF
$define TMR1_Gate_IntFlag   PIR4bits_TMR1GIF
$define TMR3_Gate_IntFlag   PIR6bits_TMR3GIF
$define TMR5_Gate_IntFlag   PIR8bits_TMR5GIF
$define CRC_IntFlag         PIR0bits_CRCIF
$define CSW_IntFlag         PIR0bits_CSWIF
$define SMT1PWM_IntFlag     PIR1bits_SMT1PWAIF
$define SMT1PRA_IntFlag     PIR1bits_SMT1PRAIF
$define SMT1_IntFlag        PIR1bits_SMT1IF
$define ZCD_IntFlag         PIR1bits_ZCDIF
$define SPI_RX_IntFlag      PIR2bits_SPI1RXIF
$define SPI_TX_IntFlag      PIR2bits_SPI1TXIF
$define SPI1_RX_IntFlag     PIR2bits_SPI1RXIF
$define SPI1_TX_IntFlag     PIR2bits_SPI1TXIF
$define DMA1_ABRT_IntFlag   PIR2bits_DMA1AIF
$define DMA1_OV_IntFlag     PIR2bits_DMA1ORIF
$define DMA1_DCNT_IntFlag   PIR2bits_DMA1DCNTIF
$define DMA1_SCNT_IntFlag   PIR2bits_DMA1SCNTIF
$define CLC1_IntFlag        PIR4bits_CLC1IF
$define CWG1_IntFlag        PIR4bits_CWG1IF
$define NCO1_IntFlag        PIR4bits_NCO1IF
$define DMA2_ABRT_IntFlag   PIR5bits_DMA2AIF
$define DMA2_OV_IntFlag     PIR5bits_DMA2ORIF
$define DMA2_DCNT_IntFlag   PIR5bits_DMA2DCNTIF
$define DMA2_SCNT_IntFlag   PIR5bits_DMA2SCNTIF
$define CLC2_IntFlag        PIR7bits_CLC2IF
$define CWG2_IntFlag        PIR7bits_CWG2IF
$define CLC3_IntFlag        PIR9bits_CLC3IF
$define CWG3_IntFlag        PIR9bits_CWG3IF
$define CLC4_IntFlag        PIR10bits_CLC4IF
'
' Clear the Interrupt flags
'
$define TMR0_ClearIntFlag()        TMR0_IntFlag = 0
$define TMR1_ClearIntFlag()        TMR1_IntFlag = 0
$define TMR2_ClearIntFlag()        TMR2_IntFlag = 0
$define TMR3_ClearIntFlag()        TMR3_IntFlag = 0
$define TMR4_ClearIntFlag()        TMR4_IntFlag = 0
$define TMR5_ClearIntFlag()        TMR5_IntFlag = 0
$define TMR6_ClearIntFlag()        TMR6_IntFlag = 0
$define INT0_ClearIntFlag()        INT0_IntFlag = 0
$define INT1_ClearIntFlag()        INT1_IntFlag = 0
$define INT2_ClearIntFlag()        INT2_IntFlag = 0
$define IOC_ClearIntFlag()         IOC_IntFlag = 0
$define RX_ClearIntFlag()          RX_IntFlag = 0
$define TX_ClearIntFlag()          TX_IntFlag = 0
$define RX1_ClearIntFlag()         RX1_IntFlag = 0
$define TX1_ClearIntFlag()         TX1_IntFlag = 0
$define RX2_ClearIntFlag()         RX2_IntFlag = 0
$define TX2_ClearIntFlag()         TX2_IntFlag = 0
$define SPI_ClearIntFlag()         SPI_IntFlag = 0
$define SPI1_ClearIntFlag()        SPI1_IntFlag = 0
$define CCP1_ClearIntFlag()        CCP1_IntFlag = 0
$define CCP2_ClearIntFlag()        CCP2_IntFlag = 0
$define CCP3_ClearIntFlag()        CCP3_IntFlag = 0
$define CCP4_ClearIntFlag()        CCP4_IntFlag = 0
$define ADC_ClearIntFlag()         ADC_IntFlag = 0
$define CMP1_ClearIntFlag()        CMP1_IntFlag = 0
$define CMP2_ClearIntFlag()        CMP2_IntFlag = 0
$define NVM_ClearIntFlag()         NVM_IntFlag = 0
$define I2C_ClearIntFlag()         I2C_IntFlag = 0
$define I2C1_ClearIntFlag()        I2C1_IntFlag = 0
$define I2C2_ClearIntFlag()        I2C2_IntFlag = 0
$define HLVD_ClearIntFlag()        HLVD_IntFlag = 0
$define OSC_ClearIntFlag()         OSC_IntFlag = 0
$define TMR2_Match_ClearIntFlag()  TMR2_Match_IntFlag = 0
$define TMR4_Match_ClearIntFlag()  TMR4_Match_IntFlag = 0
$define TMR6_Match_ClearIntFlag()  TMR6_Match_IntFlag = 0
$define TMR1_Gate_ClearIntFlag()   TMR1_Gate_IntFlag = 0
$define TMR3_Gate_ClearIntFlag()   TMR3_Gate_IntFlag = 0
$define TMR5_Gate_ClearIntFlag()   TMR5_Gate_IntFlag = 0
$define CRC_ClearIntFlag()         CRC_IntFlag = 0
$define CSW_ClearIntFlag()         CSW_IntFlag = 0
$define SMT1PWM_ClearIntFlag()     SMT1PWM_IntFlag = 0
$define SMT1PRA_ClearIntFlag()     SMT1PRA_IntFlag = 0
$define SMT1_ClearIntFlag()        SMT1_IntFlag = 0
$define ZCD_ClearIntFlag()         ZCD_IntFlag = 0
$define SPI_RX_ClearIntFlag()      SPI_RX_IntFlag = 0
$define SPI_TX_ClearIntFlag()      SPI_TX_IntFlag = 0
$define SPI1_RX_ClearIntFlag()     SPI1_RX_IntFlag = 0
$define SPI1_TX_ClearIntFlag()     SPI1_TX_IntFlag = 0
$define DMA1_ABRT_ClearIntFlag()   DMA1_ABRT_IntFlag = 0
$define DMA1_OV_ClearIntFlag()     DMA1_OV_IntFlag = 0
$define DMA1_DCNT_ClearIntFlag()   DMA1_DCNT_IntFlag = 0
$define DMA1_SCNT_ClearIntFlag()   DMA1_SCNT_IntFlag = 0
$define CLC1_ClearIntFlag()        CLC1_IntFlag = 0
$define CWG1_ClearIntFlag()        CWG1_IntFlag = 0
$define NCO1_ClearIntFlag()        NCO1_IntFlag = 0
$define DMA2_ABRT_ClearIntFlag()   DMA2_ABRT_IntFlag = 0
$define DMA2_OV_ClearIntFlag()     DMA2_OV_IntFlag = 0
$define DMA2_DCNT_ClearIntFlag()   DMA2_DCNT_IntFlag = 0
$define DMA2_SCNT_ClearIntFlag()   DMA2_SCNT_IntFlag = 0
$define CLC2_ClearIntFlag()        CLC2_IntFlag = 0
$define CWG2_ClearIntFlag()        CWG2_IntFlag = 0
$define CLC3_ClearIntFlag()        CLC3_IntFlag = 0
$define CWG3_ClearIntFlag()        CWG3_IntFlag = 0
$define CLC4_ClearIntFlag()        CLC4_IntFlag = 0
'
' Interrupt On Change flags per Port.Pin
'
$define IOC_RA0_IntFlag     IOCAF.0
$define IOC_RA1_IntFlag     IOCAF.1
$define IOC_RA2_IntFlag     IOCAF.2
$define IOC_RA3_IntFlag     IOCAF.3
$define IOC_RA4_IntFlag     IOCAF.4
$define IOC_RA5_IntFlag     IOCAF.5
$define IOC_RA6_IntFlag     IOCAF.6
$define IOC_RA7_IntFlag     IOCAF.7
$define IOC_RB0_IntFlag     IOCBF.0
$define IOC_RB1_IntFlag     IOCBF.1
$define IOC_RB2_IntFlag     IOCBF.2
$define IOC_RB3_IntFlag     IOCBF.3
$define IOC_RB4_IntFlag     IOCBF.4
$define IOC_RB5_IntFlag     IOCBF.5
$define IOC_RB6_IntFlag     IOCBF.6
$define IOC_RB7_IntFlag     IOCBF.7
$define IOC_RC0_IntFlag     IOCCF.0
$define IOC_RC1_IntFlag     IOCCF.1
$define IOC_RC2_IntFlag     IOCCF.2
$define IOC_RC3_IntFlag     IOCCF.3
$define IOC_RC4_IntFlag     IOCCF.4
$define IOC_RC5_IntFlag     IOCCF.5
$define IOC_RC6_IntFlag     IOCCF.6
$define IOC_RC7_IntFlag     IOCCF.7
'
' Clear the IOC interrupt flags per Port.Pin
'
$define IOC_RA0_ClearIntFlag()     IOCAF.0 = 0
$define IOC_RA1_ClearIntFlag()     IOCAF.1 = 0
$define IOC_RA2_ClearIntFlag()     IOCAF.2 = 0
$define IOC_RA3_ClearIntFlag()     IOCAF.3 = 0
$define IOC_RA4_ClearIntFlag()     IOCAF.4 = 0
$define IOC_RA5_ClearIntFlag()     IOCAF.5 = 0
$define IOC_RA6_ClearIntFlag()     IOCAF.6 = 0
$define IOC_RA7_ClearIntFlag()     IOCAF.7 = 0
$define IOC_RB0_ClearIntFlag()     IOCBF.0 = 0
$define IOC_RB1_ClearIntFlag()     IOCBF.1 = 0
$define IOC_RB2_ClearIntFlag()     IOCBF.2 = 0
$define IOC_RB3_ClearIntFlag()     IOCBF.3 = 0
$define IOC_RB4_ClearIntFlag()     IOCBF.4 = 0
$define IOC_RB5_ClearIntFlag()     IOCBF.5 = 0
$define IOC_RB6_ClearIntFlag()     IOCBF.6 = 0
$define IOC_RB7_ClearIntFlag()     IOCBF.7 = 0
$define IOC_RC0_ClearIntFlag()     IOCCF.0 = 0
$define IOC_RC1_ClearIntFlag()     IOCCF.1 = 0
$define IOC_RC2_ClearIntFlag()     IOCCF.2 = 0
$define IOC_RC3_ClearIntFlag()     IOCCF.3 = 0
$define IOC_RC4_ClearIntFlag()     IOCCF.4 = 0
$define IOC_RC5_ClearIntFlag()     IOCCF.5 = 0
$define IOC_RC6_ClearIntFlag()     IOCCF.6 = 0
$define IOC_RC7_ClearIntFlag()     IOCCF.7 = 0
'
' Enable Interrupts
'
$define IntGlobal_Enable()      INTCON0bits_GIE = 1
$define IntPeriph_Enable()      INTCON0bits_GIEL = 1
$define Global_IntEnable()      INTCON0bits_GIE = 1
$define Periph_IntEnable()      INTCON0bits_GIEL = 1
$define TMR0_IntEnable()        PIE3bits_TMR0IE = 1
$define TMR1_IntEnable()        PIE4bits_TMR1IE = 1
$define TMR2_IntEnable()        PIE4bits_TMR2IE = 1
$define TMR3_IntEnable()        PIE6bits_TMR3IE = 1
$define TMR4_IntEnable()        PIE7bits_TMR4IE = 1
$define TMR5_IntEnable()        PIE8bits_TMR5IE = 1
$define TMR6_IntEnable()        PIE9bits_TMR6IE = 1
$define INT0_IntEnable()        PIE1bits_INT0IE = 1
$define INT1_IntEnable()        PIE5bits_INT1IE = 1
$define INT2_IntEnable()        PIE7bits_INT2IE = 1
$define IOC_IntEnable()         PIE0bits_IOCIE = 1
$define RX_IntEnable()          PIE3bits_U1RXIE = 1
$define TX_IntEnable()          PIE3bits_U1TXIE = 1
$define RX1_IntEnable()         PIE3bits_U1RXIE = 1
$define TX1_IntEnable()         PIE3bits_U1TXIE = 1
$define RX2_IntEnable()         PIE6bits_U2RXIE = 1
$define TX2_IntEnable()         PIE6bits_U2TXIE = 1
$define SPI_IntEnable()         PIE2bits_SPI1IE = 1
$define SPI1_IntEnable()        PIE2bits_SPI1IE = 1
$define CCP1_IntEnable()        PIE4bits_CCP1IE = 1
$define CCP2_IntEnable()        PIE7bits_CCP2IE = 1
$define CCP3_IntEnable()        PIE9bits_CCP3IE = 1
$define CCP4_IntEnable()        PIE10bits_CCP4IE = 1
$define ADC_IntEnable()         PIE1bits_ADIE = 1
$define CMP1_IntEnable()        PIE1bits_C1IE = 1
$define CMP2_IntEnable()        PIE5bits_C2IE = 1
$define NVM_IntEnable()         PIE0bits_NVMIE = 1
$define I2C_IntEnable()         PIE2bits_I2C1RXIE = 1
$define I2C1_IntEnable()        PIE2bits_I2C1RXIE = 1
$define I2C2_IntEnable()        PIE6bits_I2C2IE = 1
$define HLVD_IntEnable()        PIE0bits_HLVDIE = 1
$define OSC_IntEnable()         PIE0bits_OSFIE = 1
$define TMR1_Gate_IntEnable()   PIE4bits_TMR1GIE = 1
$define TMR3_Gate_IntEnable()   PIE6bits_TMR3GIE = 1
$define TMR5_Gate_IntEnable()   PIE8bits_TMR5GIE = 1
$define TMR2_Match_IntEnable()  PIE4bits_TMR2IE = 1
$define TMR4_Match_IntEnable()  PIE7bits_TMR4IE = 1
$define TMR6_Match_IntEnable()  PIE9bits_TMR6IE = 1
$define ZCD_IntEnable()         PIE1bits_ZCDIE = 1
$define SPI_RX_IntEnable()      PIE2bits_SPI1RXIE = 1
$define SPI_TX_IntEnable()      PIE2bits_SPI1TXIE = 1
$define SPI1_RX_IntEnable()     PIE2bits_SPI1RXIE = 1
$define SPI1_TX_IntEnable()     PIE2bits_SPI1TXIE = 1
$define DMA1_ABRT_IntEnable()   PIE2bits_DMA1AIE = 1
$define DMA1_OV_IntEnable()     PIE2bits_DMA1ORIE = 1
$define DMA1_DCNT_IntEnable()   PIE2bits_DMA1DCNTIE = 1
$define DMA1_SCNT_IntEnable()   PIE2bits_DMA1SCNTIE = 1
$define DMA2_ABRT_IntEnable()   PIE5bits_DMA2AIE = 1
$define DMA2_OV_IntEnable()     PIE5bits_DMA2ORIE = 1
$define DMA2_DCNT_IntEnable()   PIE5bits_DMA2DCNTIE = 1
$define DMA2_SCNT_IntEnable()   PIE5bits_DMA2SCNTIE = 1
$define CLC1_IntEnable()        PIE4bits_CLC1IE = 1
$define CLC2_IntEnable()        PIE7bits_CLC2IE = 1
$define CLC3_IntEnable()        PIE9bits_CLC3IE = 1
$define CLC4_IntEnable()        PIE10bits_CLC4IE = 1
$define CWG1_IntEnable()        PIE4bits_CWG1IE = 1
$define CWG2_IntEnable()        PIE7bits_CWG2IE = 1
$define CWG3_IntEnable()        PIE9bits_CWG3IE = 1
$define NCO1_IntEnable()        PIE4bits_NCO1IE = 1
$define CRC_IntEnable()         PIE0bits_CRCIE = 1
$define CSW_IntEnable()         PIE0bits_CSWIE = 1
$define SMT1PWM_IntEnable()     PIE1bits_SMT1PWAIE = 1
$define SMT1PRA_IntEnable()     PIE1bits_SMT1PRAIE = 1
$define SMT1_IntEnable()        PIE1bits_SMT1IE = 1
'
' Disable Interrupts
'
$define IntGlobal_Disable()      INTCON0bits_GIE = 0
$define IntPeriph_Disable()      INTCON0bits_GIEL = 0
$define Global_IntDisable()      INTCON0bits_GIE = 0
$define Periph_IntDisable()      INTCON0bits_GIEL = 0
$define TMR0_IntDisable()        PIE3bits_TMR0IE = 0
$define TMR1_IntDisable()        PIE4bits_TMR1IE = 0
$define TMR2_IntDisable()        PIE4bits_TMR2IE = 0
$define TMR3_IntDisable()        PIE6bits_TMR3IE = 0
$define TMR4_IntDisable()        PIE7bits_TMR4IE = 0
$define TMR5_IntDisable()        PIE8bits_TMR5IE = 0
$define TMR6_IntDisable()        PIE9bits_TMR6IE = 0
$define INT0_IntDisable()        PIE1bits_INT0IE = 0
$define INT1_IntDisable()        PIE5bits_INT1IE = 0
$define INT2_IntDisable()        PIE7bits_INT2IE = 0
$define IOC_IntDisable()         PIE0bits_IOCIE = 0
$define RX_IntDisable()          PIE3bits_U1RXIE = 0
$define TX_IntDisable()          PIE3bits_U1TXIE = 0
$define RX1_IntDisable()         PIE3bits_U1RXIE = 0
$define TX1_IntDisable()         PIE3bits_U1TXIE = 0
$define RX2_IntDisable()         PIE6bits_U2RXIE = 0
$define TX2_IntDisable()         PIE6bits_U2TXIE = 0
$define SPI_IntDisable()         PIE2bits_SPI1IE = 0
$define SPI1_IntDisable()        PIE2bits_SPI1IE = 0
$define CCP1_IntDisable()        PIE4bits_CCP1IE = 0
$define CCP2_IntDisable()        PIE7bits_CCP2IE = 0
$define CCP3_IntDisable()        PIE9bits_CCP3IE = 0
$define CCP4_IntDisable()        PIE10bits_CCP4IE = 0
$define ADC_IntDisable()         PIE1bits_ADIE = 0
$define CMP1_IntDisable()        PIE1bits_C1IE = 0
$define CMP2_IntDisable()        PIE5bits_C2IE = 0
$define NVM_IntDisable()         PIE0bits_NVMIE = 0
$define I2C_IntDisable()         PIE2bits_I2C1RXIE = 0
$define I2C1_IntDisable()        PIE2bits_I2C1RXIE = 0
$define I2C2_IntDisable()        PIE6bits_I2C2IE = 0
$define HLVD_IntDisable()        PIE0bits_HLVDIE = 0
$define OSC_IntDisable()         PIE0bits_OSFIE = 0
$define TMR1_Gate_IntDisable()   PIE4bits_TMR1GIE = 0
$define TMR3_Gate_IntDisable()   PIE6bits_TMR3GIE = 0
$define TMR5_Gate_IntDisable()   PIE8bits_TMR5GIE = 0
$define TMR2_Match_IntDisable()  PIE4bits_TMR2IE = 0
$define TMR4_Match_IntDisable()  PIE7bits_TMR4IE = 0
$define TMR6_Match_IntDisable()  PIE9bits_TMR6IE = 0
$define ZCD_IntDisable()         PIE1bits_ZCDIE = 0
$define SPI_RX_IntDisable()      PIE2bits_SPI1RXIE = 0
$define SPI_TX_IntDisable()      PIE2bits_SPI1TXIE = 0
$define SPI1_RX_IntDisable()     PIE2bits_SPI1RXIE = 0
$define SPI1_TX_IntDisable()     PIE2bits_SPI1TXIE = 0
$define DMA1_ABRT_IntDisable()   PIE2bits_DMA1AIE = 0
$define DMA1_OV_IntDisable()     PIE2bits_DMA1ORIE = 0
$define DMA1_DCNT_IntDisable()   PIE2bits_DMA1DCNTIE = 0
$define DMA1_SCNT_IntDisable()   PIE2bits_DMA1SCNTIE = 0
$define DMA2_ABRT_IntDisable()   PIE5bits_DMA2AIE = 0
$define DMA2_OV_IntDisable()     PIE5bits_DMA2ORIE = 0
$define DMA2_DCNT_IntDisable()   PIE5bits_DMA2DCNTIE = 0
$define DMA2_SCNT_IntDisable()   PIE5bits_DMA2SCNTIE = 0
$define CLC1_IntDisable()        PIE4bits_CLC1IE = 0
$define CLC2_IntDisable()        PIE7bits_CLC2IE = 0
$define CLC3_IntDisable()        PIE9bits_CLC3IE = 0
$define CLC4_IntDisable()        PIE10bits_CLC4IE = 0
$define CWG1_IntDisable()        PIE4bits_CWG1IE = 0
$define CWG2_IntDisable()        PIE7bits_CWG2IE = 0
$define CWG3_IntDisable()        PIE9bits_CWG3IE = 0
$define NCO1_IntDisable()        PIE4bits_NCO1IE = 0
$define CRC_IntDisable()         PIE0bits_CRCIE = 0
$define CSW_IntDisable()         PIE0bits_CSWIE = 0
$define SMT1PWM_IntDisable()     PIE1bits_SMT1PWAIE = 0
$define SMT1PRA_IntDisable()     PIE1bits_SMT1PRAIE = 0
$define SMT1_IntDisable()        PIE1bits_SMT1IE = 0
'------------------------------------------------------------------
' INT0
'
$define INT0_Edge_Rising()  Set INTCON0bits_INT0EDG     ' Interrupt on a rising edge on the INT0 pin
$define INT0_Edge_Falling() Clear INTCON0bits_INT0EDG   ' Interrupt on a falling edge on the INT0 pin

'------------------------------------------------------------------
' INT1
'
$define INT1_Edge_Rising()  Set INTCON0bits_INT1EDG     ' Interrupt on a rising edge on the INT1 pin
$define INT1_Edge_Falling() Clear INTCON0bits_INT1EDG   ' Interrupt on a falling edge on the INT1 pin

'------------------------------------------------------------------
' INT2
'
$define INT2_Edge_Rising()  Set INTCON0bits_INT2EDG     ' Interrupt on a rising edge on the INT2 pin
$define INT2_Edge_Falling() Clear INTCON0bits_INT2EDG   ' Interrupt on a falling edge on the INT2 pin

'------------------------------------------------------------------
' PORTA.0 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA0_Rising()  '
    IOCAN.0 = 0           '
    IOCAP.0 = 1

$define IOC_RA0_Falling() '
    IOCAN.0 = 1           '
    IOCAP.0 = 0

'------------------------------------------------------------------
' PORTA.1 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA1_Rising()  '
    IOCAN.1 = 0           '
    IOCAP.1 = 1

$define IOC_RA1_Falling() '
    IOCAN.1 = 1           '
    IOCAP.1 = 0

'------------------------------------------------------------------
' PORTA.2 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA2_Rising()  '
    IOCAN.2 = 0           '
    IOCAP.2 = 1

$define IOC_RA2_Falling() '
    IOCAN.2 = 1           '
    IOCAP.2 = 0

'------------------------------------------------------------------
' PORTA.3 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA3_Rising()  '
    IOCAN.3 = 0           '
    IOCAP.3 = 1

$define IOC_RA3_Falling() '
    IOCAN.3 = 1           '
    IOCAP.3 = 0

'------------------------------------------------------------------
' PORTA.4 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA4_Rising()  '
    IOCAN.4 = 0           '
    IOCAP.4 = 1

$define IOC_RA4_Falling() '
    IOCAN.4 = 1           '
    IOCAP.4 = 0

'------------------------------------------------------------------
' PORTA.5 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA5_Rising()  '
    IOCAN.5 = 0           '
    IOCAP.5 = 1

$define IOC_RA5_Falling() '
    IOCAN.5 = 1           '
    IOCAP.5 = 0

'------------------------------------------------------------------
' PORTA.6 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA6_Rising()  '
    IOCAN.6 = 0           '
    IOCAP.6 = 1

$define IOC_RA6_Falling() '
    IOCAN.6 = 1           '
    IOCAP.6 = 0

'------------------------------------------------------------------
' PORTA.7 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RA7_Rising()  '
    IOCAN.7 = 0           '
    IOCAP.7 = 1

$define IOC_RA7_Falling() '
    IOCAN.7 = 1           '
    IOCAP.7 = 0

'------------------------------------------------------------------
' PORTB.0 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB0_Rising()  '
    IOCBN.0 = 0           '
    IOCBP.0 = 1

$define IOC_RB0_Falling() '
    IOCBN.0 = 1           '
    IOCBP.0 = 0

'------------------------------------------------------------------
' PORTB.1 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB1_Rising()  '
    IOCBN.1 = 0           '
    IOCBP.1 = 1

$define IOC_RB1_Falling() '
    IOCBN.1 = 1           '
    IOCBP.1 = 0

'------------------------------------------------------------------
' PORTB.2 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB2_Rising()  '
    IOCBN.2 = 0           '
    IOCBP.2 = 1

$define IOC_RB2_Falling() '
    IOCBN.2 = 1           '
    IOCBP.2 = 0

'------------------------------------------------------------------
' PORTB.3 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB3_Rising()  '
    IOCBN.3 = 0           '
    IOCBP.3 = 1

$define IOC_RB3_Falling() '
    IOCBN.3 = 1           '
    IOCBP.3 = 0

'------------------------------------------------------------------
' PORTB.4 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB4_Rising()  '
    IOCBN.4 = 0           '
    IOCBP.4 = 1

$define IOC_RB4_Falling() '
    IOCBN.4 = 1           '
    IOCBP.4 = 0

'------------------------------------------------------------------
' PORTB.5 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB5_Rising()  '
    IOCBN.5 = 0           '
    IOCBP.5 = 1

$define IOC_RB5_Falling() '
    IOCBN.5 = 1           '
    IOCBP.5 = 0

'------------------------------------------------------------------
' PORTB.6 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB6_Rising()  '
    IOCBN.6 = 0           '
    IOCBP.6 = 1

$define IOC_RB6_Falling() '
    IOCBN.6 = 1           '
    IOCBP.6 = 0

'------------------------------------------------------------------
' PORTB.7 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RB7_Rising()  '
    IOCBN.7 = 0           '
    IOCBP.7 = 1

$define IOC_RB7_Falling() '
    IOCBN.7 = 1           '
    IOCBP.7 = 0

'------------------------------------------------------------------
' PORTC.0 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC0_Rising()  '
    IOCCN.0 = 0           '
    IOCCP.0 = 1

$define IOC_RC0_Falling() '
    IOCCN.0 = 1           '
    IOCCP.0 = 0

'------------------------------------------------------------------
' PORTC.1 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC1_Rising()  '
    IOCCN.1 = 0           '
    IOCCP.1 = 1

$define IOC_RC1_Falling() '
    IOCCN.1 = 1           '
    IOCCP.1 = 0

'------------------------------------------------------------------
' PORTC.2 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC2_Rising()  '
    IOCCN.2 = 0           '
    IOCCP.2 = 1

$define IOC_RC2_Falling() '
    IOCCN.2 = 1           '
    IOCCP.2 = 0

'------------------------------------------------------------------
' PORTC.3 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC3_Rising()  '
    IOCCN.3 = 0           '
    IOCCP.3 = 1

$define IOC_RC3_Falling() '
    IOCCN.3 = 1           '
    IOCCP.3 = 0

'------------------------------------------------------------------
' PORTC.4 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC4_Rising()  '
    IOCCN.4 = 0           '
    IOCCP.4 = 1

$define IOC_RC4_Falling() '
    IOCCN.4 = 1           '
    IOCCP.4 = 0

'------------------------------------------------------------------
' PORTC.5 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC5_Rising()  '
    IOCCN.5 = 0           '
    IOCCP.5 = 1

$define IOC_RC5_Falling() '
    IOCCN.5 = 1           '
    IOCCP.5 = 0

'------------------------------------------------------------------
' PORTC.6 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC6_Rising()  '
    IOCCN.6 = 0           '
    IOCCP.6 = 1

$define IOC_RC6_Falling() '
    IOCCN.6 = 1           '
    IOCCP.6 = 0

'------------------------------------------------------------------
' PORTC.7 IOC (Interrupt On Change) Edge Detection
'
$define IOC_RC7_Rising()  '
    IOCCN.7 = 0           '
    IOCCP.7 = 1

$define IOC_RC7_Falling() '
    IOCCN.7 = 1           '
    IOCCP.7 = 0

'------------------------------------------------------------------
' PORTA.0 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA0_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA0_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA0_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.1 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA1_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA1_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA1_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.2 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA2_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA2_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA2_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.3 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA3_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA3_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA3_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.4 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA4_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA4_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA4_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.5 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA5_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA5_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA5_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.6 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA6_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA6_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA6_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTA.7 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RA7_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RA7_Rising()            '
    $elseif pParam = Falling        '
        IOC_RA7_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.0 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB0_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB0_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB0_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.1 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB1_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB1_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB1_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.2 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB2_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB2_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB2_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.3 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB3_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB3_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB3_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.4 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB4_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB4_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB4_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.5 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB5_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB5_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB5_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.6 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB6_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB6_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB6_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTB.7 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RB7_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RB7_Rising()            '
    $elseif pParam = Falling        '
        IOC_RB7_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.0 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC0_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC0_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC0_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.1 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC1_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC1_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC1_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.2 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC2_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC2_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC2_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.3 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC3_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC3_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC3_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.4 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC4_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC4_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC4_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.5 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC5_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC5_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC5_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.6 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC6_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC6_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC6_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' PORTC.7 IOC (Interrupt On Change) Edge Detection
' Input     : pParam must be the texts "Rising" or "Falling" for the edge detection
'
$define IOC_RC7_Edge(pParam)        '
    $if pParam = Rising             '
        IOC_RC7_Rising()            '
    $elseif pParam = Falling        '
        IOC_RC7_Falling()           '
    $else                           '
        $error "Unrecognised parameter. Rising or Falling only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable global interrupts
'
$define Int_Global(pParam) '
    $if pParam = Enable         '
        IntGlobal_Enable()      '
    $elseif pParam = Disable    '
        IntGlobal_Disable()     '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable peripheral interrupts
'
$define Int_Peripheral(pParam)      '
    $if pParam = Enable             '
        IntPeriph_Enable()          '
    $elseif pParam = Disable        '
        IntPeriph_Disable()         '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer0 interrupt
'
$define Int_TMR0(pParam)        '
    $if pParam = Enable         '
        TMR0_IntEnable()        '
    $elseif pParam = Disable    '
        TMR0_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer1 interrupt
'
$define Int_TMR1(pParam)        '
    $if pParam = Enable         '
        TMR1_IntEnable()        '
    $elseif pParam = Disable    '
        TMR1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer2 interrupt
'
$define Int_TMR2(pParam)        '
    $if pParam = Enable         '
        TMR2_IntEnable()        '
    $elseif pParam = Disable    '
        TMR2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer3 interrupt
'
$define Int_TMR3(pParam)        '
    $if pParam = Enable         '
        TMR3_IntEnable()        '
    $elseif pParam = Disable    '
        TMR3_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer4 interrupt
'
$define Int_TMR4(pParam)        '
    $if pParam = Enable         '
        TMR4_IntEnable()        '
    $elseif pParam = Disable    '
        TMR4_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer5 interrupt
'
$define Int_TMR5(pParam)        '
    $if pParam = Enable         '
        TMR5_IntEnable()        '
    $elseif pParam = Disable    '
        TMR5_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer6 interrupt
'
$define Int_TMR6(pParam)        '
    $if pParam = Enable         '
        TMR6_IntEnable()        '
    $elseif pParam = Disable    '
        TMR6_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an INT0 interrupt
'
$define Int_INT0(pParam)        '
    $if pParam = Enable         '
        INT0_IntEnable()        '
    $elseif pParam = Disable    '
        INT0_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an INT1 interrupt
'
$define Int_INT1(pParam)        '
    $if pParam = Enable         '
        INT1_IntEnable()        '
    $elseif pParam = Disable    '
        INT1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an INT2 interrupt
'
$define Int_INT2(pParam)        '
    $if pParam = Enable         '
        INT2_IntEnable()        '
    $elseif pParam = Disable    '
        INT2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CCP1 interrupt
'
$define Int_CCP1(pParam)        '
    $if pParam = Enable         '
        CCP1_IntEnable()        '
    $elseif pParam = Disable    '
        CCP1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CCP2 interrupt
'
$define Int_CCP2(pParam)        '
    $if pParam = Enable         '
        CCP2_IntEnable()        '
    $elseif pParam = Disable    '
        CCP2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CCP3 interrupt
'
$define Int_CCP3(pParam)        '
    $if pParam = Enable         '
        CCP3_IntEnable()        '
    $elseif pParam = Disable    '
        CCP3_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CCP4 interrupt
'
$define Int_CCP4(pParam)        '
    $if pParam = Enable         '
        CCP4_IntEnable()        '
    $elseif pParam = Disable    '
        CCP4_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an IOC interrupt
'
$define Int_IOC(pParam)         '
    $if pParam = Enable         '
        IOC_IntEnable()         '
    $elseif pParam = Disable    '
        IOC_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an ADC interrupt
'
$define Int_ADC(pParam)         '
    $if pParam = Enable         '
        ADC_IntEnable()         '
    $elseif pParam = Disable    '
        ADC_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif
'------------------------------------------------------------------
' Enable\Disable a UART1 receive interrupt
'
$define Int_RX1(pParam)         '
    $if pParam = Enable         '
        RX1_IntEnable()         '
    $elseif pParam = Disable    '
        RX1_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

$define Int_RX1(pParam) Int_RX1(pParam)
'------------------------------------------------------------------
' Enable\Disable a UART1 transmit interrupt
'
$define Int_TX1(pParam)         '
    $if pParam = Enable         '
        TX1_IntEnable()         '
    $elseif pParam = Disable    '
        TX1_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a UART2 receive interrupt
'
$define Int_RX2(pParam)         '
    $if pParam = Enable         '
        RX2_IntEnable()         '
    $elseif pParam = Disable    '
        RX2_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a UART2 transmit interrupt
'
$define Int_TX2(pParam)         '
    $if pParam = Enable         '
        RX2_IntEnable()         '
    $elseif pParam = Disable    '
        RX2_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

$define Int_TX1(pParam) Int_TX1(pParam)
'------------------------------------------------------------------
' Enable\Disable an SPI1 interrupt
'
$define Int_SPI1(pParam)        '
    $if pParam = Enable         '
        SPI1_IntEnable()        '
    $elseif pParam = Disable    '
        SPI1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

$define Int_SPI(pParam) Int_SPI1(pParam)
'------------------------------------------------------------------
' Enable\Disable an Oscillator Fail interrupt
'
$define Int_OSC(pParam)         '
    $if pParam = Enable         '
        OSC_IntEnable()         '
    $elseif pParam = Disable    '
        OSC_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Comparator 1 interrupt
'
$define Int_CMP1(pParam)        '
    $if pParam = Enable         '
        CMP1_IntEnable()        '
    $elseif pParam = Disable    '
        CMP1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Comparator 2 interrupt
'
$define Int_CMP2(pParam)        '
    $if pParam = Enable         '
        IntEnable_Comp2()       '
    $elseif pParam = Disable    '
        IntDisable_Comp2()      '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an EEPROM and Flash Write interrupt
'
$define Int_Flash(pParam)       '
    $if pParam = Enable         '
        NVM_IntEnable()         '
    $elseif pParam = Disable    '
        NVM_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an MSPI1 Bus collision interrupt
'
$define Int_I2C(pParam)         '
    $if pParam = Enable         '
        I2C_IntEnable()         '
    $elseif pParam = Disable    '
        I2C_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

$define Int_I2C1(pParam) Int_I2C(pParam)
'------------------------------------------------------------------
' Enable\Disable a Low Voltage interrupt
'
$define Int_HLVD(pParam)        '
    $if pParam = Enable         '
        HLVD_IntEnable()        '
    $elseif pParam = Disable    '
        HLVD_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an I2C2 Bus collision interrupt
'
$define Int_I2C2(pParam)        '
    $if pParam = Enable         '
        I2C2_IntEnable()        '
    $elseif pParam = Disable    '
        I2C2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer2 to PR2 match interrupt
'
$define Int_TMR2_Match(pParam)      '
    $if pParam = Enable             '
        TMR2_Match_IntEnable()      '
    $elseif pParam = Disable        '
        TMR2_Match_IntDisable()     '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer4 to PR4 match interrupt
'
$define Int_TMR4_Match(pParam)      '
    $if pParam = Enable             '
        TMR4_Match_IntEnable()      '
    $elseif pParam = Disable        '
        TMR4_Match_IntDisable()     '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer6 to PR6 match interrupt
'
$define Int_TMR6_Match(pParam)      '
    $if pParam = Enable             '
        TMR6_Match_IntEnable()      '
    $elseif pParam = Disable        '
        TMR6_Match_IntDisable()     '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer1 Gate interrupt
'
$define Int_TMR1_Gate(pParam)       '
    $if pParam = Enable             '
        TMR1_Gate_IntEnable()       '
    $elseif pParam = Disable        '
        TMR1_Gate_IntDisable()      '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer3 Gate interrupt
'
$define Int_TMR3_Gate(pParam)       '
    $if pParam = Enable             '
        TMR3_Gate_IntEnable()       '
    $elseif pParam = Disable        '
        TMR3_Gate_IntDisable()      '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a Timer5 Gate interrupt
'
$define Int_TMR5_Gate(pParam)       '
    $if pParam = Enable             '
        TMR5_Gate_IntEnable()       '
    $elseif pParam = Disable        '
        TMR5_Gate_IntDisable()      '
    $else                           '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a ZCD interrupt
'
$define Int_ZCD(pParam)         '
    $if pParam = Enable         '
        ZCD_IntEnable()         '
    $elseif pParam = Disable    '
        ZCD_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an SPI1 RX interrupt
'
$define Int_SPI1_RX(pParam)     '
    $if pParam = Enable         '
        SPI1_RX_IntEnable()     '
    $elseif pParam = Disable    '
        SPI1_RX_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an SPI1 TX interrupt
'
$define Int_SPI1_TX(pParam)     '
    $if pParam = Enable         '
        SPI1_TX_IntEnable()     '
    $elseif pParam = Disable    '
        SPI1_TX_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA1 Abort interrupt
'
$define Int_DMA1_ABRT(pParam)   '
    $if pParam = Enable         '
        DMA1_ABRT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA1_ABRT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA1 Over-Run interrupt
'
$define Int_DMA1_OV(pParam)     '
    $if pParam = Enable         '
        DMA1_OV_IntEnable()     '
    $elseif pParam = Disable    '
        DMA1_OV_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA1 Destination Count interrupt
'
$define Int_DMA1_DCNT(pParam)   '
    $if pParam = Enable         '
        DMA1_DCNT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA1_DCNT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA1 Source Count interrupt
'
$define Int_DMA1_SCNT(pParam)   '
    $if pParam = Enable         '
        DMA1_SCNT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA1_SCNT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA2 Abort interrupt
'
$define Int_DMA2_ABRT(pParam)   '
    $if pParam = Enable         '
        DMA2_ABRT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA2_ABRT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA2 Over-Run interrupt
'
$define Int_DMA2_OV(pParam)     '
    $if pParam = Enable         '
        DMA2_OV_IntEnable()     '
    $elseif pParam = Disable    '
        DMA2_OV_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA2 Destination Count interrupt
'
$define Int_DMA2_DCNT(pParam)   '
    $if pParam = Enable         '
        DMA2_DCNT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA2_DCNT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a DMA2 Source Count interrupt
'
$define Int_DMA2_SCNT(pParam)   '
    $if pParam = Enable         '
        DMA2_SCNT_IntEnable()   '
    $elseif pParam = Disable    '
        DMA2_SCNT_IntDisable()  '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CLC1 interrupt
'
$define Int_CLC1(pParam)        '
    $if pParam = Enable         '
        CLC1_IntEnable()        '
    $elseif pParam = Disable    '
        CLC1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CLC2 interrupt
'
$define Int_CLC2(pParam)        '
    $if pParam = Enable         '
        CLC2_IntEnable()        '
    $elseif pParam = Disable    '
        CLC2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CLC3 interrupt
'
$define Int_CLC3(pParam)        '
    $if pParam = Enable         '
        CLC3_IntEnable()        '
    $elseif pParam = Disable    '
        CLC3_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CLC4 interrupt
'
$define Int_CLC4(pParam)        '
    $if pParam = Enable         '
        CLC4_IntEnable()        '
    $elseif pParam = Disable    '
        CLC4_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CWG1 interrupt
'
$define Int_CWG1(pParam)        '
    $if pParam = Enable         '
        CWG1_IntEnable()        '
    $elseif pParam = Disable    '
        CWG1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CWG2 interrupt
'
$define Int_CWG2(pParam)        '
    $if pParam = Enable         '
        CWG2_IntEnable()        '
    $elseif pParam = Disable    '
        CWG2_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CWG3 interrupt
'
$define Int_CWG3(pParam)        '
    $if pParam = Enable         '
        CWG3_IntEnable()        '
    $elseif pParam = Disable    '
        CWG3_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an NCO1 interrupt
'
$define Int_NCO1(pParam)        '
    $if pParam = Enable         '
        NCO1_IntEnable()        '
    $elseif pParam = Disable    '
        NCO1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CRC interrupt
'
$define Int_CRC(pParam)         '
    $if pParam = Enable         '
        CRC_IntEnable()         '
    $elseif pParam = Disable    '
        CRC_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a CSW interrupt
'
$define Int_CSW(pParam)         '
    $if pParam = Enable         '
        CSW_IntEnable()         '
    $elseif pParam = Disable    '
        CSW_IntDisable()        '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a SMT1PWM interrupt
'
$define Int_SMT1PWM(pParam)     '
    $if pParam = Enable         '
        SMT1PWM_IntEnable()     '
    $elseif pParam = Disable    '
        SMT1PWM_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable a SMT1PRA interrupt
'
$define Int_SMT1PRA(pParam)     '
    $if pParam = Enable         '
        SMT1PRA_IntEnable()     '
    $elseif pParam = Disable    '
        SMT1PRA_IntDisable()    '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------
' Enable\Disable an SMT1 interrupt
'
$define Int_SMT1(pParam)        '
    $if pParam = Enable         '
        SMT1_IntEnable()        '
    $elseif pParam = Disable    '
        SMT1_IntDisable()       '
    $else                       '
        $error "Unrecognised parameter. Enable or Disable only" '
    $endif

'------------------------------------------------------------------

$define _Managed_ISR

'----------------------------------------------------------------------------
' The main high priority ISR handler subroutine
'
' This routine calls the relevant peripheral interrupt handlers
'
$if _defined(Handle_IOC_Int) Or _defined(Handle_INT0_Int) Or _defined(Handle_INT1_Int) Or _defined(Handle_INT2_Int)                 '
 Or _defined(Handle_RX_Int) Or _defined(Handle_TX_Int) Or _defined(Handle_RX1_Int) Or _defined(Handle_TX1_Int)                      '
 Or _defined(Handle_RX2_Int) Or _defined(Handle_TX2_Int)                                                                            '
 Or _defined(Handle_SPI1_Int) Or _defined(Handle_SPI_Int)                                                                           '
 Or _defined(Handle_CCP1_Int) Or _defined(Handle_CCP2_Int) Or _defined(Handle_CCP3_Int) Or _defined(Handle_CCP4_Int)                '
 Or _defined(Handle_TMR0_Int) Or _defined(Handle_TMR1_Int) Or _defined(Handle_TMR2_Int) Or _defined(Handle_TMR3_Int)                '
 Or _defined(Handle_TMR4_Int) Or _defined(Handle_TMR5_Int) Or _defined(Handle_TMR6_Int)                                             '
 Or _defined(Handle_HLVD_Int) Or _defined(Handle_ADC_Int) Or _defined(Handle_OSC_Int)                                               '
 Or _defined(Handle_CMP1_Int) Or _defined(Handle_CMP2_Int) Or _defined(Handle_NVM_Int)                                              '
 Or _defined(Handle_I2C_Int)  Or _defined(Handle_I2C1_Int) Or _defined(Handle_I2C2_Int)                                             '
 Or _defined(Handle_TMR1_Gate_Int) Or _defined(Handle_TMR3_Gate_Int) Or _defined(Handle_TMR5_Gate_Int) Or _defined(Handle_CCP3_Int) '
 Or _defined(Handle_TMR2_Match_Int) Or _defined(Handle_TMR4_Match_Int) Or _defined(Handle_TMR6_Match_Int)                           '
 Or _defined(Handle_CRC_Int) Or _defined(Handle_CSW_Int) Or _defined(Handle_ZCD_Int)                                                '
 Or _defined(Handle_SMT1PWM_Int) Or _defined(Handle_SMT1PRA_Int) Or _defined(Handle_SMT1_Int)                                       '
 Or _defined(Handle_SPI_RX_Int) Or _defined(Handle_SPI_TX_Int) Or _defined(Handle_SPI1_RX_Int) Or _defined(Handle_SPI1_TX_Int)          '
 Or _defined(Handle_DMA1_ABRT_Int) Or _defined(Handle_DMA1_OV_Int) Or _defined(Handle_DMA1_DCNT_Int) Or _defined(Handle_DMA1_SCNT_Int)  '
 Or _defined(Handle_DMA2_ABRT_Int) Or _defined(Handle_DMA2_OV_Int) Or _defined(Handle_DMA2_DCNT_Int) Or _defined(Handle_DMA2_SCNT_Int)  '
 Or _defined(Handle_CLC1_Int) Or _defined(Handle_CLC2_Int) Or _defined(Handle_CLC3_Int) Or _defined(Handle_CLC4_Int)                    '
 Or _defined(Handle_CWG1_Int) Or _defined(Handle_CWG2_Int) Or _defined(Handle_CWG3_Int) Or _defined(Handle_NCO1_Int)

Declare Reminders = Off
Declare Warnings = Off
    On_Hardware_Interrupt GoTo _ISR_High
    GoTo _InterruptManagerMain               ' Jump over the interrupt handler subroutine

_ISR_High:

$ifdef _Managed_ISR
    Context Save FSR0L, FSR0H, FSR1L, FSR1H
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_RX_Int) Or _defined(Handle_RX1_Int)
    If RX_IntFlag = 1 Then
        GoTo _ISR_RX1
_ISR_RX1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_SPI_Int) Or _defined(Handle_SPI1_Int)
    If SPI_IntFlag = 1 Then
        GoTo _ISR_SPI1
_ISR_SPI1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR0_Int
    If TMR0_IntFlag = 1 Then
        GoTo _ISR_TMR0
_ISR_TMR0_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR1_Int
    If TMR1_IntFlag = 1 Then
        GoTo _ISR_TMR1
_ISR_TMR1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR3_Int
    If TMR3_IntFlag = 1 Then
        GoTo _ISR_TMR3
_ISR_TMR3_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR4_Int
    If TMR4_IntFlag = 1 Then
        GoTo _ISR_TMR4
_ISR_TMR4_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR5_Int
    If TMR5_IntFlag = 1 Then
        GoTo _ISR_TMR5
_ISR_TMR5_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR6_Int
    If TMR6_IntFlag = 1 Then
        GoTo _ISR_TMR6
_ISR_TMR6_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_INT0_Int
    If INT0_IntFlag = 1 Then
        GoTo _ISR_INT0
_ISR_INT0_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_INT1_Int
    If INT1_IntFlag = 1 Then
        GoTo _ISR_INT1
_ISR_INT1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_INT2_Int
    If INT2_IntFlag = 1 Then
        GoTo _ISR_INT2
_ISR_INT2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_IOC_Int
    If IOC_IntFlag = 1 Then
        GoTo _ISR_IOC
_ISR_IOC_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_TX_Int) Or _defined(Handle_TX1_Int)
    If TX_IntFlag = 1 Then
        GoTo _ISR_TX1
_ISR_TX1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_RX2_Int
    If RX2_IntFlag = 1 Then
        GoTo _ISR_RX2
_ISR_RX2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TX2_Int
    If TX2_IntFlag = 1 Then
        GoTo _ISR_TX2
_ISR_TX2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CCP1_Int
    If CCP1_IntFlag = 1 Then
        GoTo _ISR_CCP1
_ISR_CCP1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CCP2_Int
    If CCP2_IntFlag = 1 Then
        GoTo _ISR_CCP2
_ISR_CCP2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CCP3_Int
    If CCP3_IntFlag = 1 Then
        GoTo _ISR_CCP3
_ISR_CCP3_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CCP4_Int
    If CCP4_IntFlag = 1 Then
        GoTo _ISR_CCP4
_ISR_CCP4_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_ADC_Int
    If ADC_IntFlag = 1 Then
        GoTo _ISR_ADC
_ISR_ADC_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CMP1_Int
    If CMP1_IntFlag = 1 Then
        GoTo _ISR_CMP1
_ISR_CMP1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CMP2_Int
    If CMP2_IntFlag = 1 Then
        GoTo _ISR_CMP2
_ISR_CMP2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_NVM_Int
    If NVM_IntFlag = 1 Then
        GoTo _ISR_NVM
_ISR_NVM_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_I2C_Int) Or _defined(Handle_I2C1_Int)
    If I2C_IntFlag = 1 Then
        GoTo _ISR_I2C1
_ISR_I2C1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_I2C2_Int
    If I2C2_IntFlag = 1 Then
        GoTo _ISR_I2C2
_ISR_I2C2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_HLVD_Int
    If HLVD_IntFlag = 1 Then
        GoTo _ISR_HLVD
_ISR_Low_Voltage_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_OSC_Int
    If OSC_IntFlag = 1 Then
        GoTo _ISR_OSC
_ISR_OSC_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR1_Gate_Int
    If TMR1_Gate_IntFlag = 1 Then
        GoTo _ISR_TMR1_Gate
_ISR_TMR1_Gate_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR3_Gate_Int
    If TMR3_Gate_IntFlag = 1 Then
        GoTo _ISR_TMR3_Gate
_ISR_TMR3_Gate_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR5_Gate_Int
    If TMR5_Gate_IntFlag = 1 Then
        GoTo _ISR_TMR5_Gate
_ISR_TMR5_Gate_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR2_Match_Int
    If TMR2_Match_IntFlag = 1 Then
        GoTo _ISR_TMR2_Match
_ISR_TMR2_Match_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR4_Match_Int
    If TMR4_Match_IntFlag = 1 Then
        GoTo _ISR_TMR4_Match
_ISR_TMR4_Match_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_TMR6_Match_Int
    If TMR6_Match_IntFlag = 1 Then
        GoTo _ISR_TMR6_Match
_ISR_TMR6_Match_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CRC_Int
    If CRC_IntFlag = 1 Then
        GoTo _ISR_CRC
_ISR_CRC_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CSW_Int
    If CSW_IntFlag = 1 Then
        GoTo _ISR_CSW
_ISR_CSW_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_ZCD_Int
    If ZCD_IntFlag = 1 Then
        GoTo _ISR_ZCD
_ISR_ZCD_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_SMT1PWM_Int
    If SMT1PWM_IntFlag = 1 Then
        GoTo _ISR_SMT1PWM
_ISR_SMT1PWM_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_SMT1PRA_Int
    If SMT1PRA_IntFlag = 1 Then
        GoTo _ISR_SMT1PRA
_ISR_SMT1PRA_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_SMT1_Int
    If SMT1_IntFlag = 1 Then
        GoTo _ISR_SMT1
_ISR_SMT1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_SPI_RX_Int) Or _defined(Handle_SPI1_RX_Int)
    If SPI1_RX_IntFlag = 1 Then
        GoTo _ISR_SPI1_RX
_ISR_SPI1_RX_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$if _defined(Handle_SPI_TX_Int) Or _defined(Handle_SPI1_TX_Int)
    If SPI1_TX_IntFlag = 1 Then
        GoTo _ISR_SPI1_TX
_ISR_SPI1_TX_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA1_ABRT_Int
    If DMA1_ABRT_IntFlag = 1 Then
        GoTo _ISR_DMA1_ABRT
_ISR_DMA1_ABRT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA1_OV_Int
    If DMA1_OV_IntFlag = 1 Then
        GoTo _ISR_DMA1_OV
_ISR_DMA1_OV_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA1_DCNT_Int
    If DMA1_DCNT_IntFlag = 1 Then
        GoTo _ISR_DMA1_DCNT
_ISR_DMA1_DCNT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA1_SCNT_Int
    If DMA1_SCNT_IntFlag = 1 Then
        GoTo _ISR_DMA1_SCNT
_ISR_DMA1_SCNT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA2_ABRT_Int
    If DMA2_ABRT_IntFlag = 1 Then
        GoTo _ISR_DMA2_ABRT
_ISR_DMA2_ABRT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA2_OV_Int
    If DMA2_OV_IntFlag = 1 Then
        GoTo _ISR_DMA2_OV
_ISR_DMA2_OV_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA2_DCNT_Int
    If DMA2_DCNT_IntFlag = 1 Then
        GoTo _ISR_DMA2_DCNT
_ISR_DMA2_DCNT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_DMA2_SCNT_Int
    If DMA2_SCNT_IntFlag = 1 Then
        GoTo _ISR_DMA2_SCNT
_ISR_DMA2_SCNT_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CLC1_Int
    If CLC1_IntFlag = 1 Then
        GoTo _ISR_CLC1
_ISR_CLC1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CLC2_Int
    If CLC2_IntFlag = 1 Then
        GoTo _ISR_CLC2
_ISR_CLC2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CLC3_Int
    If CLC3_IntFlag = 1 Then
        GoTo _ISR_CLC3
_ISR_CLC3_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CLC4_Int
    If CLC4_IntFlag = 1 Then
        GoTo _ISR_CLC4
_ISR_CLC4_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CWG1_Int
    If CWG1_IntFlag = 1 Then
        GoTo _ISR_CWG1
_ISR_CWG1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CWG2_Int
    If CWG2_IntFlag = 1 Then
        GoTo _ISR_CWG2
_ISR_CWG2_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_CWG3_Int
    If CWG3_IntFlag = 1 Then
        GoTo _ISR_CWG3
_ISR_CWG3_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef Handle_NCO1_Int
    If NCO1_IntFlag = 1 Then
        GoTo _ISR_NCO1
_ISR_NCO1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
$ifdef _Managed_ISR
    Context Restore
$else
    Retfie Fast
$endif  ' _Managed_ISR

'----------------------------------------------------------------------------
' Interrupt On Change interrupt manager
'
$define ISR_IOC(pParam)         '
$if pParam = START              '
    GoTo _ISR_IOC_Over          '
_ISR_IOC:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    IOC_IntFlag = 0             '
    GoTo _ISR_IOC_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_IOC_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' INT0 interrupt manager
'
$define ISR_INT0(pParam)        '
$if pParam = START              '
    GoTo _ISR_INT0_Over         '
_ISR_INT0:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    INT0_IntFlag = 0            '
    GoTo ISR_INT0_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_INT0_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' INT1 interrupt manager
'
$define ISR_INT1(pParam)        '
$if pParam = START              '
    GoTo _ISR_INT1_Over         '
_ISR_INT1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    INT1_IntFlag = 0            '
    GoTo _ISR_INT1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_INT1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' INT2 interrupt manager
'
$define ISR_INT2(pParam)        '
$if pParam = START              '
    GoTo _ISR_INT2_Over         '
_ISR_INT2:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    INT2_IntFlag = 0            '
    GoTo _ISR_INT2_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_INT2_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer0 overflow interrupt manager
'
$define ISR_TMR0(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR0_Over         '
_ISR_TMR0:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR0_IntFlag = 0            '
    GoTo _ISR_TMR0_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR0_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer1 overflow interrupt manager
'
$define ISR_TMR1(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR1_Over         '
_ISR_TMR1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR1_IntFlag = 0            '
    GoTo _ISR_TMR1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer3 overflow interrupt manager
'
$define ISR_TMR3(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR3_Over         '
_ISR_TMR3:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR3_IntFlag = 0            '
    GoTo _ISR_TMR3_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR3_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer4 overflow interrupt manager
'
$define ISR_TMR4(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR4_Over         '
_ISR_TMR4:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR4_IntFlag = 0            '
    GoTo _ISR_TMR4_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR4_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer5 overflow interrupt manager
'
$define ISR_TMR5(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR5_Over         '
_ISR_TMR5:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR5_IntFlag = 0            '
    GoTo _ISR_TMR5_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR5_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer6 overflow interrupt manager
'
$define ISR_TMR6(pParam)        '
$if pParam = START              '
    GoTo _ISR_TMR6_Over         '
_ISR_TMR6:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR6_IntFlag = 0            '
    GoTo _ISR_TMR6_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR6_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' UART1 receive interrupt manager
'
$define ISR_RX(pParam)         '
$if pParam = START              '
    GoTo _ISR_RX1_Over          '
_ISR_RX1:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    GoTo _ISR_RX1_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_RX1_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

$define ISR_RX1(pParam) ISR_RX(pParam)

'----------------------------------------------------------------------------
' UART1 transmit interrupt manager
'
$define ISR_TX(pParam)         '
$if pParam = START              '
    GoTo _ISR_TX1_Over          '
_ISR_TX1:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    GoTo _ISR_TX1_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TX1_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

$define ISR_TX1(pParam) ISR_TX(pParam)

'----------------------------------------------------------------------------
' UART2 receive interrupt manager
'
$define ISR_RX2(pParam)         '
$if pParam = START              '
    GoTo _ISR_RX2_Over          '
_ISR_RX2:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    GoTo _ISR_RX2_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_RX2_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' UART2 transmit interrupt manager
'
$define ISR_TX2(pParam)         '
$if pParam = START              '
    GoTo _ISR_TX2_Over          '
_ISR_TX2:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    GoTo ISR_TX2_Exit           '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TX2_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SPI interrupt manager
'
$define ISR_SPI(pParam)         '
$if pParam = START              '
    GoTo _ISR_SPI1_Over         '
_ISR_SPI1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SPI_IntFlag = 0             '
    GoTo _ISR_SPI1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SPI1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

$define ISR_SPI1(pParam) ISR_SPI(pParam)

'----------------------------------------------------------------------------
' CCP1 interrupt manager
'
$define ISR_CCP1(pParam)        '
$if pParam = START              '
    GoTo _ISR_CCP1_Over         '
_ISR_CCP1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CCP1_IntFlag = 0            '
    GoTo _ISR_CCP1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CCP1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CCP2 interrupt manager
'
$define ISR_CCP2(pParam)        '
$if pParam = START              '
    GoTo _ISR_CCP2_Over         '
_ISR_CCP2:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CCP2_IntFlag = 0            '
    GoTo _ISR_CCP2_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CCP2_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CCP3 interrupt manager
'
$define ISR_CCP3(pParam)        '
$if pParam = START              '
    GoTo _ISR_CCP3_Over         '
_ISR_CCP3:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CCP3_IntFlag = 0            '
    GoTo _ISR_CCP3_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CCP3_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CCP4 interrupt manager
'
$define ISR_CCP4(pParam)        '
$if pParam = START              '
    GoTo _ISR_CCP4_Over         '
_ISR_CCP4:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CCP4_IntFlag = 0            '
    GoTo _ISR_CCP4_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CCP4_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' ADC interrupt manager
'
$define ISR_ADC(pParam)         '
$if pParam = START              '
    GoTo _ISR_ADC_Over          '
_ISR_ADC:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    ADC_IntFlag = 0             '
    GoTo _ISR_ADC_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_ADC_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Comparator 1 interrupt manager
'
$define ISR_CMP1(pParam)       '
$if pParam = START             '
    GoTo _ISR_CMP1_Over        '
_ISR_CMP1:                     '
    $ifdef _Managed_ISR        '
        High_Int_Sub_Start     '
    $endif                     '
$elseif pParam = EXIT          '
    CMP1_IntFlag = 0           '
    GoTo _ISR_CMP1_Exit        '
    $ifdef _Managed_ISR        '
        High_Int_Sub_End       '
    $endif                     '
_ISR_CMP1_Over:                '
$else                          '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Comparator 2 interrupt manager
'
$define ISR_CMP2(pParam)       '
$if pParam = START             '
    GoTo _ISR_CMP2_Over        '
_ISR_CMP2:                     '
    $ifdef _Managed_ISR        '
        High_Int_Sub_Start     '
    $endif                     '
$elseif pParam = EXIT          '
    CMP2_IntFlag = 0           '
    GoTo _ISR_CMP2:_Exit       '
    $ifdef _Managed_ISR        '
        High_Int_Sub_End       '
    $endif                     '
_ISR_CMP2_Over:                '
$else                          '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Non Volatile Memory write interrupt manager
'
$define ISR_NVM(pParam)         '
$if pParam = START              '
    GoTo _ISR_NVM_Over          '
_ISR_NVM:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    NVM_IntFlag = 0             '
    GoTo _ISR_NVM_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_NVM_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' I2C1 Bus_Collision interrupt manager
'
$define ISR_I2C1(pParam)        '
$if pParam = START              '
    GoTo _ISR_I2C1_Over         '
_ISR_I2C1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    I2C1_IntFlag = 0            '
    GoTo _ISR_I2C1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_I2C1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' I2C2 Bus Collision interrupt manager
'
$define ISR_I2C2(pParam)        '
$if pParam = START              '
    GoTo _ISR_I2C2_Over         '
_ISR_I2C2:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    I2C2_IntFlag = 0            '
    GoTo _ISR_I2C2_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_I2C2_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Low Voltage interrupt manager
'
$define ISR_HLVD(pParam)        '
$if pParam = START              '
    GoTo _ISR_HLVD_Over         '
_ISR_HLVD:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    HLVD_IntFlag = 0            '
    GoTo _ISR_Low_Voltage_Exit  '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_HLVD_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Oscillator Fail interrupt manager
'
$define ISR_OSC(pParam)         '
$if pParam = START              '
    GoTo _ISR_OSC_Over          '
_ISR_OSC:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    OSC_IntFlag = 0             '
    GoTo _ISR_OSC_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_OSC_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer1 Gate interrupt manager
'
$define ISR_TMR1_Gate(pParam)   '
$if pParam = START              '
    GoTo _ISR_TMR1_Gate_Over    '
_ISR_TMR1_Gate:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR1_Gate_IntFlag = 0       '
    GoTo _ISR_TMR1_Gate_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR1_Gate_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer3 Gate interrupt manager
'
$define ISR_TMR3_Gate(pParam)   '
$if pParam = START              '
    GoTo _ISR_TMR3_Gate_Over    '
_ISR_TMR3_Gate:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR3_Gate_IntFlag = 0       '
    GoTo _ISR_TMR3_Gate_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR3_Gate_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer5 Gate interrupt manager
'
$define ISR_TMR5_Gate(pParam)   '
$if pParam = START              '
    GoTo _ISR_TMR5_Gate_Over    '
_ISR_TMR5_Gate:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR5_Gate_IntFlag = 0       '
    GoTo _ISR_TMR5_Gate_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR5_Gate_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer2 to PR2 match interrupt manager
'
$define ISR_TMR2_Match(pParam) '
$if pParam = START              '
    GoTo _ISR_TMR2_Match_Over   '
_ISR_TMR2_Match:                '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR2_Match_IntFlag = 0      '
    GoTo _ISR_TMR2_Match_Exit   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR2_Match_Over:           '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer4 to PR4 match interrupt manager
'
$define ISR_TMR4_Match(pParam) '
$if pParam = START              '
    GoTo _ISR_TMR4_Match_Over   '
_ISR_TMR4_Match:                '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR4_Match_IntFlag = 0      '
    GoTo _ISR_TMR4_Match_Exit   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR4_Match_Over:           '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' Timer6 to PR6 match interrupt manager
'
$define ISR_TMR6_Match(pParam) '
$if pParam = START              '
    GoTo _ISR_TMR6_Match_Over   '
_ISR_TMR6_Match:                '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    TMR6_Match_IntFlag = 0      '
    GoTo _ISR_TMR6_Match_Exit   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_TMR6_Match_Over:           '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif


'----------------------------------------------------------------------------
' CRC interrupt manager
'
$define ISR_CRC(pParam)         '
$if pParam = START              '
    GoTo _ISR_CRC_Over          '
_ISR_CRC:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CRC_IntFlag = 0             '
    GoTo _ISR_CRC_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CRC_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CSW interrupt manager
'
$define ISR_CSW(pParam)         '
$if pParam = START              '
    GoTo _ISR_CSW_Over          '
_ISR_CSW:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CSW_IntFlag = 0             '
    GoTo _ISR_CSW_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CSW_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' ZCD interrupt manager
'
$define ISR_ZCD(pParam)         '
$if pParam = START              '
    GoTo _ISR_ZCD_Over          '
_ISR_ZCD:                       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    ZCD_IntFlag = 0             '
    GoTo _ISR_ZCD_Exit          '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_ZCD_Over:                  '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SMT1PWM interrupt manager
'
$define ISR_SMT1PWM(pParam)     '
$if pParam = START              '
    GoTo _ISR_SMT1PWM_Over      '
_ISR_SMT1PWM:                   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SMT1PWM_IntFlag = 0         '
    GoTo _ISR_SMT1PWM_Exit      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SMT1PWM_Over:              '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SMT1PRA interrupt manager
'
$define ISR_SMT1PRA(pParam)     '
$if pParam = START              '
    GoTo _ISR_SMT1PRA_Over      '
_ISR_SMT1PRA:                   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SMT1PWM_IntFlag = 0         '
    GoTo _ISR_SMT1PRA_Exit      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SMT1PRA_Over:              '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SMT1 interrupt manager
'
$define ISR_SMT1(pParam)        '
$if pParam = START              '
    GoTo _ISR_SMT1_Over         '
_ISR_SMT1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SMT1_IntFlag = 0            '
    GoTo _ISR_SMT1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SMT1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SPI RX interrupt manager
'
$define ISR_SPI_RX(pParam)      '
$if pParam = START              '
    GoTo _ISR_SPI_RX_Over       '
_ISR_SPI_RX:                    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SPI_RX_IntFlag = 0          '
    GoTo _ISR_SPI_RX_Exit       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SPI_RX_Over:               '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' SPI TX interrupt manager
'
$define ISR_SPI_TX(pParam)      '
$if pParam = START              '
    GoTo _ISR_SPI_TX_Over       '
_ISR_SPI_TX:                    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    SPI_TX_IntFlag = 0          '
    GoTo _ISR_SPI_TX_Exit       '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_SPI_TX_Over:               '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA1_ABRT interrupt manager
'
$define ISR_DMA1_ABRT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA1_ABRT_Over    '
_ISR_DMA1_ABRT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA1_ABRT_IntFlag = 0       '
    GoTo _ISR_DMA1_ABRT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA1_ABRT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA1_OV interrupt manager
'
$define ISR_DMA1_OV(pParam)     '
$if pParam = START              '
    GoTo _ISR_DMA1_OV_Over      '
_ISR_DMA1_OV:                   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA1_OV_IntFlag = 0         '
    GoTo _ISR_DMA1_OV_Exit      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA1_OV_Over:              '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA1_DCNT interrupt manager
'
$define ISR_DMA1_DCNT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA1_DCNT_Over    '
_ISR_DMA1_DCNT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA1_DCNT_IntFlag = 0       '
    GoTo _ISR_DMA1_DCNT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA1_DCNT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA1_SCNT interrupt manager
'
$define ISR_DMA1_SCNT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA1_SCNT_Over    '
_ISR_DMA1_SCNT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA1_SCNT_IntFlag = 0       '
    GoTo _ISR_DMA1_SCNT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA1_SCNT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA2_ABRT interrupt manager
'
$define ISR_DMA2_ABRT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA2_ABRT_Over    '
_ISR_DMA2_ABRT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA2_ABRT_IntFlag = 0       '
    GoTo _ISR_DMA2_ABRT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA2_ABRT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA2_OV interrupt manager
'
$define ISR_DMA2_OV(pParam)     '
$if pParam = START              '
    GoTo _ISR_DMA2_OV_Over      '
_ISR_DMA2_OV:                   '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA2_OV_IntFlag = 0         '
    GoTo _ISR_DMA2_OV_Exit      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA2_OV_Over:              '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA2_DCNT interrupt manager
'
$define ISR_DMA2_DCNT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA2_DCNT_Over    '
_ISR_DMA2_DCNT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA2_DCNT_IntFlag = 0       '
    GoTo _ISR_DMA2_DCNT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA2_DCNT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' DMA2_SCNT interrupt manager
'
$define ISR_DMA2_SCNT(pParam)   '
$if pParam = START              '
    GoTo _ISR_DMA2_SCNT_Over    '
_ISR_DMA2_SCNT:                 '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    DMA2_SCNT_IntFlag = 0       '
    GoTo _ISR_DMA2_SCNT_Exit    '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_DMA2_SCNT_Over:            '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CLC1 interrupt manager
'
$define ISR_CLC1(pParam)        '
$if pParam = START              '
    GoTo _ISR_CLC1_Over         '
_ISR_CLC1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CLC1_IntFlag = 0            '
    GoTo _ISR_CLC1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CLC1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CLC2 interrupt manager
'
$define ISR_CLC2(pParam)        '
$if pParam = START              '
    GoTo _ISR_CLC2_Over         '
_ISR_CLC2:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CLC2_IntFlag = 0            '
    GoTo _ISR_CLC2_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CLC2_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CLC3 interrupt manager
'
$define ISR_CLC3(pParam)        '
$if pParam = START              '
    GoTo _ISR_CLC3_Over         '
_ISR_CLC3:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CLC3_IntFlag = 0            '
    GoTo _ISR_CLC3_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CLC3_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CLC4 interrupt manager
'
$define ISR_CLC4(pParam)        '
$if pParam = START              '
    GoTo _ISR_CLC4_Over         '
_ISR_CLC4:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CLC4_IntFlag = 0            '
    GoTo _ISR_CLC4_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CLC4_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

$ifdef Handle_CWG1_Int
    If CWG1_IntFlag = 1 Then
        GoTo _ISR_CWG1
_ISR_CWG1_Exit:
    EndIf
$endif

'----------------------------------------------------------------------------
' CWG1 interrupt manager
'
$define ISR_CWG1(pParam)        '
$if pParam = START              '
    GoTo _ISR_CWG1_Over         '
_ISR_CWG1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CWG1_IntFlag = 0            '
    GoTo _ISR_CWG1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CWG1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CWG2 interrupt manager
'
$define ISR_CWG2(pParam)        '
$if pParam = START              '
    GoTo _ISR_CWG2_Over         '
_ISR_CWG2:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CWG2_IntFlag = 0            '
    GoTo _ISR_CWG2_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CWG2_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' CWG3 interrupt manager
'
$define ISR_CWG3(pParam)        '
$if pParam = START              '
    GoTo _ISR_CWG3_Over         '
_ISR_CWG3:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    CWG3_IntFlag = 0            '
    GoTo _ISR_CWG3_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_CWG3_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

'----------------------------------------------------------------------------
' NCO1 interrupt manager
'
$define ISR_NCO1(pParam)        '
$if pParam = START              '
    GoTo _ISR_NCO1_Over         '
_ISR_NCO1:                      '
    $ifdef _Managed_ISR         '
        High_Int_Sub_Start      '
    $endif                      '
$elseif pParam = EXIT           '
    NCO1_IntFlag = 0            '
    GoTo _ISR_NCO1_Exit         '
    $ifdef _Managed_ISR         '
        High_Int_Sub_End        '
    $endif                      '
_ISR_NCO1_Over:                 '
$else                           '
    $error "Parameter must be START or EXIT" '
$endif

$endif      ' _defined(Handle_XXXX)
'----------------------------------------------------------------------------
_InterruptManagerMain:

$endif      ' _Positron_Int_Manager_

Dompie

Thanks Les, that fits the Dev Board of JONW perfectly. Your Positron Compiler, Bootloader and now the Int Manager, together with JONW's board, are an ideal combination to set up and develop a project.
Perhaps a combined sale of the Positron Compiler and the 18F27K42 Dev Board would be a good option.

Johan

PS I thought JONW still has 18F27K42 Dev Boards, if anyone is interested you can always PM him.

JonW

Hi Les

I think you can make it work with something like the board I designed as its much smaller and lower cost, you are very welcome to the design files and what stock I have on hand.  It could be even lower cost if the USB IC was ported over to WCH but we have seen issues with these on some OS, I opted for the CP2102 as it can handle 100mA 3V3 load and was in stock at the SMT house.    If you are interested pm or mail me and we can go through the costs and come to some arrangement on the boards I have on hand (around 45 stuffed with 27k42) (I will trade you for the source code on the bootloader Gui so I can customise it :-)).  You can then make some cash on the sales to help fund the development and it costs you nothing to give it a go for 40 boards?  I don't know what people are willing to pay but with the bootloader, gui and now this int manager bundled in its got to be worth giving it a go?

On the bootloader GUI there is an issue if you deselect the RTS option in that you cant get the selection back again.  Work around is to manipulate the device.ini file as in the tiny bootloader.








SebaG

Thank you very much for the file. Amazing work! It would be a pity to waste so much work without implementing this project.

GaryC

Hello
  Les may have a few setting around, better to get a few Dollars than collecting dust.

Gary