Attribute VB_Name = "Module1"
'#Uses "Const.inc"
'#Uses "Format.inc"
'Uses "..\classes\InterruptClass.cls"
'#Uses "..\classes\ModuleClass.cls"
'#Uses "..\classes\ManualLinkClass.cls"

Option Explicit

'*****************************************************************************
' @Doc
' @Module        Pages.INC
'-----------------------------------------------------------------------------
' @Controllers
'
' @Description   This module contains constants and global functions for
' 2-1-0          global pages (Interrupt, Notes ..)
'
'-----------------------------------------------------------------------------
' @History
'          Rev. Author       Date        Description
'          0.1  Sunil        06-10-04    initial version
'          0.2  Radhish      15-10-04    Interrupt page code added
'          0.3  Sunil        16-11-04    Interrupt page code modified.
'                                        - Control names changed.
'                                        - Indentation.
'                                        - Added code to reset the prority when
'                                          the interrupt is disbled.
'          0.4  Sunil        18-11-04    GUI of Interrupt page redesigned.
'
'
'*****************************************************************************

'*****************************************************************************
' @Global Constants
'*****************************************************************************
Const TOOLTIP_MODULE_NOT_USED = "the interrupt enable option in module is not used"

'*****************************************************************************
' @Global Types
'*****************************************************************************


'*****************************************************************************
' @Global Functions
'*****************************************************************************

'*****************************************************************************
' @bfunc   Public | OnLoadPageNotes | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a page to the peripheral.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
'
'*****************************************************************************
Public Function OnLoadPageNotes(ps As Peripherals) As Boolean
  On Error Resume Next
  OnLoadPageNotes = False

  If (Not ps.AddPage("Notes")) Then Exit Function

  OnLoadPageNotes = True
End Function

'*****************************************************************************
' @bfunc   Public | OnChangingPageNotes | Boolean |
'
'-----------------------------------------------------------------------------
'          This function makes all activities for the Notes page in each
'          module function OnChangingPage.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
' @bparm   | PageName | String | current page name
' @bparm   | ModuleName | String | current module name
'
'*****************************************************************************
Public Function OnChangingPageNotes(ps As Peripherals, Pagename As String, ModuleName As String) As Boolean
  On Error Resume Next
  OnChangingPageNotes = False

  Dim i As Integer
  Dim e As Collection
  Dim s As String

  Set e = ps.ExtenderCollection

  If (Not e("Notes").Loaded) And (Pagename = "Notes") Then
    e("Notes").Loaded = True
    s = ModuleName & "_Notes"
    
    If (Not ps.AddFrame("fra" & s, 100, 100, 8450, 5200, "")) Then Exit Function
      If (Not ps.AddText("txt" & s, 1825, 600, 6000, 3780)) Then Exit Function
      If (Not ps.addlabel("lbl" & s, 0, 200, 600, 1575, 380, "Insert Notes:")) Then Exit Function
       
  End If

  OnChangingPageNotes = True
End Function

'*****************************************************************************
' @bfunc   Public | OnShowPageNotes | Boolean |
'
'-----------------------------------------------------------------------------
'          This function makes all activities for the Notes page in each
'          module function OnShow.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
' @bparm   | Controlname | String | current control name
' @bparm   | Pagename | String | current page name
' @bparm   | ModuleName | String | current module name
' @bparm   | v() | Variant | values for the controlls
'
'*****************************************************************************
Public Function OnShowPageNotes(ps As Peripherals, Controlname As String, Pagename As String, ModuleName As String, v() As Variant) As Boolean
  On Error Resume Next
  OnShowPageNotes = False
  
  Dim r As ProjectData
  Dim c As Collection
  Dim s As String

  Set r = ps.ProjectData
  Set c = ps.ControlCollection

  s = ModuleName & "_Notes"
  
  If (Pagename = "Notes") Then
  
      '------------------------------------------------------------------------------------
      ' page: Notes (action)
      '------------------------------------------------------------------------------------
      Select Case Controlname
          '--------------------------------------------------------------------------------
          ' control: txt.._Notes (action)
          '--------------------------------------------------------------------------------
          Case "txt" & s
               ' action on clicking the selected control
               If (IsInputFormatOK(v(1), FORMAT_NOTES, c("lbl" & s).Caption)) Then
                 r.v(s) = v(1)
               Else
                  Exit Function
               End If
               
      End Select
    
      '------------------------------------------------------------------------------------
      ' page: Notes (show)
      '------------------------------------------------------------------------------------
      
        '----------------------------------------------------------------------------------
        ' control: txt.._Notes
        '----------------------------------------------------------------------------------
        ' action on showing the control
        With c("txt" & s)
            .Text = r.v(s)
        End With
    
  End If         ' if Pagename

  OnShowPageNotes = True
End Function

'*****************************************************************************
' @bfunc   Public | OnLoadPageInterrupts | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a page to the peripheral.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
'
'*****************************************************************************
Public Function OnLoadPageInterrupts(ps As Peripherals) As Boolean
  On Error Resume Next
  OnLoadPageInterrupts = False

  If (Not ps.AddPage("Interrupts")) Then Exit Function
    
  
  OnLoadPageInterrupts = True
End Function

'*****************************************************************************
' @bfunc   Public | OnChangingPageInterrupts | Boolean |
'
'-----------------------------------------------------------------------------
'          This function makes all activities for the interrupt page in each
'          module function OnChangingPage.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
' @bparm   | Pagename | String | current page name
'
'*****************************************************************************
Public Function OnChangingPageInterrupts(ps As Peripherals, Pagename As String) As Boolean
  On Error GoTo ErrorInterrupts
  OnChangingPageInterrupts = False
  
  Dim c As Object
  Dim e As Object
  Dim i As Integer
  
  Dim sIntSource(0 To 13) As String
  
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
  
