'#Uses "..\classes\FunctionClass.cls"
'#Uses "..\classes\ParameterClass.cls"
'#Uses "..\include\Const.inc"
'#Uses "..\include\Format.inc"
'#Uses "..\include\Global.inc"
'#Uses "..\include\Pages.inc"
'#Uses "..\include\Port.inc"
'#Uses "Include.inc"
Option Explicit
'*****************************************************************************
' Module:
'        GPT1
'-----------------------------------------------------------------------------
' Description:
'        This file contains functions which are create controls for the
'        module 'GPT1'.
'        Furthermore it contains functions for the event handling of
'        these controls.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        1.0  ahe            27.04.00     final version for C165UTAH, C165H
'
'        ----------------------------------------------------------------------
'        1.1  ahe            28.09.00     final version for C165UTAH, C165H
'                                         - changes disabled condition for TxUD
' 
'        ----------------------------------------------------------------------
'        4.0  ahe            19.04.01     final version for Pegasus
'                                         - prefix GPT12_ and ... 
'                                         - many changes
'
'        4.1  ahe            08.08.02     - neu interrupt page
'                                         - changed page name
'        4.2  ste            16.12.02     no changes
'        4.3  ste            24.02.03     caption for module clock changed
'
'*****************************************************************************


Const MSG_GPT_DISABLE = "If you disable the module clock the configuration of the GPT1 AND GPT2"  & vbcrlf & _
                        "modules will be reseted. Do you really want to continue ?"