If (Not ps.ExtenderCollection("Interrupts").Loaded) And (Pagename = "Interrupts") Then
    ps.ExtenderCollection("Interrupts").Loaded = True
    
    sIntSource(0) = "External Interrupt 0"
    sIntSource(1) = "Timer 0 Interrupt"
    sIntSource(2) = "External Interrupt 1"
    sIntSource(3) = "Timer 1 Interrupt"
    sIntSource(4) = "UART Interrupt"
    sIntSource(5) = "Timer 2 / BRG / MultiCAN Node 0 Interpts"
    sIntSource(6) = "ADC / MultiCAN Node 1 and 2 Interpts"
    sIntSource(7) = "SSC Interrupt"
    sIntSource(8) = "External 2 / T21 / UART1 / BRG1 Intrpts"
    sIntSource(9) = "External [6:3]  / MultiCAN Node 3 Interpts"
    sIntSource(10) = "CCU6 Node 0 / MultiCAN Node 4 Interpts"
    sIntSource(11) = "CCU6 Node 1 / MultiCAN Node 5 Interpts"
    sIntSource(12) = "CCU6 Node 2 / MultiCAN Node 6 Interpts"
    sIntSource(13) = "CCU6 Node 3 / MultiCAN Node 7 Interpts"
    
    If (Not ps.AddFrame("frmOuterFrame", 0, 0, 10070, 5500, "")) Then Exit Function
        c("frmOuterFrame").BorderStyle = 0
            
            ' ------------------------------------------------------------------------------------------
            ' Top row
            If (Not ps.addlabel("lbl0_0", 1, 0, 50, 750, 385, "")) Then Exit Function
            c("lbl0_0").Appearance = 0
            
            If (Not ps.addlabel("lblLevel", 0, 80, 130, 500, 250, "Level")) Then Exit Function
            With c("lblLevel")
                .ForeColor = &HFF0000
                .FontBold = True
            End With
            
            If (Not ps.addlabel("lbl0_1", 1, 740, 50, 3900, 385, "")) Then Exit Function
            c("lbl0_1").Appearance = 0
            
            If (Not ps.addlabel("lblIntSource", 0, 1000, 130, 1600, 250, "Interrupt Source")) Then Exit Function
            With c("lblIntSource")
                .ForeColor = &HFF0000
                .FontBold = True
            End With
            
            If (Not ps.addlabel("lbl0_2", 1, 4620, 50, 4030, 385, "")) Then Exit Function
            c("lbl0_2").Appearance = 0
            
            If (Not ps.addlabel("lblPriority0", 0, 4700, 130, 1000, 250, "Priority 0")) Then Exit Function
            With c("lblPriority0")
                .ForeColor = &HFF0000
                .FontBold = True
            End With
            
            If (Not ps.addlabel("lblPriority1", 0, 5750, 130, 1000, 250, "Priority 1")) Then Exit Function
            With c("lblPriority1")
                .ForeColor = &HFF0000
                .FontBold = True
            End With

            If (Not ps.addlabel("lblPriority2", 0, 6800, 130, 1500, 250, "Priority 2")) Then Exit Function
            With c("lblPriority2")
                .ForeColor = &HFF0000
                .FontBold = True
            End With

            If (Not ps.addlabel("lblPriority3", 0, 7850, 130, 1500, 250, "Priority 3")) Then Exit Function
            With c("lblPriority3")
                .ForeColor = &HFF0000
                .FontBold = True
            End With
            
            ' ------------------------------------------------------------------------------------------
            
            ' NMI row
            If (Not ps.addlabel("lbl1_0", 1, 0, 420, 750, 320, "")) Then Exit Function
            c("lbl1_0").Appearance = 0
            
            If (Not ps.addlabel("lblLevel0", 0, 80, 480, 650, 250, "Level 0")) Then Exit Function
            
            If (Not ps.addlabel("lbl1_1", 1, 740, 420, 3900, 320, "")) Then Exit Function
            c("lbl1_1").Appearance = 0
            
            If (Not ps.addlabel("lblNMI", 0, 1000, 480, 3000, 250, "Non Maskable Interrupt (NMI)")) Then Exit Function
            
            If (Not ps.addlabel("lbl1_2", 1, 4620, 420, 4030, 320, "")) Then Exit Function
            c("lbl1_2").Appearance = 0
            
            If (Not ps.addlabel("lblNMIPriority", 0, 5300, 480, 3000, 250, "Highest Priority (can't be changed)")) Then Exit Function
            With c("lblNMIPriority")
                .FontBold = True
            End With
            
            ' -------------------------------------------------------------------------------------------
            ' Other Interrupt entries
            

            For i = 1 To 14
                If (Not ps.addlabel("lbl" & i + 1 & "_0", 1, 0, 420 + i * 315, 750, 320, "")) Then Exit Function
                c("lbl" & i + 1 & "_0").Appearance = 0
                If (Not ps.addlabel("lblLevel" & i, 0, 80, 480 + i * 315, 650, 250, "Level " & i)) Then Exit Function

                If (Not ps.addlabel("lbl" & i + 1 & "_1", 1, 740, 420 + i * 315, 3900, 320, "")) Then Exit Function
                c("lbl" & i + 1 & "_1").Appearance = 0
                If (Not ps.addlabel("lbl" & sIntSource(i - 1), 0, 1000, 480 + i * 315, 3000, 250, sIntSource(i - 1))) Then Exit Function

                If (Not ps.addlabel("lbl" & i + 1 & "_2", 1, 4620, 420 + i * 315, 4030, 320, "")) Then Exit Function
                c("lbl" & i + 1 & "_2").Appearance = 0

            Next
            ' --------------------------------------------------------------------------------------------
            ' Option Buttons
            
            '-----------------------------------------------------------------------------------------------------------------
            If (Not ps.AddFrame("fraExtInt0", 4820, 750, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraExtInt0").BorderStyle = 0
                If (Not ps.AddOption("optExtInt0_0", 100, 60, 200, 110, "")) Then Exit Function
                If (Not ps.AddOption("optExtInt0_1", 1250, 60, 200, 110, "")) Then Exit Function
                If (Not ps.AddOption("optExtInt0_2", 2400, 60, 200, 110, "")) Then Exit Function
                If (Not ps.AddOption("optExtInt0_3", 3400, 60, 200, 110, "")) Then Exit Function


            If (Not ps.AddFrame("fraTimer0Intr", 4820, 1070, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraTimer0Intr").BorderStyle = 0
               If (Not ps.AddOption("optTimer0Intr_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer0Intr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer0Intr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer0Intr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraExtIntr1", 4820, 1380, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraExtIntr1").BorderStyle = 0
               If (Not ps.AddOption("optExtIntr1_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr1_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr1_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr1_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraTimer1Intr", 4820, 1690, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraTimer1Intr").BorderStyle = 0
               If (Not ps.AddOption("optTimer1Intr_0", 100, 50, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer1Intr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer1Intr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer1Intr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraUARTIntr", 4820, 2010, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraUARTIntr").BorderStyle = 0
               If (Not ps.AddOption("optUARTIntr_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optUARTIntr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optUARTIntr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optUARTIntr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraTimer2Intr", 4820, 2320, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraTimer2Intr").BorderStyle = 0
               If (Not ps.AddOption("optTimer2Intr_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer2Intr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer2Intr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optTimer2Intr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraADCIntr", 4820, 2640, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraADCIntr").BorderStyle = 0
               If (Not ps.AddOption("optADCIntr_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optADCIntr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optADCIntr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optADCIntr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraSSCIntr", 4820, 2960, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraSSCIntr").BorderStyle = 0
               If (Not ps.AddOption("optSSCIntr_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optSSCIntr_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optSSCIntr_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optSSCIntr_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraExtIntr2", 4820, 3270, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraExtIntr2").BorderStyle = 0
               If (Not ps.AddOption("optExtIntr2_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr2_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr2_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr2_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraExtIntr6-3", 4820, 3590, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraExtIntr6-3").BorderStyle = 0
               If (Not ps.AddOption("optExtIntr6-3_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr6-3_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr6-3_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optExtIntr6-3_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraCCU6IntrNode0", 4820, 3900, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraCCU6IntrNode0").BorderStyle = 0
               If (Not ps.AddOption("optCCU6IntrNode0_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode0_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode0_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode0_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraCCU6IntrNode1", 4820, 4220, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraCCU6IntrNode1").BorderStyle = 0
               If (Not ps.AddOption("optCCU6IntrNode1_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode1_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode1_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode1_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraCCU6IntrNode2", 4820, 4530, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraCCU6IntrNode2").BorderStyle = 0
               If (Not ps.AddOption("optCCU6IntrNode2_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode2_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode2_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode2_3", 3400, 60, 200, 110, "")) Then Exit Function

            If (Not ps.AddFrame("fraCCU6IntrNode3", 4820, 4850, 3800, 300)) Then Exit Function
            ps.ControlCollection("fraCCU6IntrNode3").BorderStyle = 0
               If (Not ps.AddOption("optCCU6IntrNode3_0", 100, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode3_1", 1250, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode3_2", 2400, 60, 200, 110, "")) Then Exit Function
               If (Not ps.AddOption("optCCU6IntrNode3_3", 3400, 60, 200, 110, "")) Then Exit Function

           
End If

  OnChangingPageInterrupts = True
  Exit Function
  
ErrorInterrupts:
    errorbox "Error OnchangingPage Interrupts", Err.Description
End Function

'*****************************************************************************
' @bfunc   Public | OnShowPageInterrupts | Boolean |
'
'-----------------------------------------------------------------------------
'          This function makes all activities for the interrupt page in each
'          module function OnShow.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    False| if an error has been occured in the function
' @flag    True|  else
'
'-----------------------------------------------------------------------------
' @bparm   | ps | Peripherals | reference to this object
' @bparm   | Controlname | String | current control name
' @bparm   | v() | Variant | values for the controls
' @bparm   | Pagename | String | current page name
'
'*****************************************************************************
Public Function OnShowPageInterrupts(ps As Peripherals, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo ErrorOnShowInterrupts
  
  OnShowPageInterrupts = False
  
  Dim r As Object
  Dim c As Object
  Dim e As Object
  Dim i As Integer
  Dim bDisabled As Boolean
  
  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection

  If (Pagename = "Interrupts") Then
  
    '-------------------------------------------------------------------------
    ' page: interruptpage (action)
    '-------------------------------------------------------------------------
    Select Case Controlname
        '---------------------------------------------------------------------
        ' External Interrupt 0
        '---------------------------------------------------------------------
        Case "optExtInt0_0"
             r.l(CORE_PREFIX & "IP_PX0") = 0
             r.l(CORE_PREFIX & "IPH_PX0H") = 0

        Case "optExtInt0_1"
             r.v(CORE_PREFIX & "IP_PX0") = 1
             r.v(CORE_PREFIX & "IPH_PX0H") = 0

        Case "optExtInt0_2"
             r.v(CORE_PREFIX & "IP_PX0") = 0
             r.v(CORE_PREFIX & "IPH_PX0H") = 1

        Case "optExtInt0_3"
             r.v(CORE_PREFIX & "IP_PX0") = 1
             r.v(CORE_PREFIX & "IPH_PX0H") = 1

        '---------------------------------------------------------------------
        ' Timer 0 Interrupt
        '---------------------------------------------------------------------
        Case "optTimer0Intr_0"
             r.v(CORE_PREFIX & "IP_PT0") = 0
             r.v(CORE_PREFIX & "IPH_PT0H") = 0

        Case "optTimer0Intr_1"
             r.v(CORE_PREFIX & "IP_PT0") = 1
             r.v(CORE_PREFIX & "IPH_PT0H") = 0

        Case "optTimer0Intr_2"
             r.v(CORE_PREFIX & "IP_PT0") = 0
             r.v(CORE_PREFIX & "IPH_PT0H") = 1

        Case "optTimer0Intr_3"
             r.v(CORE_PREFIX & "IP_PT0") = 1
             r.v(CORE_PREFIX & "IPH_PT0H") = 1

        '---------------------------------------------------------------------
        ' External Interrupt 1
        '---------------------------------------------------------------------
        Case "optExtIntr1_0"
             r.v(CORE_PREFIX & "IP_PX1") = 0
             r.v(CORE_PREFIX & "IPH_PX1H") = 0

        Case "optExtIntr1_1"
             r.v(CORE_PREFIX & "IP_PX1") = 1
             r.v(CORE_PREFIX & "IPH_PX1H") = 0

        Case "optExtIntr1_2"
             r.v(CORE_PREFIX & "IP_PX1") = 0
             r.v(CORE_PREFIX & "IPH_PX1H") = 1

        Case "optExtIntr1_3"
             r.v(CORE_PREFIX & "IP_PX1") = 1
             r.v(CORE_PREFIX & "IPH_PX1H") = 1

        '---------------------------------------------------------------------
        ' Timer 1 Interrupt
        '---------------------------------------------------------------------
        Case "optTimer1Intr_0"
             r.v(CORE_PREFIX & "IP_PT1") = 0
             r.v(CORE_PREFIX & "IPH_PT1H") = 0

        Case "optTimer1Intr_1"
             r.v(CORE_PREFIX & "IP_PT1") = 1
             r.v(CORE_PREFIX & "IPH_PT1H") = 0

        Case "optTimer1Intr_2"
             r.v(CORE_PREFIX & "IP_PT1") = 0
             r.v(CORE_PREFIX & "IPH_PT1H") = 1

        Case "optTimer1Intr_3"
             r.v(CORE_PREFIX & "IP_PT1") = 1
             r.v(CORE_PREFIX & "IPH_PT1H") = 1

        '---------------------------------------------------------------------
        ' UART Interrupt
        '---------------------------------------------------------------------
        Case "optUARTIntr_0"
            r.v(CORE_PREFIX & "IP_PS") = 0
            r.v(CORE_PREFIX & "IPH_PSH") = 0

        Case "optUARTIntr_1"
            r.v(CORE_PREFIX & "IP_PS") = 1
            r.v(CORE_PREFIX & "IPH_PSH") = 0

        Case "optUARTIntr_2"
            r.v(CORE_PREFIX & "IP_PS") = 0
            r.v(CORE_PREFIX & "IPH_PSH") = 1

        Case "optUARTIntr_3"
            r.v(CORE_PREFIX & "IP_PS") = 1
            r.v(CORE_PREFIX & "IPH_PSH") = 1

        '---------------------------------------------------------------------
        ' Timer 2 Interrupt
        '---------------------------------------------------------------------
        Case "optTimer2Intr_0"
            r.v(CORE_PREFIX & "IP_PT2") = 0
            r.v(CORE_PREFIX & "IPH_PT2H") = 0

        Case "optTimer2Intr_1"
            r.v(CORE_PREFIX & "IP_PT2") = 1
            r.v(CORE_PREFIX & "IPH_PT2H") = 0

        Case "optTimer2Intr_2"
            r.v(CORE_PREFIX & "IP_PT2") = 0
            r.v(CORE_PREFIX & "IPH_PT2H") = 1

        Case "optTimer2Intr_3"
            r.v(CORE_PREFIX & "IP_PT2") = 1
            r.v(CORE_PREFIX & "IPH_PT2H") = 1

        '---------------------------------------------------------------------
        ' ADC Interrupt
        '---------------------------------------------------------------------
        Case "optADCIntr_0"
            r.v(CORE_PREFIX & "IP1_PADC") = 0
            r.v(CORE_PREFIX & "IPH1_PADCH") = 0

        Case "optADCIntr_1"
            r.v(CORE_PREFIX & "IP1_PADC") = 1
            r.v(CORE_PREFIX & "IPH1_PADCH") = 0

        Case "optADCIntr_2"
            r.v(CORE_PREFIX & "IP1_PADC") = 0
            r.v(CORE_PREFIX & "IPH1_PADCH") = 1

        Case "optADCIntr_3"
            r.v(CORE_PREFIX & "IP1_PADC") = 1
            r.v(CORE_PREFIX & "IPH1_PADCH") = 1

        '---------------------------------------------------------------------
        ' SSC Interrupt
        '---------------------------------------------------------------------
        Case "optSSCIntr_0"
            r.v(CORE_PREFIX & "IP1_PSSC") = 0
            r.v(CORE_PREFIX & "IPH1_PSSCH") = 0

        Case "optSSCIntr_1"
            r.v(CORE_PREFIX & "IP1_PSSC") = 1
            r.v(CORE_PREFIX & "IPH1_PSSCH") = 0

        Case "optSSCIntr_2"
            r.v(CORE_PREFIX & "IP1_PSSC") = 0
            r.v(CORE_PREFIX & "IPH1_PSSCH") = 1

        Case "optSSCIntr_3"
            r.v(CORE_PREFIX & "IP1_PSSC") = 1
            r.v(CORE_PREFIX & "IPH1_PSSCH") = 1

        '---------------------------------------------------------------------
        ' External Interrupt 2
        '---------------------------------------------------------------------
        Case "optExtIntr2_0"
            r.v(CORE_PREFIX & "IP1_PX2") = 0
            r.v(CORE_PREFIX & "IPH1_PX2H") = 0

        Case "optExtIntr2_1"
            r.v(CORE_PREFIX & "IP1_PX2") = 1
            r.v(CORE_PREFIX & "IPH1_PX2H") = 0

        Case "optExtIntr2_2"
            r.v(CORE_PREFIX & "IP1_PX2") = 0
            r.v(CORE_PREFIX & "IPH1_PX2H") = 1

        Case "optExtIntr2_3"
            r.v(CORE_PREFIX & "IP1_PX2") = 1
            r.v(CORE_PREFIX & "IPH1_PX2H") = 1

        '---------------------------------------------------------------------
        ' External Interrupt [6:3]
        '---------------------------------------------------------------------
        Case "optExtIntr6-3_0"
            r.v(CORE_PREFIX & "IP1_PXM") = 0
            r.v(CORE_PREFIX & "IPH1_PXMH") = 0

        Case "optExtIntr6-3_1"
            r.v(CORE_PREFIX & "IP1_PXM") = 1
            r.v(CORE_PREFIX & "IPH1_PXMH") = 0

        Case "optExtIntr6-3_2"
            r.v(CORE_PREFIX & "IP1_PXM") = 0
            r.v(CORE_PREFIX & "IPH1_PXMH") = 1

        Case "optExtIntr6-3_3"
            r.v(CORE_PREFIX & "IP1_PXM") = 1
            r.v(CORE_PREFIX & "IPH1_PXMH") = 1

        '---------------------------------------------------------------------
        ' CCU6 Interrupt Node Pointer 0
        '---------------------------------------------------------------------
        Case "optCCU6IntrNode0_0"
            r.v(CORE_PREFIX & "IP1_PCCIP0") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0

        Case "optCCU6IntrNode0_1"
            r.v(CORE_PREFIX & "IP1_PCCIP0") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0

        Case "optCCU6IntrNode0_2"
            r.v(CORE_PREFIX & "IP1_PCCIP0") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 1

        Case "optCCU6IntrNode0_3"
            r.v(CORE_PREFIX & "IP1_PCCIP0") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 1

        '---------------------------------------------------------------------
        ' CCU6 Interrupt Node Pointer 1
        '---------------------------------------------------------------------
        Case "optCCU6IntrNode1_0"
            r.v(CORE_PREFIX & "IP1_PCCIP1") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0

        Case "optCCU6IntrNode1_1"
            r.v(CORE_PREFIX & "IP1_PCCIP1") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0

        Case "optCCU6IntrNode1_2"
            r.v(CORE_PREFIX & "IP1_PCCIP1") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 1

        Case "optCCU6IntrNode1_3"
            r.v(CORE_PREFIX & "IP1_PCCIP1") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 1

        '---------------------------------------------------------------------
        ' CCU6 Interrupt Node Pointer 2
        '---------------------------------------------------------------------
        Case "optCCU6IntrNode2_0"
            r.v(CORE_PREFIX & "IP1_PCCIP2") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0

        Case "optCCU6IntrNode2_1"
            r.v(CORE_PREFIX & "IP1_PCCIP2") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0

        Case "optCCU6IntrNode2_2"
            r.v(CORE_PREFIX & "IP1_PCCIP2") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 1

        Case "optCCU6IntrNode2_3"
            r.v(CORE_PREFIX & "IP1_PCCIP2") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 1

        '----------------------------------------------------------------
        ' CCU6 Interrupt Node Pointer 3
        '---------------------------------------------------------------------
        Case "optCCU6IntrNode3_0"
            r.v(CORE_PREFIX & "IP1_PCCIP3") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0

        Case "optCCU6IntrNode3_1"
            r.v(CORE_PREFIX & "IP1_PCCIP3") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0

        Case "optCCU6IntrNode3_2"
            r.v(CORE_PREFIX & "IP1_PCCIP3") = 0
            r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 1

        Case "optCCU6IntrNode3_3"
            r.v(CORE_PREFIX & "IP1_PCCIP3") = 1
            r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 1

    End Select
    
    '-------------------------------------------------------------------------
    ' page: interruptpage (show)
    '-------------------------------------------------------------------------
        
    '-------------------------------------------------------------------------
    ' External Interrupt 0
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN0_EX0") = 0) And Not (r.v(CORE_PREFIX & "IP_PX0") = 0 And r.v(CORE_PREFIX & "IPH_PX0H") = 0) Then
        r.v(CORE_PREFIX & "IP_PX0") = 0
        r.v(CORE_PREFIX & "IPH_PX0H") = 0
    End If

    With c("optExtInt0_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX0") = 0) And (r.v(CORE_PREFIX & "IPH_PX0H") = 0))
    End With

    With e("optExtInt0_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With
    
    With c("optExtInt0_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX0") = 1) And (r.v(CORE_PREFIX & "IPH_PX0H") = 0))
    End With

    With e("optExtInt0_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtInt0_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX0") = 0) And (r.v(CORE_PREFIX & "IPH_PX0H") = 1))
    End With

    With e("optExtInt0_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtInt0_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX0") = 1) And (r.v(CORE_PREFIX & "IPH_PX0H") = 1))
    End With

    With e("optExtInt0_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '-------------------------------------------------------------------------
    ' Timer 0 Interrupt
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN0_ET0") = 0) And Not (r.v(CORE_PREFIX & "IP_PT0") = 0 And r.v(CORE_PREFIX & "IPH_PT0H") = 0) Then
        r.v(CORE_PREFIX & "IP_PT0") = 0
        r.v(CORE_PREFIX & "IPH_PT0H") = 0
    End If

    With c("optTimer0Intr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT0") = 0) And (r.v(CORE_PREFIX & "IPH_PT0H") = 0))
    End With

    With e("optTimer0Intr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer0Intr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT0") = 1) And (r.v(CORE_PREFIX & "IPH_PT0H") = 0))
    End With

    With e("optTimer0Intr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer0Intr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET0") = 0)
       .Enabled = Not bDisabled
       .Value = ((r.v(CORE_PREFIX & "IP_PT0") = 0) And (r.v(CORE_PREFIX & "IPH_PT0H") = 1))
    End With

    With e("optTimer0Intr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer0Intr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT0") = 1) And (r.v(CORE_PREFIX & "IPH_PT0H") = 1))
    End With

    With e("optTimer0Intr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '-------------------------------------------------------------------------
    ' External Interrupt 1
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN0_EX1") = 0) And Not (r.v(CORE_PREFIX & "IP_PX1") = 0 And r.v(CORE_PREFIX & "IPH_PX1H") = 0) Then
        r.v(CORE_PREFIX & "IP_PX1") = 0
        r.v(CORE_PREFIX & "IPH_PX1H") = 0
    End If

     With c("optExtIntr1_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX1") = 0) And (r.v(CORE_PREFIX & "IPH_PX1H") = 0))
    End With

    With e("optExtIntr1_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr1_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX1") = 1) And (r.v(CORE_PREFIX & "IPH_PX1H") = 0))
    End With

    With e("optExtIntr1_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr1_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX1") = 0) And (r.v(CORE_PREFIX & "IPH_PX1H") = 1))
    End With

    With e("optExtIntr1_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr1_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_EX1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PX1") = 1) And (r.v(CORE_PREFIX & "IPH_PX1H") = 1))
    End With

    With e("optExtIntr1_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '-------------------------------------------------------------------------
    ' Timer 1 Interrupt
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN0_ET1") = 0) And Not (r.v(CORE_PREFIX & "IP_PT1") = 0 And r.v(CORE_PREFIX & "IPH_PT1H") = 0) Then
        r.v(CORE_PREFIX & "IP_PT1") = 0
        r.v(CORE_PREFIX & "IPH_PT1H") = 0
    End If

     With c("optTimer1Intr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT1") = 0) And (r.v(CORE_PREFIX & "IPH_PT1H") = 0))
    End With

    With e("optTimer1Intr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer1Intr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT1") = 1) And (r.v(CORE_PREFIX & "IPH_PT1H") = 0))
    End With

    With e("optTimer1Intr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer1Intr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT1") = 0) And (r.v(CORE_PREFIX & "IPH_PT1H") = 1))
    End With

    With e("optTimer1Intr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer1Intr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET1") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT1") = 1) And (r.v(CORE_PREFIX & "IPH_PT1H") = 1))
    End With

    With e("optTimer1Intr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '-------------------------------------------------------------------------
    ' UART Interrupt
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN0_ES") = 0) And Not (r.v(CORE_PREFIX & "IP_PS") = 0 And r.v(CORE_PREFIX & "IPH_PSH") = 0) Then
        r.v(CORE_PREFIX & "IP_PS") = 0
        r.v(CORE_PREFIX & "IPH_PSH") = 0
    End If

    With c("optUARTIntr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ES") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PS") = 0) And (r.v(CORE_PREFIX & "IPH_PSH") = 0))
    End With

    With e("optUARTIntr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optUARTIntr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ES") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PS") = 1) And (r.v(CORE_PREFIX & "IPH_PSH") = 0))
    End With

    With e("optUARTIntr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optUARTIntr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ES") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PS") = 0) And (r.v(CORE_PREFIX & "IPH_PSH") = 1))
    End With

    With e("optUARTIntr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optUARTIntr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ES") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PS") = 1) And (r.v(CORE_PREFIX & "IPH_PSH") = 1))
    End With

    With e("optUARTIntr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


    '-------------------------------------------------------------------------
    ' Timer 2 Interrupt
    '-------------------------------------------------------------------------
    If ((r.v(CORE_PREFIX & "IEN0_ET2") = 0) And (r.v("BRG_Interrupt_Select") = 0) And (r.v("CAN_USE_SRN0") = 0)) And Not (r.v(CORE_PREFIX & "IP_PT2") = 0 And r.v(CORE_PREFIX & "IPH_PT2H") = 0) Then
        r.v(CORE_PREFIX & "IP_PT2") = 0
        r.v(CORE_PREFIX & "IPH_PT2H") = 0
    End If

     With c("optTimer2Intr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET2") = 0 And r.v("BRG_Interrupt_Select") = 0) And (r.v("CAN_USE_SRN0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT2") = 0) And (r.v(CORE_PREFIX & "IPH_PT2H") = 0))
    End With

    With e("optTimer2Intr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer2Intr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET2") = 0 And r.v("BRG_Interrupt_Select") = 0) And (r.v("CAN_USE_SRN0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT2") = 1) And (r.v(CORE_PREFIX & "IPH_PT2H") = 0))
    End With

    With e("optTimer2Intr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer2Intr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET2") = 0 And r.v("BRG_Interrupt_Select") = 0) And (r.v("CAN_USE_SRN0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT2") = 0) And (r.v(CORE_PREFIX & "IPH_PT2H") = 1))
    End With

    With e("optTimer2Intr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optTimer2Intr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN0_ET2") = 0 And r.v("BRG_Interrupt_Select") = 0) And (r.v("CAN_USE_SRN0") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP_PT2") = 1) And (r.v(CORE_PREFIX & "IPH_PT2H") = 1))
    End With

    With e("optTimer2Intr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


    '-------------------------------------------------------------------------
    ' ADC Interrupt
    '-------------------------------------------------------------------------
    If ((r.v(CORE_PREFIX & "IEN1_EADC") = 0) And (r.v("CAN_USE_SRN1") = 0) And (r.v("CAN_USE_SRN2") = 0)) And Not ((r.v(CORE_PREFIX & "IP1_PADC") = 0) And (r.v(CORE_PREFIX & "IPH1_PADCH") = 0)) Then
        r.v(CORE_PREFIX & "IP1_PADC") = 0
        r.v(CORE_PREFIX & "IPH1_PADCH") = 0
    End If

     With c("optADCIntr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EADC") = 0) And (r.v("CAN_USE_SRN1") = 0) And (r.v("CAN_USE_SRN2") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PADC") = 0) And (r.v(CORE_PREFIX & "IPH1_PADCH") = 0))
    End With

    With e("optADCIntr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optADCIntr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EADC") = 0) And (r.v("CAN_USE_SRN1") = 0) And (r.v("CAN_USE_SRN2") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PADC") = 1) And (r.v(CORE_PREFIX & "IPH1_PADCH") = 0))
    End With

    With e("optADCIntr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optADCIntr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EADC") = 0) And (r.v("CAN_USE_SRN1") = 0) And (r.v("CAN_USE_SRN2") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PADC") = 0) And (r.v(CORE_PREFIX & "IPH1_PADCH") = 1))
    End With

    With e("optADCIntr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optADCIntr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EADC") = 0) And (r.v("CAN_USE_SRN1") = 0) And (r.v("CAN_USE_SRN2") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PADC") = 1) And (r.v(CORE_PREFIX & "IPH1_PADCH") = 1))
    End With

    With e("optADCIntr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


     '-------------------------------------------------------------------------
     ' SSC Interrupt
     '-------------------------------------------------------------------------
     If (r.v(CORE_PREFIX & "IEN1_ESSC") = 0) And Not (r.v(CORE_PREFIX & "IP1_PSSC") = 0 And r.v(CORE_PREFIX & "IPH1_PSSCH") = 0) Then
        r.v(CORE_PREFIX & "IP1_PSSC") = 0
        r.v(CORE_PREFIX & "IPH1_PSSCH") = 0
     End If

     With c("optSSCIntr_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ESSC") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PSSC") = 0) And (r.v(CORE_PREFIX & "IPH1_PSSCH") = 0))
    End With

    With e("optSSCIntr_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optSSCIntr_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ESSC") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PSSC") = 1) And (r.v(CORE_PREFIX & "IPH1_PSSCH") = 0))
    End With

    With e("optSSCIntr_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optSSCIntr_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ESSC") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PSSC") = 0) And (r.v(CORE_PREFIX & "IPH1_PSSCH") = 1))
    End With

    With e("optSSCIntr_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optSSCIntr_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ESSC") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PSSC") = 1) And (r.v(CORE_PREFIX & "IPH1_PSSCH") = 1))
    End With

    With e("optSSCIntr_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '---------------------------------------------------------------------
    ' External Interrupt 2
    '---------------------------------------------------------------------
     If ((r.v(CORE_PREFIX & "IEN1_EX2") = 0) And (r.v("T21_Interrupt_Select") = 0) And (r.v("UART1_Interrupt_Select") = 0) And (r.v("BRG1_Interrupt_Select") = 0)) And Not (r.v(CORE_PREFIX & "IP1_PX2") = 0 And r.v(CORE_PREFIX & "IPH1_PX2H") = 0) Then
        r.v(CORE_PREFIX & "IP1_PX2") = 0
        r.v(CORE_PREFIX & "IPH1_PX2H") = 0
     End If
     
     With c("optExtIntr2_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EX2") = 0) And (r.v("T21_Interrupt_Select") = 0) And (r.v("UART1_Interrupt_Select") = 0) And (r.v("BRG1_Interrupt_Select") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PX2") = 0) And (r.v(CORE_PREFIX & "IPH1_PX2H") = 0))
    End With

    With e("optExtIntr2_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr2_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EX2") = 0) And (r.v("T21_Interrupt_Select") = 0) And (r.v("UART1_Interrupt_Select") = 0) And (r.v("BRG1_Interrupt_Select") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PX2") = 1) And (r.v(CORE_PREFIX & "IPH1_PX2H") = 0))
    End With

    With e("optExtIntr2_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr2_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EX2") = 0) And (r.v("T21_Interrupt_Select") = 0) And (r.v("UART1_Interrupt_Select") = 0) And (r.v("BRG1_Interrupt_Select") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PX2") = 0) And (r.v(CORE_PREFIX & "IPH1_PX2H") = 1))
    End With

    With e("optExtIntr2_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr2_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EX2") = 0) And (r.v("T21_Interrupt_Select") = 0) And (r.v("UART1_Interrupt_Select") = 0) And (r.v("BRG1_Interrupt_Select") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PX2") = 1) And (r.v(CORE_PREFIX & "IPH1_PX2H") = 1))
    End With

    With e("optExtIntr2_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


    '---------------------------------------------------------------------
    ' External Interrupt [6:3]
    '---------------------------------------------------------------------
     If (r.v(CORE_PREFIX & "IEN1_EXM") = 0) And (r.v("CAN_USE_SRN3") = 0) And Not (r.v(CORE_PREFIX & "IP1_PXM") = 0 And r.v(CORE_PREFIX & "IPH1_PXMH") = 0) Then
        r.v(CORE_PREFIX & "IP1_PXM") = 0
        r.v(CORE_PREFIX & "IPH1_PXMH") = 0
     End If

     With c("optExtIntr6-3_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EXM") = 0) And (r.v("CAN_USE_SRN3") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PXM") = 0) And (r.v(CORE_PREFIX & "IPH1_PXMH") = 0))
    End With

    With e("optExtIntr6-3_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr6-3_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EXM") = 0) And (r.v("CAN_USE_SRN3") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PXM") = 1) And (r.v(CORE_PREFIX & "IPH1_PXMH") = 0))
    End With

    With e("optExtIntr6-3_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr6-3_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EXM") = 0) And (r.v("CAN_USE_SRN3") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PXM") = 0) And (r.v(CORE_PREFIX & "IPH1_PXMH") = 1))
    End With

    With e("optExtIntr6-3_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optExtIntr6-3_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_EXM") = 0) And (r.v("CAN_USE_SRN3") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PXM") = 1) And (r.v(CORE_PREFIX & "IPH1_PXMH") = 1))
    End With

    With e("optExtIntr6-3_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '---------------------------------------------------------------------
    ' CCU6 Interrupt Node Pointer 0
    '---------------------------------------------------------------------
     If (r.v(CORE_PREFIX & "IEN1_ECCIP0") = 0) And (r.v("CAN_USE_SRN4") = 0) And Not (r.v(CORE_PREFIX & "IP1_PCCIP0") = 0 And r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0) Then
        r.v(CORE_PREFIX & "IP1_PCCIP0") = 0
        r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0
     End If

     With c("optCCU6IntrNode0_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP0") = 0) And (r.v("CAN_USE_SRN4") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP0") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0))
    End With

    With e("optCCU6IntrNode0_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode0_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP0") = 0) And (r.v("CAN_USE_SRN4") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP0") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 0))
    End With

    With e("optCCU6IntrNode0_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode0_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP0") = 0) And (r.v("CAN_USE_SRN4") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP0") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 1))
    End With

    With e("optCCU6IntrNode0_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode0_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP0") = 0) And (r.v("CAN_USE_SRN4") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP0") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP0H") = 1))
    End With

    With e("optCCU6IntrNode0_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


    '-------------------------------------------------------------------------
    '   CCU6 Interrupt Node Pointer 1
    '-------------------------------------------------------------------------
     If (r.v(CORE_PREFIX & "IEN1_ECCIP1") = 0) And (r.v("CAN_USE_SRN5") = 0) And Not (r.v(CORE_PREFIX & "IP1_PCCIP1") = 0 And r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0) Then
        r.v(CORE_PREFIX & "IP1_PCCIP1") = 0
        r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0
     End If

     With c("optCCU6IntrNode1_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP1") = 0) And (r.v("CAN_USE_SRN5") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP1") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0))
    End With

    With e("optCCU6IntrNode1_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode1_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP1") = 0) And (r.v("CAN_USE_SRN5") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP1") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 0))
    End With

    With e("optCCU6IntrNode1_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode1_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP1") = 0) And (r.v("CAN_USE_SRN5") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP1") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 1))
    End With

    With e("optCCU6IntrNode1_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode1_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP1") = 0) And (r.v("CAN_USE_SRN5") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP1") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP1H") = 1))
    End With

    With e("optCCU6IntrNode1_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    '-------------------------------------------------------------------------
    '   CCU6 Interrupt Node Pointer 2
    '-------------------------------------------------------------------------
     If (r.v(CORE_PREFIX & "IEN1_ECCIP2") = 0) And (r.v("CAN_USE_SRN6") = 0) And Not (r.v(CORE_PREFIX & "IP1_PCCIP2") = 0 And r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0) Then
        r.v(CORE_PREFIX & "IP1_PCCIP2") = 0
        r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0
     End If

     With c("optCCU6IntrNode2_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP2") = 0) And (r.v("CAN_USE_SRN6") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP2") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0))
    End With

    With e("optCCU6IntrNode2_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode2_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP2") = 0) And (r.v("CAN_USE_SRN6") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP2") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 0))
    End With

    With e("optCCU6IntrNode2_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode2_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP2") = 0) And (r.v("CAN_USE_SRN6") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP2") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 1))
    End With

    With e("optCCU6IntrNode2_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode2_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP2") = 0) And (r.v("CAN_USE_SRN6") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP2") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP2H") = 1))
    End With

    With e("optCCU6IntrNode2_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With


    '-------------------------------------------------------------------------
    ' CCU6 Interrupt Node Pointer 3
    '-------------------------------------------------------------------------
    If (r.v(CORE_PREFIX & "IEN1_ECCIP3") = 0) And (r.v("CAN_USE_SRN7") = 0) And Not (r.v(CORE_PREFIX & "IP1_PCCIP3") = 0 And r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0) Then
        r.v(CORE_PREFIX & "IP1_PCCIP3") = 0
        r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0
    End If

     With c("optCCU6IntrNode3_0")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP3") = 0) And (r.v("CAN_USE_SRN7") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP3") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0))
    End With

    With e("optCCU6IntrNode3_0")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode3_1")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP3") = 0) And (r.v("CAN_USE_SRN7") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP3") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 0))
    End With

    With e("optCCU6IntrNode3_1")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode3_2")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP3") = 0) And (r.v("CAN_USE_SRN7") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP3") = 0) And (r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 1))
    End With

    With e("optCCU6IntrNode3_2")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

    With c("optCCU6IntrNode3_3")
        bDisabled = (r.v(CORE_PREFIX & "IEN1_ECCIP3") = 0) And (r.v("CAN_USE_SRN7") = 0)
        .Enabled = Not bDisabled
        .Value = ((r.v(CORE_PREFIX & "IP1_PCCIP3") = 1) And (r.v(CORE_PREFIX & "IPH1_PCCIP3H") = 1))
    End With

    With e("optCCU6IntrNode3_3")
        If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledToolTip(TOOLTIP_MODULE_NOT_USED)
        End If
    End With

  End If

  OnShowPageInterrupts = True
  Exit Function
  
ErrorOnShowInterrupts:
    errorbox "Error OnshowPage Interrupts", Err.Description
  
End Function

'*****************************************************************************
'Description:
'        This function initializes the menu of the Peripherals window.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        sScriptName     name of the script for which the menu should be added
'                        (e.g. "SSCx\Dialog")
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function InitMenu(ps As Peripherals, sScriptName As String) As Boolean
        On Error GoTo InitMenuError
    
    Dim ts As Tool
    Dim bs As Band
    Dim bsMain As Band
    Dim pic As Object
    Dim i As Long
    Dim l As Long
    Dim m As Object
    
    
    InitMenu = False
    
    Set m = ObjectCollection("MANUALLINKS")
    
    ' add toolbar band
    Set bsMain = ps.Menu.Bands.Add("MainBand")
    
        
    bsMain.Caption = "DAvE Tools"
    bsMain.Type = DDBTNormal
    bsMain.flags = DDBFFixed
    
        
    'close
    Set pic = LoadBitmap(DefGetPath("Icons") & "CLOSE.BMP")
    If (IsNull(pic)) Then Exit Function

    Set ts = bsMain.Tools.Add(1, "Close")
    ts.SetPicture Index:=0, Picture:=pic, Color:=QBColor(5)
    ts.ToolTipText = "Close this window"

    ' info
    Set pic = LoadBitmap(DefGetPath("Icons") & "INFO.BMP")
    If (IsNull(pic)) Then Exit Function

    Set ts = bsMain.Tools.Add(2, "Info")
    ts.SetPicture Index:=0, Picture:=pic, Color:=QBColor(5)
    ts.ControlType = DDTTButtonDropDown
    ts.SubBand = "Info"
    ts.ToolTipText = "Documentation"
    ts.BeginGroup = True
    Set bs = ps.Menu.Bands.Add("Info")
    bs.Type = DDBTPopup

    ' manuals
    Set pic = LoadBitmap(DefGetPath("Icons") & "DOC.BMP")
    If (IsNull(pic)) Then Exit Function

    For l = 1 To m.MenuCounter()
      If (m.ScriptName(l) = sScriptName) Then
        For i = 1 To m.LinkCounter(l)
          Set ts = bs.Tools.Add(i, "Doc")
          ts.Caption = m.LinkName(l, i)
          ts.Text = m.KeyName(l, i)
          ts.SetPicture Index:=0, Picture:=pic, Color:=QBColor(5)
                ts.BeginGroup = m.Group(l, i)
        Next i
        Exit For
      End If
    Next l

    ' help
    Set pic = LoadBitmap(DefGetPath("Icons") & "HELP.BMP")
    If (IsNull(pic)) Then Exit Function

    Set ts = bsMain.Tools.Add(3, "Help")
    ts.BeginGroup = True
    ts.SetPicture Index:=0, Picture:=pic, Color:=QBColor(5)
    ts.ToolTipText = "Help"

    ps.Menu.RecalcLayout
    
    InitMenu = True
    Exit Function

InitMenuError:
  errorbox "Can not load the menu", Err.Description
  Exit Function
End Function

'*****************************************************************************
'Description:
'        This function is called if the user clicks on a menu entry.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Toolname        name of the entry
'        ToolId          id of the entry
'        Tooltext        additional text of the entry
'        sScriptName     name of the script for which the menu should be added
'                        (e.g. "SSCx\Dialog")
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function MenuClick(ps As Peripherals, Toolname As String, ToolId As Long, Tooltext As String, sScriptName As String) As Boolean
    On Error GoTo MenuClickError
    Dim i As Long
    Dim l As Long
    Dim m As Object

    MenuClick = False
    Set m = ObjectCollection("MANUALLINKS")

    Select Case Toolname
        Case "Close"
            ps.Terminate
            
        Case "Info"
            UserMessage FormatMessageBoxText(MSG_DOCU_BUTTON)
            
        Case "Help"
           HelpContext 1008
           
        Case "Doc"
            For l = 1 To m.MenuCounter()
              If (m.ScriptName(l) = sScriptName) Then
                For i = 1 To m.LinkCounter(l)
                  If (Tooltext = m.KeyName(l, i)) Then
                    Call ShowDocument(m.DefSection(l, i), Tooltext)
                    Exit For
                  End If
                Next i
                Exit For
              End If
            Next l
            
    End Select

    MenuClick = True
    Exit Function

MenuClickError:
    Exit Function
End Function