'*****************************************************************************
'Description:    
'        This function is called from DAvE just before the Peripherals
'        window is shown.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnLoad(ps As Peripherals) As Boolean
    On Error GoTo OnLoadError

    OnLoad = False

    '-------------------------------------------------------------------------
    ' page: ModuleClock
    '-------------------------------------------------------------------------
    If (Not OnLoadPageModuleClock(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnLoadPageAuxiliaryTimerx(ps, 2)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: CoreTimer3
    '-------------------------------------------------------------------------
    If (Not OnLoadPageCoreTimer3(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnLoadPageAuxiliaryTimerx(ps, 4)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnLoadPageInterrupts_32(ps, 0)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnLoadPageInterrupts_32(ps, 1)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: PEC
    '-------------------------------------------------------------------------
    If (Not OnLoadPagePEC(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Functions
    '-------------------------------------------------------------------------
    If (Not OnLoadPageFunctions(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Parameters
    '-------------------------------------------------------------------------
    If (Not OnLoadPageParameters(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Notes
    '-------------------------------------------------------------------------
    If (Not OnLoadPageNotes(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' end of pages
    '-------------------------------------------------------------------------
    
    '-------------------------------------------------------------------------
    ' call function to initialize the menu
    '-------------------------------------------------------------------------
    If (Not InitMenu(ps,"GPT1\Dialog")) Then Exit Function

    OnLoad = True
    Exit Function

OnLoadError:
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE just before a page
'        is shown.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Page            no. of the page (starts with 1)
'        Pagename        name of the page
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnChangingPage(ps As Peripherals, Page As Integer, Pagename As String) As Boolean
    On Error Goto OnChangingPageError

    OnChangingPage = False

    '-------------------------------------------------------------------------
    ' page: ModuleClock
    '-------------------------------------------------------------------------
    If (Not OnChangingPageModuleClock (ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnChangingPageAuxiliaryTimerx (ps, Pagename, 2)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: CoreTimer3
    '-------------------------------------------------------------------------
    If (Not OnChangingPageCoreTimer3 (ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnChangingPageAuxiliaryTimerx (ps, Pagename, 4)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnChangingPageInterrupts_32 (ps, Pagename, 0)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnChangingPageInterrupts_32 (ps, Pagename, 1)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: PEC
    '-------------------------------------------------------------------------
    If (Not OnChangingPagePEC (ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Functions
    '-------------------------------------------------------------------------
    If (Not OnChangingPageFunctions (ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Parameters
    '-------------------------------------------------------------------------
    If (Not OnChangingPageParameters (ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Notes
    '-------------------------------------------------------------------------
    If (Not OnChangingPageNotes (ps, Pagename, "GPT1")) Then Exit Function


    OnChangingPage = True
    Exit Function

OnChangingPageError:
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE in two cases:
'
'        1.
'            The contents of the peripherals window must be refreshed.
'            In this case the 'Controlname' parameter is a empty string
'            and the values array 'v()' contains nothing.
'
'        2.
'            A control on the peripherals has been changed.
'            In this case the 'Controlname' parameter contains the name
'            of the changed control and the values array 'v()' contains the
'            changed value(s).
'
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     name of the changed control (for case 2)
'        v()             array with the changed values (for case 2)
'        Page            no. of the page (starts with 1)
'        Pagename        name of the page
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnShow(ps As Peripherals, Controlname As String, v() As Variant, Page As Integer, Pagename As String) As Boolean
    On Error GoTo OnShowError
    Dim sVarPre As String
    sVarPre = "GPT1"

    OnShow = False

    '-------------------------------------------------------------------------
    ' page: ModuleClock
    '-------------------------------------------------------------------------
    If (Not OnShowPageModuleClock(ps, Controlname, Pagename, v)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnShowPageAuxiliaryTimerx(ps, Controlname, Pagename, v, 2)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: CoreTimer3
    '-------------------------------------------------------------------------
    If (Not OnShowPageCoreTimer3(ps, Controlname, Pagename, v)) Then Exit Function
  
    '-------------------------------------------------------------------------
    ' page: AuxiliaryTimerx
    '-------------------------------------------------------------------------
    If (Not OnShowPageAuxiliaryTimerx(ps, Controlname, Pagename, v, 4)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnShowPageInterrupts_32(ps, Controlname, v, sVarPre, Pagename, 0)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnShowPageInterrupts_32(ps, Controlname, v, sVarPre, Pagename, 1)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: PEC
    '-------------------------------------------------------------------------
    If (Not OnShowPagePEC(ps, Controlname, v, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Functions
    '-------------------------------------------------------------------------
    If (Not OnShowPageFunctions(ps, Controlname, Pagename, v)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Parameters
    '-------------------------------------------------------------------------
    If (Not OnShowPageParameters(ps, Controlname, Pagename, v)) Then Exit Function 
       
    '-------------------------------------------------------------------------
    ' page: Notes
    '-------------------------------------------------------------------------
    If (Not OnShowPageNotes(ps, Controlname, Pagename, "GPT1", v)) Then Exit Function


    OnShow = True
    Exit Function

OnShowError:
    Errorbox "Can not show page", Err.Description
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE if the user clicks on a button.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     name of the button
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnClick(ps As Peripherals, Controlname As String) As Boolean
    On Error GoTo OnClickError

    OnClick = False

    Dim np As Peripherals


    '-------------------------------------------------------------------------
    ' buttons: PEC
    '-------------------------------------------------------------------------
    If (Not OnClickPagePEC(ps, Controlname)) Then Exit Function


    OnClick = True
    Exit Function

OnClickError:
    Errorbox "Can not process the click", Err.Description
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE 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
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnMenuClick(ps As Peripherals, Toolname As String, ToolId As Long, Tooltext As String) As Boolean
    On Error GoTo OnMenuClickError

    OnMenuClick = False

    If (Not MenuClick(ps, Toolname, ToolId, Tooltext, "GPT1\Dialog")) Then Exit Function

    OnMenuClick = True
    Exit Function

OnMenuClickError:
    Exit Function
End Function
    

'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add the page 'ModuleClock'.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageModuleClock(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageModuleClock = False

  If (Not ps.AddPage("Module Clock")) Then Exit Function

  OnLoadPageModuleClock = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnChangingPageModuleClock(ps As Object, Pagename As String) As Boolean
  On Error Resume Next

  OnChangingPageModuleClock = False
  Dim sVarPre As String
  Dim r       As ProjectData

  sVarPre = "GPT1"
  
  Set r = ps.ProjectData
  
  If (Not ps.ExtenderCollection("Module Clock").Loaded) And (Pagename = "Module Clock") Then
    ps.ExtenderCollection("Module Clock").Loaded = True
  

    '-------------------------------
    ' frame: frmMD
    '-------------------------------
    If (Not ps.AddFrame("frmMD",100,100, 5400, 1375, _
      "GPT Disabled Flag (" & GetGPT1DisebleBitName(r, sVarPre) & ")")) Then Exit Function
        If (Not ps.AddOption("optPERDISx_0", 200, 350, 4800, 380, _
          "Enable GPT1 AND GPT2 modules; the peripherals are supplied with the clock signal")) Then Exit Function
        If (Not ps.AddOption("optPERDISx_1", 200, 825, 4800, 380, _
          "Disable GPT1 AND GPT2 modules; the clock input of peripherals is disabled")) Then Exit Function

    '-------------------------------
    ' frame: frmInputClock
    '-------------------------------
    If (Not ps.AddFrame("frmInputClock",100,1600, 5400, 1000, _
      "Input Clock")) Then Exit Function
        If (Not ps.AddLabel("lbl_txt_InputClock", 0, 200, 450, 3225, 300, _
          "Input clock of the " & sVarPre & " module [MHz]")) Then Exit Function
        If (Not ps.AddLabel("lbl_box_InputClock", 1, 3550, 400, 1000, 300, "")) Then Exit Function

    '-------------------------------
    ' frame: frmBPS1
    '-------------------------------
    If (Not ps.AddFrame("frmBPS1",100,2700, 5400, 2200, _
      "Timer Block Prescaler 1 (BPS1)")) Then Exit Function
        If (Not ps.AddOption("optBPS1_1", 200, 300, 4800, 300, "")) Then Exit Function
        If (Not ps.AddOption("optBPS1_0", 200, 650, 4800, 300, "")) Then Exit Function
        If (Not ps.AddOption("optBPS1_3", 200, 1000, 4800, 300, "")) Then Exit Function
        If (Not ps.AddOption("optBPS1_2", 200, 1350, 4800, 300, "")) Then Exit Function
        If (Not ps.AddLabel("lbl_txt_BPS1", 0, 200, 1750, 4000, 300, "")) Then Exit Function
        If (Not ps.AddLabel("lbl_box_BPS1", 1, 4000, 1700, 1000, 300, "")) Then Exit Function

  End If
  OnChangingPageModuleClock = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnShowPageModuleClock(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageModuleClockError

  OnShowPageModuleClock = False

  Dim r         As ProjectData
  Dim c         As Object
  Dim e         As Object
  Dim sVarPre   As String
  Dim bDisabled As Boolean
  Dim vIndex    As Variant
  Dim TimerNr   As Variant
  Dim i         As Integer
  
  vIndex = ""
  sVarPre = "GPT1"

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

  If (Pagename = "Module Clock") Then
    '-------------------------------------------------------------------------
    ' page: ModuleClock (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: optPERDISx_0 (action)
        '---------------------------------------------------------------------
        Case "optPERDISx_0"
             r.v("SYSCON3_" & GetGPT1DisebleBitName(r, sVarPre)) = 0

        '---------------------------------------------------------------------
        ' control: optPERDISx_1 (action)
        '---------------------------------------------------------------------
        Case "optPERDISx_1"
            If (Ask(MSG_GPT_DISABLE)) Then
                If (Not UpdateOnePeripherals(r, "GPT2", SET_MODULE_TO_DEFAULT)) Then Exit Function
                Call SetModuleToDefault(r)
                r.v("SYSCON3_" & GetGPT1DisebleBitName(r, sVarPre)) = 1

             End If

        '---------------------------------------------------------------------
        ' control: optBPS1_0 (action)
        '---------------------------------------------------------------------
        Case "optBPS1_0"
             r.v(GPT12_ & "T3CON_BPS1") = 0

        '---------------------------------------------------------------------
        ' control: optBPS1_1 (action)
        '---------------------------------------------------------------------
        Case "optBPS1_1"
             r.v(GPT12_ & "T3CON_BPS1") = 1

        '---------------------------------------------------------------------
        ' control: optBPS1_2 (action)
        '---------------------------------------------------------------------
        Case "optBPS1_2"
             r.v(GPT12_ & "T3CON_BPS1") = 2

        '---------------------------------------------------------------------
        ' control: optBPS1_3 (action)
        '---------------------------------------------------------------------
        Case "optBPS1_3"
             r.v(GPT12_ & "T3CON_BPS1") = 3

      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: ModuleClock (show)
    '-------------------------------------------------------------------------

    '-------------------------------------------------------------------------
    ' control: optPERDISx_0 (show)
    '-------------------------------------------------------------------------
    With c("optPERDISx_0")
      bDisabled = False
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v("SYSCON3_" & GetGPT1DisebleBitName(r, sVarPre)) = 0)
    End With

    With e("optPERDISx_0")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("")
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optPERDISx_1 (show)
    '-------------------------------------------------------------------------
    With c("optPERDISx_1")
      bDisabled = False
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v("SYSCON3_" & GetGPT1DisebleBitName(r, sVarPre)) = 1)
    End With

    With e("optPERDISx_1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("")
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_txt_InputClock (show)
    '-------------------------------------------------------------------------
    With c("lbl_txt_InputClock")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
    End With

    With e("lbl_txt_InputClock")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_box_InputClock (show)
    '-------------------------------------------------------------------------
    With c("lbl_box_InputClock")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      If (GetGPT1ModuleClock(r, vIndex) > GetMaxSystemClock(r)) Then
          .Caption = TO_HIGH
      Else
          .Caption = GetGPT1ModuleClock(r, vIndex)
      End If
    End With

    With e("lbl_box_InputClock")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    For i = 0 To 3
        '-------------------------------------------------------------------------
        ' control: optBPS1_0 (show)
        '-------------------------------------------------------------------------
        With c("optBPS1_" & i)
          .Caption = "Prescaler for timer block 1 is " & GetBPS1Factor(i)
          bDisabled = (IsModuleDisabled(r, sVarPre))
          .Enabled = Not(bDisabled)
          .Value = -CInt(r.v(GPT12_ & "T3CON_BPS1") = i)
        End With

        With e("optBPS1_" & i)
          If (bDisabled) Then
            .DisabledTooltipText = TOOLTIP_DISABLED_IF
            If (IsModuleDisabled(r, sVarPre)) Then
              .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
            End If
          End If
        End With
    Next i


    '-------------------------------------------------------------------------
    ' control: lbl_txt_BPS1 (show)
    '-------------------------------------------------------------------------
    With c("lbl_txt_BPS1")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Caption = "Max. input frequency for timer 2/3/4 [MHz]"
    End With

    With e("lbl_txt_BPS1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_box_BPS1 (show)
    '-------------------------------------------------------------------------
    With c("lbl_box_BPS1")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Caption = GetGPT1ModuleClock(r, vIndex)/GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1"))
    End With

    With e("lbl_box_BPS1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With



  End If

  OnShowPageModuleClock = True
  Exit Function

OnShowPageModuleClockError:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add the page 'Auxiliary Timer Tx'.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageAuxiliaryTimerx(ps As Peripherals, TimerNr As Variant) As Boolean
  On Error Resume Next

  OnLoadPageAuxiliaryTimerx = False

  If (Not ps.AddPage("T" & TimerNr)) Then Exit Function

  OnLoadPageAuxiliaryTimerx = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Function OnChangingPageAuxiliaryTimerx(ps As Peripherals, Pagename As String, TimerNr As Variant) As Boolean
  On Error Resume Next
  
  
  

  OnChangingPageAuxiliaryTimerx = False
  
  If (Not ps.ExtenderCollection("T" & TimerNr).Loaded) And (Pagename = "T" & TimerNr) Then
    ps.ExtenderCollection("T" & TimerNr).Loaded = True
  

    '-------------------------------
    ' frame: frmTxM
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "M",100,100, 2750, 4275, _
      "Timer " & TimerNr & " Mode (T" & TimerNr & "M)")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_0", 200, 300, 1975, 300, _
          "Timer mode")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_1", 200, 750, 1975, 300, _
          "Counter mode")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_2", 200, 1200, 1975, 380, _
          "")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_3", 200, 1750, 2075, 380, _
          "")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_4", 200, 2250, 1975, 300, _
          "Reload mode")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_5", 200, 2700, 1975, 300, _
          "Capture mode")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_6", 200, 3150, 2300, 380, _
          "Incremental interface mode (rotation detection)")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "M_7", 200, 3700, 2275, 380, _
          "Incremental interface mode (edge detection)")) Then Exit Function


    '-------------------------------
    ' frame: frmTxI
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "I",2950,100, 5600, 1325, _
      "Input Selection")) Then Exit Function
        If (Not ps.AddLabel("lbl_txt_Freq" & TimerNr, 0, 200, 300, 2800, 300, _
          "Input frequency for Timer " & TimerNr & " [MHz]")) Then Exit Function
        If (Not ps.AddLabel("lbl_box_Freq" & TimerNr, 1, 3200, 250, 1000, 300, "")) Then Exit Function
        If (Not ps.AddCombo("cboT" & TimerNr & "I", 1400, 550, 4050, 315)) Then Exit Function
        If (Not ps.AddLabel("lblT" & TimerNr & "I", 0, 200, 500, 1200, 415, _
          "Prescaler (T" & TimerNr & "I)")) Then Exit Function

    '-------------------------------
    ' frame: frmTxUD
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "UD",2950,1475, 2750, 1025, _
      "Up/Down Control (T" & TimerNr & "UD)")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "UD_0", 200, 250, 1975, 300, _
          "Count up")) Then Exit Function
        If (Not ps.AddOption("optT" & TimerNr & "UD_1", 200, 600, 1975, 300, _
          "Count down")) Then Exit Function

    '-------------------------------
    ' frame: frmTxUDE
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "UDE",2950,2550, 2750, 900, _
      "External Up/Down Enable (T" & TimerNr & "UDE)")) Then Exit Function
        If (Not ps.AddCheck("chkT" & TimerNr & "UDE", 200, 325, 2425, 380, _
          "")) Then Exit Function

    '-------------------------------
    ' frame: frmTx
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "",5800,1475, 2750, 1975, _
      "Timer Register")) Then Exit Function
        If (Not ps.AddText("txtUnFl" & TimerNr & "", 1500, 350, 1075, 315)) Then Exit Function
        If (Not ps.AddText("txtOvFl" & TimerNr & "", 1500, 950, 1075, 315)) Then Exit Function
        If (Not ps.AddText("txtTimReg" & TimerNr & "", 1500, 1550, 1075, 315)) Then Exit Function
        If (Not ps.AddLabel("lblUnFl" & TimerNr & "", 0, 150, 400, 1100, 395, "Underflow [s]")) Then Exit Function
        If (Not ps.AddLabel("lblOvFl" & TimerNr & "", 0, 150, 1000, 1100, 395, "Overflow [s]")) Then Exit Function
        If (Not ps.AddLabel("lblTimReg" & TimerNr & "", 0, 150, 1500, 1425, 380, _
          "Timer register " & vbcrlf & "(" & GPT12_ & "T" & TimerNr & ")")) Then Exit Function

    '-------------------------------
    ' frame: frmTxR
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "R",2950,3500, 2750, 900, _
      "Timer Start")) Then Exit Function
        If (Not ps.AddCheck("chkT" & TimerNr & "R", 200, 300, 2475, 380, _
          "Start timer " & TimerNr & " after initialization (T" & TimerNr & "R)")) Then Exit Function

    '-------------------------------
    ' frame: frmTxRC
    '-------------------------------
    If (Not ps.AddFrame("frmT" & TimerNr & "RC",5800,3500, 2750, 900, _
      "Timer " & TimerNr & " Remote Control")) Then Exit Function
        If (Not ps.AddCheck("chkT" & TimerNr & "RC", 200, 300, 2400, 380, _
          "T" & TimerNr & " is controlled by the run bit T3R (T" & TimerNr & "RC)")) Then Exit Function

    '-------------------------------
    ' frame: frmCI
    '-------------------------------
    If (Not ps.AddFrame("frmCI" & TimerNr & "",100,4425, 8450, 800, _
      "Interrupt Control")) Then Exit Function
        If (Not ps.AddCheck("chkT" & TimerNr & "IE", 200, 300, 2850, 300, _
          "Enable timer " & TimerNr & " interrupt (IE)")) Then Exit Function
        If (Not ps.AddCheck("chkT" & TimerNr & "IRDIS", 3775, 300, 4475, 300, _
          "Disable incremental interface mode interrupt (T" & TimerNr & "IRDIS)")) Then Exit Function

  End If
  OnChangingPageAuxiliaryTimerx = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnShowPageAuxiliaryTimerx(ps As Peripherals, Controlname As String, Pagename As String, v() As Variant, TimerNr As Variant) As Boolean
  On Error GoTo OnShowPageAuxiliaryTimerxError

  OnShowPageAuxiliaryTimerx = False

  Dim r           As ProjectData
  Dim c           As Object
  Dim e           As Object
  Dim bDisabled   As Boolean
  Dim i           As Integer
  Dim vIndex      As Variant
  Dim sVarPre     As String
  Dim uTime       As UnitType
  Dim dDivider    As Double
  
  sVarPre = "GPT1"

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

  If (Pagename = "T" & TimerNr) Then
    '-------------------------------------------------------------------------
    ' page: Auxiliary Timer Tx (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: optTxM_0 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_0"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1) Then 'if in cbo edge selection
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             End If
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 

             If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_1 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_1"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 

             If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
             End If
             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_2 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_2"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1) Then 'if in cbo edge selection
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             End If
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 

             If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_3 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_3"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1) Then 'if in cbo edge selection
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             End If
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 

             If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If
  
        '---------------------------------------------------------------------
        ' control: optTxM_4 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_4"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 5) Then 
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             End If
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 
             
             If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_5 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_5"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 5) Then 
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
             End If
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 0 
             
             If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_6 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_6"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 3
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 1 

             If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optTxM_7 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "M_7"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 3
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 1 

             If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
             End If

             If (GetPinFunction(r, "T" & TimerNr & "EUD") <> 1) Then
               Call RequestAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: cboTxI (action)
        '---------------------------------------------------------------------
        Case "cboT" & TimerNr & "I"
             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                 r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                 r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3) Then
               
               For i = 0 To 7
                  If v(1) = GetPrescalerResolution(r, i) Then
                    r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = i
                  End If
               Next i
             
             End If

             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
                 r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                 r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5) Then
               
               Select Case (v(1))
                           Case ("T" & TimerNr & " is disabled")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
                                If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
                                  Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Positive transition on T" & TimerNr & "IN (" & _
                                  GetPinName("T" & TimerNr & "IN") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 1
                                If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Negative transition on T" & TimerNr & "IN (" & _
                                  GetPinName("T" & TimerNr & "IN") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 2
                                If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Any transition on T" & TimerNr & "IN (" & _
                                  GetPinName("T" & TimerNr & "IN") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 3
                                If (GetPinFunction(r, "T" & TimerNr & "IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Positive transition of output toggle latch T3OTL")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 5
                                If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
                                  Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Negative transition of output toggle latch T3OTL")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 6
                                If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
                                  Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
                           Case ("Any transition of output toggle latch T3OTL")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 7
                                If (GetPinFunction(r, "T" & TimerNr & "IN") = 1) Then
                                  Call ReleaseAlternateInputPin(r, "T" & TimerNr & "IN")
                                End If
               End Select
             End If

             If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
                 r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
               
               Select Case (v(1))
                           Case ("T" & TimerNr & " stops")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0
                           Case ("Any transition on T" & TimerNr & "IN (" & _
                                  GetPinName("T" & TimerNr & "IN") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 1
                           Case ("Any transition on T" & TimerNr & "EUD (" & _
                                  GetPinName("T" & TimerNr & "EUD") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 2
                           Case ("Any transition on T" & TimerNr & "IN (" & _
                                  GetPinName("T" & TimerNr & "IN") & ") or T" & TimerNr & _
                                  "EUD (" & GetPinName("T" & TimerNr & "EUD") & ")")
                                r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 3
               End Select
             End If

        '---------------------------------------------------------------------
        ' control: optTxUD_0 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "UD_0"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UD") = 0

        '---------------------------------------------------------------------
        ' control: optTxUD_1 (action)
        '---------------------------------------------------------------------
        Case "optT" & TimerNr & "UD_1"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UD") = 1

        '---------------------------------------------------------------------
        ' control: chkTxUDE (action)
        '---------------------------------------------------------------------
        Case "chkT" & TimerNr & "UDE"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = v(1)

             If v(1) Then
               If (IsAlternateInputPinFree(r, "T" & TimerNr & "EUD")) Then
                 Call RequestAlternateInputPin(r, "T" & TimerNr & "EUD")
               End IF
             Else
              Call ReleaseAlternateInputPin(r, "T" & TimerNr & "EUD")
             End If

        '---------------------------------------------------------------------
        ' control: chkTxIE (action)
        '---------------------------------------------------------------------
        Case "chkT" & TimerNr & "IE"
             If v(1) = 1 Then
               Call EnableSRN(r, sVarPre, GPT12_ & "T" & TimerNr & "IC", "Tmr" & TimerNr)
             Else
               Call DisableSRN(r, sVarPre, GPT12_ & "T" & TimerNr & "IC", "Tmr" & TimerNr)
               r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 0
             End If

        '---------------------------------------------------------------------
        ' control: chkTxIRDIS (action)
        '---------------------------------------------------------------------
        Case "chkT" & TimerNr & "IRDIS"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = v(1)

        '---------------------------------------------------------------------
        ' control: chkTxR (action)
        '---------------------------------------------------------------------
        Case "chkT" & TimerNr & "R"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = v(1)
             
        '---------------------------------------------------------------------
        ' control: txtTimReg (action)
        '---------------------------------------------------------------------
        Case "txtTimReg" & TimerNr
             If (IsInputFormatOK(v(1), "H4", c("lblTimReg" & TimerNr).Caption, 0, 65535)) Then
               r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr & "") = v(1)
             Else
                 Exit Function
             End If


        '---------------------------------------------------------------------
        ' control: txtOvFl (action)
        '---------------------------------------------------------------------
        Case "txtOvFl" & TimerNr
             uTime = ConvertTime(GetOverflow(r, TimerNr))
             dDivider = uTime.dDivider
             If (IsInputFormatOK(v(1), "F", c("lblOvFl" & TimerNr & "").Caption, _
                 Format(GetMinResolution(r, TimerNr) / dDivider, "0.000"), _
                 Format(GetMaxResolution(r, TimerNr) / dDivider, "0.000"))) Then

               r.l(GPT12_ & "T" & TimerNr & "_T" & TimerNr) = _
                 GetTimerNrValue(r, v(1) * dDivider, True, TimerNr)   'True for overflow
             Else
                 Exit Function
             End If


        '---------------------------------------------------------------------
        ' control: txtUnFl (action)
        '---------------------------------------------------------------------
        Case "txtUnFl" & TimerNr
             uTime = ConvertTime(GetUnderflow(r, TimerNr))
             dDivider = uTime.dDivider
             If (IsInputFormatOK(v(1), "F", c("lblUnFl" & TimerNr & "").Caption, _
                 Format(GetMinResolution(r, TimerNr) / dDivider, "0.000"), _
                 Format(GetMaxResolution(r, TimerNr) / dDivider, "0.000"))) Then

               r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr & "") = _
                 GetTimerNrValue(r, v(1) * dDivider, False, TimerNr)   'False for underflow            
             Else
                 Exit Function
             End If


        '---------------------------------------------------------------------
        ' control: chkTxRC (action)
        '---------------------------------------------------------------------
        Case "chkT" & TimerNr & "RC"
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = v(1)


      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: Auxiliary Timer Tx (show)
    '-------------------------------------------------------------------------

    '-------------------------------------------------------------------------
    ' control: optTxM_0 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_0")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0)
    End With

    With e("optT" & TimerNr & "M_0")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_1 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_1")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1)
    End With

    With e("optT" & TimerNr & "M_1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_2 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_2")
      .Caption = "Gated timer with gate active low (" & _
                 GetPinName("T" & TimerNr & "IN") & ")"
      bDisabled = (Not(IsAlternateInputPinFree(r, "T" & TimerNr & "IN")) Or _
                   IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2)
    End With

    With e("optT" & TimerNr & "M_2")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(IsAlternateInputPinFree(r, "T" & TimerNr & "IN"))) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "IN")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_3 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_3")
      .Caption = "Gated timer with gate active high (" & GetPinName("T" & TimerNr & "IN") & ")"
      bDisabled = (IsModuleDisabled(r, sVarPre) Or _
                   Not(IsAlternateInputPinFree(r, "T" & TimerNr & "IN")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)
    End With

    With e("optT" & TimerNr & "M_3")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(IsAlternateInputPinFree(r, "T" & TimerNr & "IN"))) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "IN")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_4 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_4")
      .Caption = "Reload T3 with T" & TimerNr
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4)
    End With

    With e("optT" & TimerNr & "M_4")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_5 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_5")
      .Caption = "Capture T3 into T" & TimerNr
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5)
    End With

    With e("optT" & TimerNr & "M_5")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_6 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_6")
        bDisabled = (IsModuleDisabled(r, sVarPre) Or Not( _
                     IsAlternateInputPinFree(r, "T" & TimerNr & "IN") And _
                     IsAlternateInputPinFree(r, "T" & TimerNr & "EUD")) )
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6)
    End With

    With e("optT" & TimerNr & "M_6")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (IsAlternateInputPinFree(r, "T" & TimerNr & "IN") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "IN")
        End If
        If (IsAlternateInputPinFree(r, "T" & TimerNr & "EUD") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxM_7 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "M_7")
        bDisabled = (IsModuleDisabled(r, sVarPre) Or Not( _
                     IsAlternateInputPinFree(r, "T" & TimerNr & "IN") And _
                     IsAlternateInputPinFree(r, "T" & TimerNr & "EUD")) )
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7)
    End With

    With e("optT" & TimerNr & "M_7")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (IsAlternateInputPinFree(r, "T" & TimerNr & "IN") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "IN")
        End If
        
        If (IsAlternateInputPinFree(r, "T" & TimerNr & "EUD") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboTxI (show)
    '-------------------------------------------------------------------------
    With c("cboT" & TimerNr & "I")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Clear
      

      '--- Timer Or Gated mode
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3) Then
        For i = 0 To 7
          .AddItem GetPrescalerResolution(r, i)
        Next i
      .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
      End If


      '--- Counter/Reload mode
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4) Then  
        .AddItem "T" & TimerNr & " is disabled"

        If (IsAlternateInputPinFree(r, "T" & TimerNr & "IN")) Then   'TxIN frei ?
          .AddItem "Positive transition on T" & TimerNr & "IN (" & _
                    GetPinName("T" & TimerNr & "IN") & ")"
          .AddItem "Negative transition on T" & TimerNr & "IN (" & _
                    GetPinName("T" & TimerNr & "IN") & ")"
          .AddItem "Any transition on T" & TimerNr & "IN (" & _
                    GetPinName("T" & TimerNr & "IN") & ")"
        End If

        .AddItem "Positive transition of output toggle latch T3OTL"
        .AddItem "Negative transition of output toggle latch T3OTL"
        .AddItem "Any transition of output toggle latch T3OTL"

       If (IsAlternateInputPinFree(r, "T" & TimerNr & "IN")) Then    'wegen dem Fehlen von TxI = 4
         If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 5 Or _
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 6 Or _
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 7) Then
           .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") - 1
         Else
           .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
         End If

       Else
         If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") = 0) Then  'keine Vrschiebung notwendich
           .ListIndex = 0
         Else
           .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I") - 4  'Verschiebung, weil 3 Elelemnte fehlen
         End If
       End If
      End If


      '--- Capture mode
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5) Then
        .AddItem "T" & TimerNr & " is disabled"
        .AddItem "Positive transition on T" & TimerNr & "IN (" & _
                  GetPinName("T" & TimerNr & "IN") & ")"
        .AddItem "Negative transition on T" & TimerNr & "IN (" & _
                  GetPinName("T" & TimerNr & "IN") & ")"
        .AddItem "Any transition on T" & TimerNr & "IN (" & _
                  GetPinName("T" & TimerNr & "IN") & ")"
        .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
      End If

     
      '--- Increment mode
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
        .AddItem "T" & TimerNr & " stops"
        .AddItem "Any transition on T" & TimerNr & "IN (" & _
                  GetPinName("T" & TimerNr & "IN") & ")"
        .AddItem "Any transition on T" & TimerNr & "EUD (" & _
                  GetPinName("T" & TimerNr & "EUD") & ")"
        .AddItem "Any transition on T" & TimerNr & "IN (" & _
                  GetPinName("T" & TimerNr & "IN") & ") or T" & TimerNr & "EUD (" & _
                  GetPinName("T" & TimerNr & "EUD") & ")"
        .ListIndex = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
      End If
      
    End With


    With e("cboT" & TimerNr & "I")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblTxI (show)
    '-------------------------------------------------------------------------
    With c("lblT" & TimerNr & "I")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3) Then
        .Caption = "Prescaler     (T" & TimerNr & "I)"
      Else
        .Caption = "Edge selection (T" & TimerNr & "I)"
      End If
    End With

    With e("lblT" & TimerNr & "I")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_box_Freqx (show)
    '-------------------------------------------------------------------------
    With c("lbl_box_Freq" & TimerNr)
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
        .Caption = GetGPT1ModuleClock(r, vIndex)/16 & " XX"
      Else
        .Caption = GetGPT1ModuleClock(r, vIndex)/8 & " XX"
      End If
      .Visible = False
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
    End With

    With e("lbl_box_Freq" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_txt_Freqx (show)
    '-------------------------------------------------------------------------
    With c("lbl_txt_Freq" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre))
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
        .Caption = "Max. input frequency for Timer " & TimerNr & " [MHz]"
      Else
        .Caption = "Input frequency for Timer " & TimerNr & " [MHz]"
      End If
      .Visible = False
      .Enabled = Not(bDisabled)
    End With

    With e("lbl_txt_Freq" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxUD_0 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "UD_0")
      bDisabled = (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5 Or _
                   IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UD") = 0)
    End With

    With e("optT" & TimerNr & "UD_0")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4)  Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("the reload mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5)  Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("the capture mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optTxUD_1 (show)
    '-------------------------------------------------------------------------
    With c("optT" & TimerNr & "UD_1")
      bDisabled = (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5 Or _
                   IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UD") = 1)
    End With

    With e("optT" & TimerNr & "UD_1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4)  Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("the reload mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5)  Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("the capture mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkTxUDE (show)
    '-------------------------------------------------------------------------
    With c("chkT" & TimerNr & "UDE")
      .Caption = "Enable external up/down via T" & TimerNr & "EUD (" & _
                  GetPinName("T" & TimerNr & "EUD") & ")"
      bDisabled = (IsAlternateOutputPinFree(r, "T" & TimerNr & "EUD") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7 Or _
                   IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "UDE") = 1)
    End With

    With e("chkT" & TimerNr & "UDE")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("reload mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("capture mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
            r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("incremental interface mode is selected")
        End If
        If (IsAlternateOutputPinFree(r, "T" & TimerNr & "EUD") = 0) Then 
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T" & TimerNr & "EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkTxIE (show)
    '-------------------------------------------------------------------------
    With c("chkT" & TimerNr & "IE")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -Cint(r.v(GPT12_ & "T" & TimerNr & "IC_IE") = 1)
    End With

    With e("chkT" & TimerNr & "IE")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkTxIRDIS (show)
    '-------------------------------------------------------------------------
    With c("chkT" & TimerNr & "IRDIS")
      bDisabled = ( (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 6 And _
                     r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 7) Or _
                     r.v(GPT12_ & "T" & TimerNr & "IC_IE") = 0 Or _
                     IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "IRDIS") = 1)
    End With

    With e("chkT" & TimerNr & "IRDIS")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If ((r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 6 And _
             r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") <> 7)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledToolTip("no incremental interface mode selected (T" & TimerNr & "M)")
        End If
        IF r.v(GPT12_ & "T" & TimerNr & "IC_IE") = 0 Then
          .DisabledTooltipTExt = .DisabledTooltipText & _
            FormatDisabledToolTip("timer " & TimerNr & " interrupt is disabled (T" & TimerNr & "IE)")
        End IF
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkTxR (show)
    '-------------------------------------------------------------------------
    With c("chkT" & TimerNr & "R")
      bDisabled = (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = 1 Or _
                   IsModuleDisabled(r, sVarPre) Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5)
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = 1)
    End With

    With e("chkT" & TimerNr & "R")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = 1) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("timer " & TimerNr & " remote control is enabled")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("reload mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("capture mode is selected")
        End If
      End If
    End With
 
    '-------------------------------------------------------------------------
    ' control: chkTxRC (show)
    '-------------------------------------------------------------------------
    With c("chkT" & TimerNr & "RC")
      bDisabled = (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = 1 Or _
                   IsModuleDisabled(r, sVarPre) Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5)
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "RC") = 1)
    End With

    With e("chkT" & TimerNr & "RC")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "R") = 1) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("the start bit of timer " & TimerNr & " is enabled")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 4) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("reload mode is selected")
        End If
        If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 5) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("capture mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtTimReg (show)
    '-------------------------------------------------------------------------
    With c("txtTimReg" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Text = FormatTextOutput(r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr & ""), "H4")
    End With

    With e("txtTimReg" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblTimReg (show)
    '-------------------------------------------------------------------------
    With c("lblTimReg" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
    End With

    With e("lblTimReg" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblOvFl (show)
    '-------------------------------------------------------------------------
    With c("lblOvFl" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre) Or _
                   Not (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3))
      .Enabled = Not(bDisabled)
    End With

    With e("lblOvFl" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblUnFl (show)
    '-------------------------------------------------------------------------
    With c("lblUnFl" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre) Or _
                   Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3))
      .Enabled = Not(bDisabled)
    End With

    With e("lblUnFl" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtOvFl (show)
    '-------------------------------------------------------------------------
    With c("txtOvFl" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre) Or _
                   Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3))
      .Enabled = Not(bDisabled)
      If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
        .Text = CALCULATION_NOT_POSSIBLE
      Else
        uTime = ConvertTime(GetOverflow(r, TimerNr))
        .Text = Format(uTime.dValue, "0.000")
        c("lblOvFl" & TimerNr).Caption = "Overflow [" & uTime.sUnit & "]"
      End IF

    End With

    With e("txtOvFl" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtUnFl (show)
    '-------------------------------------------------------------------------
    With c("txtUnFl" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre) Or _
                   Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3))
      .Enabled = Not(bDisabled)
      If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
        .Text = CALCULATION_NOT_POSSIBLE
      Else
        uTime = ConvertTime(GetUnderflow(r, TimerNr))
        .Text = Format(uTime.dValue, "0.000")
        c("lblUnFl" & TimerNr).Caption = "Underflow [" & uTime.sUnit & "]"
      End IF

    End With

    With e("txtUnFl" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 0 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 2 Or _
                   r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 3)) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With


  End If

  OnShowPageAuxiliaryTimerx = True
  Exit Function

OnShowPageAuxiliaryTimerxError:
  Errorbox "Can not show page", Err.Description  
  Exit Function
End Function


'-----------------------------------------------------------------------------
' local functions
'-----------------------------------------------------------------------------

'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add a page.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageCoreTimer3(ps As Peripherals) As Boolean
  On Error Resume Next
  OnLoadPageCoreTimer3 = False

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

  OnLoadPageCoreTimer3 = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnChangingPageCoreTimer3(ps As Peripherals, Pagename As String) As Boolean
  On Error Resume Next

  OnChangingPageCoreTimer3 = False
  
  
  

  If (Not ps.ExtenderCollection("T3").Loaded) And (Pagename = "T3") Then
    ps.ExtenderCollection("T3").Loaded = True

    '-------------------------------
    ' frame: frmT3M
    '-------------------------------
    If (Not ps.AddFrame("frmT3M",100,100, 2750, 3525, _
      "Timer 3 Mode (T3M)")) Then Exit Function
        If (Not ps.AddOption("optT3M_0", 200, 300, 1975, 300, _
          "Timer mode")) Then Exit Function
        If (Not ps.AddOption("optT3M_1", 200, 750, 1975, 300, _
          "Counter mode")) Then Exit Function
        If (Not ps.AddOption("optT3M_2", 200, 1250, 1975, 380, _
          "")) Then Exit Function
        If (Not ps.AddOption("optT3M_3", 200, 1800, 2075, 380, _
          "")) Then Exit Function
        If (Not ps.AddOption("optT3M_6", 200, 2350, 2300, 380, _
          "Incremental interface mode (rotation detection)")) Then Exit Function
        If (Not ps.AddOption("optT3M_7", 200, 2900, 2275, 380, _
          "Incremental interface mode (edge detection)")) Then Exit Function
                                              
    '-------------------------------          
    ' frame: frmT3I
    '-------------------------------
    If (Not ps.AddFrame("frmT3I",2950,100, 5600, 1325, _
      "Input Selection")) Then Exit Function
        If (Not ps.AddLabel("lbl_txt_Freq3", 0, 200, 300, 2800, 300, _
          "Input frequency for Timer 3 [MHz]")) Then Exit Function
        If (Not ps.AddLabel("lbl_box_Freq3", 1, 3200, 250, 1000, 300, "")) Then Exit Function
        If (Not ps.AddCombo("cboT3I", 1400, 550, 4050, 315)) Then Exit Function
        If (Not ps.AddLabel("lblT3I", 0, 200, 500, 1200, 415, _
          "Prescaler (T3I)")) Then Exit Function

    '-------------------------------
    ' frame: frmT3UD
    '-------------------------------
    If (Not ps.AddFrame("frmT3UD",2950,1475, 2750, 1025, _
      "Up/Down Control (T3UD)")) Then Exit Function
        If (Not ps.AddOption("optT3UD_0", 200, 250, 1975, 300, _
          "Count up")) Then Exit Function
        If (Not ps.AddOption("optT3UD_1", 200, 600, 1975, 300, _
          "Count down")) Then Exit Function

    '-------------------------------
    ' frame: frmT3UDE
    '-------------------------------
    If (Not ps.AddFrame("frmT3UDE",2950,2550, 2750, 1100, _
      "External Up/Down Enable (T3UDE)")) Then Exit Function
        If (Not ps.AddCheck("chkT3UDE", 200, 400, 2425, 380, "")) Then Exit Function

    '-------------------------------
    ' frame: frmT3
    '-------------------------------
    If (Not ps.AddFrame("frmT3",5800,1475, 2750, 2175, _
      "Timer Register")) Then Exit Function
        If (Not ps.AddText("txtUnFl", 1500, 350, 1075, 315)) Then Exit Function
        If (Not ps.AddText("txtOvFl", 1500, 950, 1075, 315)) Then Exit Function
        If (Not ps.AddLabel("lblOvFl", 0, 150, 1000, 1100, 395, "Overflow [s]")) Then Exit Function
        If (Not ps.AddLabel("lblUnFl", 0, 150, 400, 1100, 395, "Underflow [s]")) Then Exit Function
        If (Not ps.AddText("txtTimReg", 1500, 1550, 1075, 315)) Then Exit Function
        If (Not ps.AddLabel("lblTimReg", 0, 150, 1500, 1425, 380, _
          "Timer register " & vbcrlf & "(" & GPT12_ & "T3)")) Then Exit Function
  
    '-------------------------------
    ' frame: frmT3OE
    '-------------------------------
    If (Not ps.AddFrame("frmT3OE",100,3700, 3200, 1450, _
      "Alternate Output Function (T3OE)")) Then Exit Function
        If (Not ps.AddCheck("chkT3OE", 200, 350, 2800, 380, "")) Then Exit Function
        If (Not ps.AddCheck("chkT3OTL", 200, 850, 2825, 380, _
          "Set output toggle latch to '1' (T3OTL)")) Then Exit Function

    '-------------------------------
    ' frame: frmT3R
    '-------------------------------
    If (Not ps.AddFrame("frmT3R",3425,3700, 2275, 1450, _
      "Timer Start")) Then Exit Function
        If (Not ps.AddCheck("chkT3R", 200, 600, 1675, 380, _
          "Start timer 3 after initialization (T3R)")) Then Exit Function

    '-------------------------------
    ' frame: frmCI
    '-------------------------------
    If (Not ps.AddFrame("frmCI",5800,3700, 2750, 1450, _
      "Interrupt Control")) Then Exit Function
        If (Not ps.AddCheck("chkT3IE", 200, 600, 2325, 380, _
          "Enable timer 3 interrupt (IE)")) Then Exit Function



  End if
  OnChangingPageCoreTimer3 = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnShowPageCoreTimer3(ps As Peripherals, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error Goto OnShowPageCoreTimer3Error

  OnShowPageCoreTimer3 = False
     
  Dim r           As ProjectData
  Dim c           As Collection
  Dim e           As Collection
  Dim bDisabled   As Boolean
  Dim i           As Integer
  Dim vIndex      As Variant
  Dim TimerNr     As Variant
  Dim sVarPre     As String
  Dim uTime       As UnitType
  Dim dDivider    As Double
  
  sVarPre = "GPT1"
  TimerNr = 3

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

  If (Pagename = "T3") Then
    '-------------------------------------------------------------------------
    ' page: GPT1_Timer_3 (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: optT3M_0 (action)
        '---------------------------------------------------------------------
        Case "optT3M_0"
             r.v(GPT12_ & "T3CON_T3M") = 0
             r.v(GPT12_ & "T3CON_T3I") = 0
             r.v(GPT12_ & "T3CON_T3UDE") = 0 

             If (GetPinFunction(r, "T3IN") = 1) Then
               Call ReleaseAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T3EUD")
             End If


        '---------------------------------------------------------------------
        ' control: optT3M_1 (action)
        '---------------------------------------------------------------------
        Case "optT3M_1"
             r.v(GPT12_ & "T3CON_T3M") = 1
             r.v(GPT12_ & "T3CON_T3I") = 3
             r.v(GPT12_ & "T3CON_T3UDE") = 0 

             If (GetPinFunction(r, "T3IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T3EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optT3M_2 (action)
        '---------------------------------------------------------------------
        Case "optT3M_2"
             r.v(GPT12_ & "T3CON_T3M") = 2
             r.v(GPT12_ & "T3CON_T3I") = 0
             r.v(GPT12_ & "T3CON_T3UDE") = 0 
             
             If (GetPinFunction(r, "T3IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T3EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optT3M_3 (action)
        '---------------------------------------------------------------------
        Case "optT3M_3"
             r.v(GPT12_ & "T3CON_T3M") = 3
             r.v(GPT12_ & "T3CON_T3I") = 0
             r.v(GPT12_ & "T3CON_T3UDE") = 0 

             If (GetPinFunction(r, "T3IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") = 1) Then
               Call ReleaseAlternateInputPin(r, "T3EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optT3M_6 (action)
        '---------------------------------------------------------------------
        Case "optT3M_6"
             r.v(GPT12_ & "T3CON_T3M") = 6
             r.v(GPT12_ & "T3CON_T3I") = 3
             r.v(GPT12_ & "T3CON_T3UDE") = 1
             
             If (GetPinFunction(r, "T3IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") <> 1) Then
               Call RequestAlternateInputPin(r, "T3EUD")
             End If

        '---------------------------------------------------------------------
        ' control: optT3M_7 (action)
        '---------------------------------------------------------------------
        Case "optT3M_7"
             r.v(GPT12_ & "T3CON_T3M") = 7
             r.v(GPT12_ & "T3CON_T3I") = 3
             r.v(GPT12_ & "T3CON_T3UDE") = 1

             If (GetPinFunction(r, "T3IN") <> 1) Then
               Call RequestAlternateInputPin(r, "T3IN")
             End If

             If (GetPinFunction(r, "T3EUD") <> 1) Then
               Call RequestAlternateInputPin(r, "T3EUD")
             End If


        '---------------------------------------------------------------------
        ' control: cboT3I (action)
        '---------------------------------------------------------------------
        Case "cboT3I"
             If (r.v(GPT12_ & "T3CON_T3M") = 0 Or r.v(GPT12_ & "T3CON_T3M") = 2 Or _
                 r.v(GPT12_ & "T3CON_T3M") = 3) Then
               For i = 0 To 7
                  If v(1) = GetPrescalerResolution(r, i) Then
                     r.v(GPT12_ & "T3CON_T3I") = i
                  End If
               Next i
             End If

             If r.v(GPT12_ & "T3CON_T3M") = 1 Then
               Select Case (v(1))
                           Case ("T3 is disabled")
                                r.v(GPT12_ & "T3CON_T3I") = 0
                                Call ReleaseAlternateInputPin(r, "T3IN")
                           Case ("Positive transition on T3IN (" & GetPinName("T3IN") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 1
                                If (GetPinFunction(r, "T3IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T3IN")
                                End If                   
                           Case ("Negative transition on T3IN (" & GetPinName("T3IN") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 2
                                If (GetPinFunction(r, "T3IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T3IN")
                                End If            
                           Case ("Any transition on T3IN (" & GetPinName("T3IN") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 3
                                If (GetPinFunction(r, "T3IN") <> 1) Then
                                  Call RequestAlternateInputPin(r, "T3IN")
                                End If            
               End Select
             End If

             If (r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7) Then
               Select Case (v(1))
                           Case ("T3 stops")
                                r.v(GPT12_ & "T3CON_T3I") = 0
                           Case ("Any transition on T3IN (" & GetPinName("T3IN") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 1
                           Case ("Any transition on T3EUD (" & GetPinName("T3EUD") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 2
                           Case ("Any transition on T3IN (" & GetPinName("T3IN") & _
                                  ") or T3EUD (" & GetPinName("T3EUD") & ")")
                                r.v(GPT12_ & "T3CON_T3I") = 3
               End Select
             End If

        '---------------------------------------------------------------------
        ' control: optT3UD_0 (action)
        '---------------------------------------------------------------------
        Case "optT3UD_0"
             r.v(GPT12_ & "T3CON_T3UD") = 0

        '---------------------------------------------------------------------
        ' control: optT3UD_1 (action)
        '---------------------------------------------------------------------
        Case "optT3UD_1"
             r.v(GPT12_ & "T3CON_T3UD") = 1

        '---------------------------------------------------------------------
        ' control: chkT3UDE (action)
        '---------------------------------------------------------------------
        Case "chkT3UDE"
             r.v(GPT12_ & "T3CON_T3UDE") = v(1)
             If v(1) Then
               If (IsAlternateInputPinFree(r, "T3EUD")) Then
                 Call RequestAlternateInputPin(r, "T3EUD")
               End IF
             Else
              Call ReleaseAlternateInputPin(r, "T3EUD")
             End If

        '---------------------------------------------------------------------
        ' control: chkT3OE (action)
        '---------------------------------------------------------------------
        Case "chkT3OE"
             r.v(GPT12_ & "T3CON_T3OE") = v(1)
             If v(1) Then
               If (IsAlternateOutputPinFree(r, "T3OUT")) Then
                 Call RequestAlternateOutputPin(r, "T3OUT")
               End IF
             Else
               Call ReleaseAlternateOutputPin(r, "T3OUT")
             End If

        '---------------------------------------------------------------------
        ' control: chkT3OTL (action)
        '---------------------------------------------------------------------
        Case "chkT3OTL"
             r.v(GPT12_ & "T3CON_T3OTL") = v(1)

        '---------------------------------------------------------------------
        ' control: chkT3IE (action)
        '---------------------------------------------------------------------
        Case "chkT3IE"
             If v(1) = 1 Then
               Call EnableSRN(r, sVarPre, GPT12_ & "T3IC", "Tmr3")
             Else
               Call DisableSRN(r, sVarPre, GPT12_ & "T3IC", "Tmr3")
             End If

        '---------------------------------------------------------------------
        ' control: chkT3R (action)
        '---------------------------------------------------------------------
        Case "chkT3R"
             r.v(GPT12_ & "T3CON_T3R") = v(1)

        '---------------------------------------------------------------------
        ' control: txtTimReg (action)
        '---------------------------------------------------------------------
        Case "txtTimReg"
             If (IsInputFormatOK(v(1), "H4", c("lblTimReg").Caption, 0, 65535)) Then
               r.v(GPT12_ & "T3_T3") = v(1)
             Else
                 Exit Function
             End If
             
        '---------------------------------------------------------------------
        ' control: txtOvFl (action)
        '---------------------------------------------------------------------
        Case "txtOvFl"
             uTime = ConvertTime(GetOverflow(r, TimerNr))
             dDivider = uTime.dDivider
             If (IsInputFormatOK(v(1), "F", c("lblOvFl").Caption, _
                 Format(GetMinResolution(r, TimerNr) / dDivider, "0.000"), _
                 Format(GetMaxResolution(r, TimerNr) / dDivider, "0.000"))) Then

               r.l(GPT12_ & "T" & TimerNr & "_T" & TimerNr) = _
                  GetTimerNrValue(r, v(1) * dDivider, True, TimerNr)   'True for overflow
             Else
                 Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: txtUnFl (action)
        '---------------------------------------------------------------------
        Case "txtUnFl"
             uTime = ConvertTime(GetUnderflow(r, TimerNr))
             dDivider = uTime.dDivider
             If (IsInputFormatOK(v(1), "F", c("lblUnFl").Caption, _
                 Format(GetMinResolution(r, TimerNr) / dDivider, "0.000"), _
                 Format(GetMaxResolution(r, TimerNr) / dDivider, "0.000"))) Then

               r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr & "") = _
                  GetTimerNrValue(r, v(1) * dDivider, False, TimerNr)   'False for underflow            
             Else
                 Exit Function
             End If

      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: GPT1_Timer_3 (show)
    '-------------------------------------------------------------------------

    '-------------------------------------------------------------------------
    ' control: optT3M_0 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_0")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 0)
    End With

    With e("optT3M_0")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3M_1 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_1")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or Not(IsAlternateInputPinFree(r, "T3IN")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 1)
    End With

    With e("optT3M_1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(IsAlternateInputPinFree(r, "T3IN"))) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3IN")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3M_2 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_2")
      .Caption = "Gated timer with gate active low (" & GetPinName("T3IN") & ")"
      bDisabled = (IsModuleDisabled(r, sVarPre) Or Not(IsAlternateInputPinFree(r, "T3IN")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 2)
    End With

    With e("optT3M_2")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(IsAlternateInputPinFree(r, "T3IN"))) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3IN")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3M_3 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_3")
      .Caption = "Gated timer with gate active high (" & GetPinName("T3IN") & ")"
      bDisabled = (IsModuleDisabled(r, sVarPre) Or Not(IsAlternateInputPinFree(r, "T3IN")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 3)
    End With

    With e("optT3M_3")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (Not(IsAlternateInputPinFree(r, "T3IN"))) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3IN")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3M_6 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_6")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or Not(IsAlternateInputPinFree(r, "T3IN") And _
                   IsAlternateInputPinFree(r, "T3EUD")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 6)
    End With

    With e("optT3M_6")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (IsAlternateInputPinFree(r, "T3IN") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3IN")
        End If
        If (IsAlternateInputPinFree(r, "T3EUD") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3M_7 (show)
    '-------------------------------------------------------------------------
    With c("optT3M_7")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or Not(IsAlternateInputPinFree(r, "T3IN") And _
                   IsAlternateInputPinFree(r, "T3EUD")))
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3M") = 7)
    End With

    With e("optT3M_7")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (IsAlternateInputPinFree(r, "T3IN") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3IN")
        End If
        If (IsAlternateInputPinFree(r, "T3EUD") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboT3I (show)
    '-------------------------------------------------------------------------
    With c("cboT3I")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      .Clear
      If (r.v(GPT12_ & "T3CON_T3M") = 0 Or r.v(GPT12_ & "T3CON_T3M") = 2 Or _
          r.v(GPT12_ & "T3CON_T3M") = 3) Then
        For i = 0 To 7
          .AddItem GetPrescalerResolution(r, i)
        Next i
      .ListIndex = r.v(GPT12_ & "T3CON_T3I")
      End If

      If r.v(GPT12_ & "T3CON_T3M") = 1 Then
        .AddItem "T3 is disabled"
        .AddItem "Positive transition on T3IN (" & GetPinName("T3IN") & ")"
        .AddItem "Negative transition on T3IN (" & GetPinName("T3IN") & ")"
        .AddItem "Any transition on T3IN (" & GetPinName("T3IN") & ")"
      .ListIndex = r.v(GPT12_ & "T3CON_T3I")
      End If

      If (r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7) Then
        .AddItem "T3 stops"
        .AddItem "Any transition on T3IN (" & GetPinName("T3IN") & ")"
        .AddItem "Any transition on T3EUD (" & GetPinName("T3EUD") & ")"
        .AddItem "Any transition on T3IN (" & GetPinName("T3IN") & ") or T3EUD (" & _
                  GetPinName("T3EUD") & ")"
      .ListIndex = r.v(GPT12_ & "T3CON_T3I")
      End If
      
    End With

    With e("cboT3I")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblT3I (show)
    '-------------------------------------------------------------------------
    With c("lblT3I")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
      If (r.v(GPT12_ & "T3CON_T3M") = 0 Or r.v(GPT12_ & "T3CON_T3M") = 2 Or _
          r.v(GPT12_ & "T3CON_T3M") = 3) Then
        .Caption = "Prescaler     (T3I)"
      Else
        .Caption = "Edge selection (T3I)"
      End If
    End With

    With e("lblT3I")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_box_Freqx (show)
    '-------------------------------------------------------------------------
    With c("lbl_box_Freq" & TimerNr)
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
        .Caption = GetGPT1ModuleClock(r, vIndex)/16 & " XX"
      Else
        .Caption = GetGPT1ModuleClock(r, vIndex)/8 & " XX"
      End If
      .Visible = False
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled)
    End With

    With e("lbl_box_Freq" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lbl_txt_Freqx (show)
    '-------------------------------------------------------------------------
    With c("lbl_txt_Freq" & TimerNr)
      bDisabled = (IsModuleDisabled(r, sVarPre))
      If (r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 1 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 6 Or _
          r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "M") = 7) Then
        .Caption = "Max. input frequency for Timer " & TimerNr & " [MHz]"
      Else
        .Caption = "Input frequency for Timer " & TimerNr & " [MHz]"
      End If
      .Visible = False
      .Enabled = Not(bDisabled)
    End With

    With e("lbl_txt_Freq" & TimerNr)
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3UD_0 (show)
    '-------------------------------------------------------------------------
    With c("optT3UD_0")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled) 
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3UD") = 0)
    End With

    With e("optT3UD_0")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optT3UD_1 (show)
    '-------------------------------------------------------------------------
    With c("optT3UD_1")
      bDisabled = (IsModuleDisabled(r, sVarPre))
      .Enabled = Not(bDisabled) 
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3UD") = 1)
    End With

    With e("optT3UD_1")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkT3UDE (show)
    '-------------------------------------------------------------------------
    With c("chkT3UDE")
      .Caption = "Enable external up/down via T3EUD (" & GetPinName("T3EUD") & ")"
      bDisabled = (IsModuleDisabled(r, sVarPre) Or IsAlternateInputPinFree(r, "T3EUD") = 0 Or _
                   r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7)
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3UDE") = 1)
    End With

    With e("chkT3UDE")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("incremental interface mode is selected")
        End If
        If (IsAlternateInputPinFree(r, "T3EUD") = 0) Then 
          .DisabledTooltipText = .DisabledTooltipText & _
            GetDisabledAlternatePinTooltip(r, "T3EUD")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkT3OE (show)
    '-------------------------------------------------------------------------
    With c("chkT3OE")
      .Caption = "Enable alternate output function T3OUT (" & GetPinName("T3OUT") & ")"
      bDisabled = (IsModuleDisabled(r, sVarPre) Or IsAlternateOutputPinFree(r, "T3OUT") = 0)
      .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3OE") = 1)
    End With

    With e("chkT3OE")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (IsAlternateOutputPinFree(r, "T3OUT") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & GetDisabledAlternatePinTooltip(r, "T3OUT")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkT3OTL (show)
    '-------------------------------------------------------------------------
    With c("chkT3OTL")
       bDisabled = (IsModuleDisabled(r, sVarPre))
       .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3OTL") = 1)
    End With

    With e("chkT3OTL")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkT3IE (show)
    '-------------------------------------------------------------------------
    With c("chkT3IE")
       bDisabled = (IsModuleDisabled(r, sVarPre))
       .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3IC_IE") = 1)
    End With

     With e("chkT3IE")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkT3R (show)
    '-------------------------------------------------------------------------
    With c("chkT3R")
       bDisabled = (IsModuleDisabled(r, sVarPre))
       .Enabled = Not(bDisabled)
      .Value = -CInt(r.v(GPT12_ & "T3CON_T3R") = 1)
    End With

     With e("chkT3R")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtTimReg (show)
    '-------------------------------------------------------------------------
    With c("txtTimReg")
       bDisabled = (IsModuleDisabled(r, sVarPre))
       .Enabled = Not(bDisabled)
      .Text = FormatTextOutput(r.v(GPT12_ & "T3_T3"), "H4")
    End With

     With e("txtTimReg")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblTimReg (show)
    '-------------------------------------------------------------------------
    With c("lblTimReg")
       bDisabled = (IsModuleDisabled(r, sVarPre))
       .Enabled = Not(bDisabled)
    End With

     With e("lblTimReg")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblOvFl (show)
    '-------------------------------------------------------------------------
    With c("lblOvFl")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or r.v(GPT12_ & "T3CON_T3M") = 1 Or _
                   r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7)
      .Enabled = Not(bDisabled)
    End With

    With e("lblOvFl")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
            r.v(GPT12_ & "T3CON_T3M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblUnFl (show)
    '-------------------------------------------------------------------------
    With c("lblUnFl")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or r.v(GPT12_ & "T3CON_T3M") = 1 Or _
                   r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7)
      .Enabled = Not(bDisabled)
    End With

    With e("lblUnFl")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
            r.v(GPT12_ & "T3CON_T3M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtOvFl (show)
    '-------------------------------------------------------------------------
    With c("txtOvFl")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or r.v(GPT12_ & "T3CON_T3M") = 1 Or _
                   r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7)
      .Enabled = Not(bDisabled)
      If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
          r.v(GPT12_ & "T3CON_T3M") = 7) Then
        .Text = CALCULATION_NOT_POSSIBLE
      Else
        uTime = ConvertTime(GetOverflow(r, TimerNr))
        .Text = Format(uTime.dValue, "0.000")
        c("lblOvFl").Caption = "Overflow [" & uTime.sUnit & "]"
      End IF
    End With

    With e("txtOvFl")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
            r.v(GPT12_ & "T3CON_T3M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtUnFl (show)
    '-------------------------------------------------------------------------
    With c("txtUnFl")
      bDisabled = (IsModuleDisabled(r, sVarPre) Or r.v(GPT12_ & "T3CON_T3M") = 1 Or _
                   r.v(GPT12_ & "T3CON_T3M") = 6 Or r.v(GPT12_ & "T3CON_T3M") = 7)
      .Enabled = Not(bDisabled)
      If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
          r.v(GPT12_ & "T3CON_T3M") = 7) Then
        .Text = CALCULATION_NOT_POSSIBLE
      Else
        uTime = ConvertTime(GetUnderflow(r, TimerNr))
        .Text = Format(uTime.dValue, "0.000")
        c("lblUnFl").Caption = "Underflow [" & uTime.sUnit & "]"
      End IF

    End With

    With e("txtUnFl")
      If (bDisabled) Then
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleDisabled(r, sVarPre)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleDisabled(r, vIndex)
        End If
        If (r.v(GPT12_ & "T3CON_T3M") = 1 Or r.v(GPT12_ & "T3CON_T3M") = 6 Or _
            r.v(GPT12_ & "T3CON_T3M") = 7) Then
          .DisabledTooltipText = .DisabledTooltipText & _
            FormatDisabledTooltip("no timer mode is selected")
        End If
      End If
    End With

        
  End If

  OnShowPageCoreTimer3 = True
  Exit Function

OnShowPageCoreTimer3Error:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add a page.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageFunctions(ps As Peripherals) As Boolean
  On Error Resume Next
  OnLoadPageFunctions = False

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

  OnLoadPageFunctions = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnChangingPageFunctions(ps As Peripherals, Pagename As String) As Boolean
  On Error Resume Next

  Dim i As Integer
  Dim aFunctions(1 To 16) As String


  OnChangingPageFunctions = False

  If (Not ps.ExtenderCollection("Functions").Loaded) And (Pagename = "Functions") Then
    ps.ExtenderCollection("Functions").Loaded = True

    '-------------------------------
    ' frame: fra_Init
    '-------------------------------
    If (Not ps.AddFrame("fra_Init", 100 , 100, 4150, 700, CAPTION_FRA_USE_INIT)) Then Exit Function
      If (Not ps.AddCheck("chk_Init", 150, 275, 200, 275, "")) Then Exit Function
      If (Not ps.AddText("txt_Init", 400, 250, 3600, 325)) Then Exit Function

    '-------------------------------
    ' frame: fra_CFile
    '-------------------------------
    If (Not ps.AddFrame("fra_CFile", 4400 , 100, 4150, 700, CAPTION_FRA_CFILE)) Then Exit Function
      If (Not ps.AddText("txt_CFile", 1475, 250, 2500, 325)) Then Exit Function
      If (Not ps.AddLabel("lbl_CFile", 0, 200, 300, 1250, 275, CAPTION_LBL_CFILE)) Then Exit Function


    '-------------------------------
    ' frame: fraLibrary1
    '-------------------------------
    ' initialize the array
    For i = Lbound(aFunctions) To Ubound(aFunctions)
      aFunctions(i) = ""
    Next i

    ' Functions and Macros
    i = Lbound(aFunctions)

    aFunctions(i) = "StartTmr"
    i = i + 1
    aFunctions(i) = "StopTmr"
    i = i + 1
    aFunctions(i) = "ClearTmr"
    i = i + 1
    aFunctions(i) = "ReadTmr"
    i = i + 1
    aFunctions(i) = "LoadTmr"
    i = i + 1
    aFunctions(i) = "Tmr2"
    i = i + 1
    aFunctions(i) = "Tmr3"
    i = i + 1
    aFunctions(i) = "Tmr4"
    i = i + 1
    aFunctions(i) = "SetToggLatch"
    i = i + 1
    aFunctions(i) = "ClrToggLatch"
    i = i + 1
    aFunctions(i) = "CountUp"
    i = i + 1
    aFunctions(i) = "CountDown"
    i = i + 1
    aFunctions(i) = "GetCountDirection"
    i = i + 1


    If (Not ps.AddFrame("fraLibrary1", 100 , 900, 4150, 4400, CAPTION_FRA_LIBRARY1)) Then Exit Function
      For i = Lbound(aFunctions) To Ubound(aFunctions)
        If Not(aFunctions(i) = "") Then
          If (Not ps.AddCheck("chk_" & aFunctions(i), 150, 325 + (300 * (i - 1)), 200, 275, "")) Then Exit Function
          If (Not ps.AddText("txt_" & aFunctions(i), 400, 300 + (300 * (i - 1)), 3600, 325)) Then Exit Function
        End If
      Next i

    '-------------------------------
    ' frame: fraLibrary1
    '-------------------------------
    ' initialize the array
    For i = Lbound(aFunctions) To Ubound(aFunctions)
      aFunctions(i) = ""
    Next i

    ' Functions and Macros
    i = Lbound(aFunctions)

    aFunctions(i) = "CheckRotation"
    i = i + 1
    aFunctions(i) = "CheckEdge"
    i = i + 1
    aFunctions(i) = "SetTmrRemoteControl"
    i = i + 1

    If (Not ps.AddFrame("fraLibrary2", 4400 , 900, 4150, 4400, CAPTION_FRA_LIBRARY2)) Then Exit Function
      For i = Lbound(aFunctions) To Ubound(aFunctions)
        If Not(aFunctions(i) = "") Then
          If (Not ps.AddCheck("chk_" & aFunctions(i), 150, 325 + (300 * (i - 1)), 200, 275, "")) Then Exit Function
          If (Not ps.AddText("txt_" & aFunctions(i), 400, 300 + (300 * (i - 1)), 3600, 325)) Then Exit Function
        End If
      Next i

  End If


  OnChangingPageFunctions = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnShowPageFunctions(ps As Peripherals, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error Goto OnShowPageFunctionsError

  OnShowPageFunctions = False
    
  Dim r         As ProjectData
  Dim c         As Collection
  Dim e         As Collection
  Dim bDisabled As Boolean
  Dim func      As FunctionClass
  Dim d         As String
  Dim sVarPre   As String
  Dim sPrefix   As String
  Dim vIndex    As Variant
  Dim sName     As String

  vIndex = ""
  sVarPre = "GPT1"
  sPrefix = sVarPre & "_"

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
  Set func = New  FunctionClass

  If (Pagename = "Functions") Then
    '-------------------------------------------------------------------------
    ' page: Functions (action)
    '-------------------------------------------------------------------------
    RefreshFunctionDescriptions(vIndex, func, r)

    If (Not UpdateFunction(sVarPre, ps, func , Controlname, v)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Functions (show)
    '-------------------------------------------------------------------------
    Set func = New FunctionClass
    RefreshFunctionDescriptions(vIndex, func, r)


    sName = sVarPre & "_NAME_Init" 
    ' disable condition
    func.Disabled(sName) = (IsModuleDisabled(r, sVarPre))
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (IsModuleDisabled(r, sVarPre)) Then
      d = d & GetTooltipModuleDisabled(r, vIndex)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_StartTmr" 
    ' disable condition
    func.Disabled(sName) = (r.v(sVarPre & "_USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_StopTmr" 
    ' disable condition
    func.Disabled(sName) = (r.v(sVarPre & "_USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_ClearTmr" 
    ' disable condition
    func.Disabled(sName) = (r.v(sVarPre & "_USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_ReadTmr" 
    ' disable condition
    func.Disabled(sName) = (r.v(sVarPre & "_USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_LoadTmr" 
    ' disable condition
    func.Disabled(sName) = (r.v(sVarPre & "_USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_Tmr2" 
    ' disable condition
    func.Disabled(sName) = True
    ' tooltip if control is disabled
    d = TOOLTIP_DISABLED_ISR32
    func.DisabledToolTip(sName) = d
    ' value for the control
    func.Value(sName) = IsISRSelected(r, sVarPre, GPT12_ & "T2IC", "Tmr2")

    sName = sVarPre & "_NAME_Tmr3" 
    ' disable condition
    func.Disabled(sName) = True
    ' tooltip if control is disabled
    d = TOOLTIP_DISABLED_ISR32
    func.DisabledToolTip(sName) = d
    ' value for the control
    func.Value(sName) = IsISRSelected(r, sVarPre, GPT12_ & "T3IC", "Tmr3")

    sName = sVarPre & "_NAME_Tmr4" 
    ' disable condition
    func.Disabled(sName) = True
    ' tooltip if control is disabled
    d = TOOLTIP_DISABLED_ISR32
    func.DisabledToolTip(sName) = d
    ' value for the control
    func.Value(sName) = IsISRSelected(r, sVarPre, GPT12_ & "T4IC", "Tmr4")

    sName = sVarPre & "_NAME_SetToggLatch" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d
                             
    sName = sVarPre & "_NAME_ClrToggLatch" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_CountUp" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_CountDown" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_GetCountDirection" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_CheckRotation" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_CheckEdge" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d

    sName = sVarPre & "_NAME_SetTmrRemoteControl" 
    ' disable condition
    func.Disabled(sName) = (r.v(sPrefix & "USE_Init") = 0)
    ' tooltip if control is disabled
    d = GetDisabledFunctionToolTipEntry(func, sName)
    If (r.v(sVarPre & "_USE_Init") = 0) Then 
      d = d & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
    End If
    func.DisabledToolTip(sName) = d


    If (Not ShowFunction(sVarPre, ps, func , v)) Then Exit Function


  End If
  
    OnShowPageFunctions = True
  Exit Function

OnShowPageFunctionsError:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add a page.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageParameters(ps As Peripherals) As Boolean
  On Error Resume Next
  OnLoadPageParameters = False

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

  OnLoadPageParameters = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnChangingPageParameters(ps As Peripherals, Pagename As String) As Boolean
  On Error Resume Next

  OnChangingPageParameters = False

  Dim i As Integer
  Dim aParameters(1 To 16) As String

  If (Not ps.ExtenderCollection("Parameters").Loaded) And (Pagename = "Parameters") Then
    ps.ExtenderCollection("Parameters").Loaded = True

    '-------------------------------------------------------------------------
    ' frame: frmCAPCOMx_HFile
    '-------------------------------------------------------------------------
    If (Not ps.AddFrame("fra_HFile", 100 , 100, 4150, 700, CAPTION_FRA_HFILE)) Then Exit Function
      If (Not ps.AddText("txt_HFile", 1475, 250, 2500, 325)) Then Exit Function
      If (Not ps.AddLabel("lbl_HFile",0 , 200 , 300, 1250, 300, CAPTION_LBL_HFILE)) Then Exit Function   

    
    '-------------------------------
    ' frame: fraParameters1
    '-------------------------------
    ' initialize the array
    For i = Lbound(aParameters) To Ubound(aParameters)
      aParameters(i) = ""
    Next i

    i = Lbound(aParameters)
    aParameters(i) = "TIMER_2"
    i = i + 1
    aParameters(i) = "TIMER_3"
    i = i + 1
    aParameters(i) = "TIMER_4"
    i = i + 1

    If (Not ps.AddFrame("fraParameters1", 100 , 900, 4150, 4400, CAPTION_FRA_PARAMETERS1)) Then Exit Function
      For i = Lbound(aParameters) To Ubound(aParameters)
        If Not(aParameters(i) = "") Then
          If (Not ps.AddText("txt_" & aParameters(i), 200, 300 * i, 3800, 325)) Then Exit Function
        End If
      Next i

  End If

  OnChangingPageParameters = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnShowPageParameters(ps As Peripherals, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error Goto OnShowPageParametersError
  OnShowPageParameters = False
    
  Dim r         As ProjectData
  Dim c         As Collection
  Dim e         As Collection
  Dim para      As ParameterClass
  Dim vIndex    As Variant
  Dim sVarPre   As String
  Dim sRegPre   As String
  Dim sName     As String
  Dim d         As String
  Dim i         As Integer

  vIndex = ps.Parameters.v("x")   
  sVarPre = "GPT1" & vIndex
  sRegPre = sVarPre & "_"

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
  Set para = New ParameterClass


  If (Pagename = "Parameters") Then

    '-------------------------------------------------------------------------
    ' page: Parameters (action)
    '-------------------------------------------------------------------------
    RefreshParameterDescriptions(vIndex, para, r)

    If (Not UpdateParameter(sVarPre, ps, para , Controlname, v)) Then Exit Function


    '-------------------------------------------------------------------------
    ' page: Parameters (show)
    '-------------------------------------------------------------------------

    Set para = New ParameterClass
    RefreshParameterDescriptions(vIndex, para, r)

'    sName = sIndex & "_PARA_T2" 
'    ' disable condition
'    para.Disabled(sName) = True
'    ' tooltip if control is disabled
'    d = FormatDisabledTooltip("Fred ...")
'    para.DisabledToolTip(sName) = d

    If (Not ShowParameter(sVarPre, ps, para, v)) Then Exit Function

  End If         ' if Pagename

  OnShowPageParameters = True
  Exit Function

OnShowPageParametersError:
    Errorbox "Can not show page", Err.Description
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnShowPageGPT1 function 
'        und ist notwendig fuer die Anzeige von cboT3I.
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        iExp            der Index aus der For - Next - Schleife 
'-----------------------------------------------------------------------------
'Returns:
'        Text           vom Typ String
'*****************************************************************************
Function GetPrescalerResolution(r As ProjectData, iExp As Integer) As String
  On Error Resume Next
  Dim Exponent  As Integer
  Dim vIndex    As Variant
  
  GetPrescalerResolution = ""
  Exponent = iExp
  GetPrescalerResolution = "Fcpu / " & 2^Exponent * GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1"))
  GetPrescalerResolution = GetPrescalerResolution & " (Resolution: " & _
                           Format$(2^Exponent * GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) / _
                           GetGPT1ModuleClock(r, vIndex), "0.000") & " s)"

  
End Function 


'*****************************************************************************
'Description:
'        This function is called from the OnShowPageGPT1 function 
'        and calculate underflow time.
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        TimerNr
'-----------------------------------------------------------------------------
'Returns:
'        underflow time in s
'        
'*****************************************************************************
Function GetUnderflow(r As ProjectData, TimerNr As Variant) As Double
  On Error Resume Next
  Dim i       As Integer
  Dim vIndex  As Variant

  i = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
  
  GetUnderflow = (r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr) + 1) * _
                 ( (GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i)) / _
                 GetGPT1ModuleClock(r, vIndex) )


End Function


'*****************************************************************************
'Description:
'        This function is called from the GPT1 module
'        and calculate overflow time [s].
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        TimerNr
'-----------------------------------------------------------------------------
'Returns:
'        overflow time [s]
'
'*****************************************************************************
Function GetOverflow(r As ProjectData, TimerNr As Variant) As Double
  On Error Resume Next
  Dim i       As Integer
  Dim vIndex  As Variant

  i = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
  
  GetOverflow = (65536 - r.v(GPT12_ & "T" & TimerNr & "_T" & TimerNr)) * _
                ( (GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i)) / _
                GetGPT1ModuleClock(r, vIndex) )

End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShowPageGPT1 function 
'        and calculate the data of the timer gegister T3.
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        t               entered time [s]
'        rIndex          
'             True       for overflow time
'             False      for underflow time    
'        TimerNr
'-----------------------------------------------------------------------------
'Returns:
'        Value of T3
'
'*****************************************************************************
Function GetTimerNrValue(r As ProjectData, t As Variant, rIndex As Boolean, TimerNr As Variant) As Long
  On Error Resume Next
  Dim i       As Integer
  Dim vIndex  As Variant
  
  If (t > GetMaxResolution(r, TimerNr)) Then
    t = GetMaxResolution(r, TimerNr)
  End If
  If (t < GetMinResolution(r, TimerNr)) Then
    t = GetMinResolution(r, TimerNr)
  End If

  
  i = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
  
  If (rIndex) Then
    GetTimerNrValue = 65536 - t / ( (GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i)) / _
                      GetGPT1ModuleClock(r, vIndex) )
    'Exit Function 
  Else
    GetTimerNrValue = t / ( (GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i)) / _
                      GetGPT1ModuleClock(r, vIndex) ) - 1
    'Exit Function 
  End If

End Function 



'*****************************************************************************
'Description:
'        This function is called from the GPT1 module  
'        and calculate the maximum resolution [ms] for timer clock.
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        TimerNr         
'-----------------------------------------------------------------------------
'Returns:
'        Value of the max. resolution [s]
'
'*****************************************************************************
Function GetMaxResolution(r As ProjectData, TimerNr As Variant) As Double
  On Error Resume Next
  Dim vIndex As Variant
  Dim i As Integer

  i = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
  
  GetMaxResolution = 65536 * GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i) / _
                     GetGPT1ModuleClock(r, vIndex)

End Function 

'*****************************************************************************
'Description:
'        This function is called from the GPT1 module  
'        and calculate the maximum resolution [ms] for timer clock.
'-----------------------------------------------------------------------------
'Parameters:
'        r               Typ von ProjektData
'        TimerNr         
'-----------------------------------------------------------------------------
'Returns:
'        Value of the max. resolution [s]
'
'*****************************************************************************
Function GetMinResolution(r As ProjectData, TimerNr As Variant) As Double
  On Error Resume Next
  Dim vIndex As Variant
  Dim i As Integer
  
  
  

  i = r.v(GPT12_ & "T" & TimerNr & "CON_T" & TimerNr & "I")
  
  GetMinResolution = GetBPS1Factor(r.v(GPT12_ & "T3CON_BPS1")) * 2^(i) / _
                     GetGPT1ModuleClock(r, vIndex)

End Function 



