Attribute VB_Name = "Module3"
'#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:
'        SSC
'-----------------------------------------------------------------------------
' Description:
'        This file contains functions which are create controls for the
'        module 'SSC'.
'        Furthermore it contains functions for the event handling of
'        these controls.
'
'-----------------------------------------------------------------------------
' History:
'
'        Rev. Author         Date        Description
'        ----------------------------------------------------------------------
'        0.1    als          25-10-04     Initial version
'        0.2    als          26-11-04     changed CheckResetSSC,
'                                         added Call CheckResetSSC(r) in OnShowPinSelection function
'        0.3    Sunil        08-12-04     code related to "SSC_CON_BM" variable has been changed.
'                                         (due to removal of the variable)
'        0.4    Sunil        29-12-04     module prefix added.
'        0.5    Radhish      31-12-04     Code for resetting of enable ssc interrupt is added
'
'
'*****************************************************************************

Const TOOLTIP_DISABLED_IF_MASTER_SELECTED = "the master mode is selected"


'*****************************************************************************
'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: Pin Selection
    '-------------------------------------------------------------------------
    If (Not OnLoadPagePinSelection(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Control
    '-------------------------------------------------------------------------
    If (Not OnLoadPageControl(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Baudrate
    '-------------------------------------------------------------------------
    If (Not OnLoadPageBaudrate(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnLoadPageInterrupts(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, "SSC\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
    Dim sVarPre As String
    Dim vIndex  As Variant
    
    sVarPre = "SSC"

    OnChangingPage = False

    
    '-------------------------------------------------------------------------
    'page: ModuleClock
    '-------------------------------------------------------------------------
    If (Not OnChangingPageModuleClock(ps, Pagename)) Then Exit Function
   
   '-------------------------------------------------------------------------
    'page: Pin Selection
    '-------------------------------------------------------------------------
    If (Not OnChangingPagePinSelection(ps, Pagename)) Then Exit Function
 
    '-------------------------------------------------------------------------
    'page: SSC Control
    '-------------------------------------------------------------------------
    If (Not OnChangingPageControl(ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: SSC Baudrate
    '-------------------------------------------------------------------------
    If (Not OnChangingPageBaudrate(ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnChangingPageInterrupts(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, sVarPre)) 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
    Dim vIndex  As Variant
    
    sVarPre = "SSC"

    OnShow = False

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

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

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

    '-------------------------------------------------------------------------
    ' page: Interrupts
    '-------------------------------------------------------------------------
    If (Not OnShowPageInterrupts(ps, Controlname, Pagename, v)) 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, sVarPre, 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 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, "SSC\Dialog")) Then Exit Function
    
    OnMenuClick = True
    Exit Function

OnMenuClickError:
    Exit Function
End Function
    

'-----------------------------------------------------------------------------
' local functions
'-----------------------------------------------------------------------------
'*****************************************************************************
'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
      
      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, " SSC Disabled Flag (PMCON1) ")) Then Exit Function
            If (Not ps.AddOption("optSSC_DIS_0", 200, 350, 4700, 300, "Enable module; the peripheral is supplied with the clock signal")) Then Exit Function
            If (Not ps.AddOption("optSSC_DIS_1", 200, 825, 4400, 300, "Disable module; the clock input of peripheral 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 module [MHz]")) Then Exit Function
            If (Not ps.AddLabel("lbl_box_InputClock", 1, 3550, 400, 1000, 300, "")) Then Exit Function

      End If
'  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 bDisabled   As Boolean
  Dim e As Object
  Dim vIndex As Variant

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
    
    
If (Pagename = "Module Clock") Then
  
      Select Case (Controlname)
      
         Case "optSSC_DIS_0"
            r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 0
            
         Case "optSSC_DIS_1"
            r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1
            Call CheckResetSSC(r)
            
      End Select

        With c("optSSC_DIS_0")
            bDisabled = False
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 0)
        End With

       With c("optSSC_DIS_1")
            bDisabled = False
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)
        End With
       
       With c("lbl_txt_InputClock")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
       End With
       
        With c("lbl_box_InputClock")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            If (bDisabled) Then
                 .Caption = CALCULATION_NOT_POSSIBLE
                 Else
                .Caption = Format(r.v("MAIN_PCLK"), "00.000")
            End If
        End With
        
        With e("lbl_box_InputClock")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vIndex)
          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 a page.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successfull operation
'        False           else
'*****************************************************************************
Public Function OnLoadPagePinSelection(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPagePinSelection = False
  If (Not ps.AddPage("Pin Selection")) Then Exit Function

  OnLoadPagePinSelection = 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 OnChangingPagePinSelection(ps As Object, Pagename As String) As Boolean
  On Error Resume Next

  OnChangingPagePinSelection = False

  Dim vIndex As Variant
  Dim sIndex As String
  Dim v As Variant
  Dim iTopOffset As Integer

  vIndex = ps.Parameters.v("x")
  
  If (Not ps.ExtenderCollection("Pin Selection").Loaded) And (Pagename = "Pin Selection") Then
    ps.ExtenderCollection("Pin Selection").Loaded = True

    '-------------------------------
    ' frame: frmSSCMS
    '-------------------------------
    If (Not ps.AddFrame("frmSSCMS", 100, 100, 8500, 800, "Master Select (CONH.MS)")) Then Exit Function
        If (Not ps.AddOption("optSSCMS_0", 150, 300, 1975, 380, "Slave mode selected")) Then Exit Function
        If (Not ps.AddOption("optSSCMS_1", 4450, 300, 1975, 375, "Master mode selected")) Then Exit Function

    '-------------------------------
    ' frame: frmSSCSIS
    '-------------------------------
        
    If (Not ps.AddFrame("frmSSC_SSIS", 100, 1000, 4200, 1350, "Slave Mode Clock Input Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_SIS_0", 150, 250, 2600, 300, "No slave clock input selected")) Then Exit Function
         
        If (Not ps.AddOption("optSSC_SIS_1", 150, 600, 3400, 300, "Slave clock input SS_CLK (P 0.3) selected")) Then Exit Function
        
        '############################################# Added by Jag  12/01/06#######################################################
         If (Not ps.AddOption("optSSC_SIS_2", 150, 950, 3400, 300, "Slave clock input SS_CLK (P 1.2) selected")) Then Exit Function
        '############################################# Added by Jag ################################################################
        
        
       
    '-------------------------------
    ' frame: frmSSCCIS
    '-------------------------------
    If (Not ps.AddFrame("frmSSC_SCIS", 100, 2450, 4200, 1350, "Slave Mode Receive Input Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_CIS_0", 150, 250, 2700, 300, "No slave receive input selected")) Then Exit Function
                   
        If (Not ps.AddOption("optSSC_CIS_1", 150, 600, 3400, 300, "Slave receive input MTSR (P 0.4) selected")) Then Exit Function
        
        '############################################# Added by Jag  12/01/06#######################################################
         If (Not ps.AddOption("optSSC_CIS_2", 150, 950, 3400, 300, "Slave receive input MTSR (P 1.3) selected")) Then Exit Function
        '############################################# Added by Jag ################################################################

    
    '-------------------------------
    ' frame: frmSSCMIS
    '-------------------------------
    If (Not ps.AddFrame("frmSSC_SMIS", 100, 3900, 4200, 1350, "Slave Mode Transmit Output Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_MIS_0", 150, 250, 2700, 300, "No slave transmit output selected")) Then Exit Function
              
        If (Not ps.AddOption("optSSC_MIS_1", 150, 600, 3500, 300, "Slave transmit output MRST (P 0.5) selected")) Then Exit Function
         
        '############################################# Added by Jag  12/01/06########################################################
         If (Not ps.AddOption("optSSC_MIS_2", 150, 950, 3500, 300, "Slave transmit output MRST (P 1.4) selected")) Then Exit Function
        '############################################# Added by Jag #################################################################
              
    '-------------------------------
    ' frame: frmSSCSIS
    '-------------------------------

    If (Not ps.AddFrame("frmSSC_MSIS", 4450, 1000, 4150, 1350, "Master Mode Clock Output Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_MSIS_0", 150, 250, 2600, 300, "No master clock output selected")) Then Exit Function
             
        If (Not ps.AddOption("optSSC_MSIS_1", 150, 600, 3600, 300, "Master clock output MS_CLK (P 0.3) selected")) Then Exit Function
        
        '############################################# Added by Jag  12/01/06#########################################################
         If (Not ps.AddOption("optSSC_MSIS_2", 150, 950, 3600, 300, "Master clock output MS_CLK (P 1.2) selected")) Then Exit Function
        '############################################# Added by Jag ##################################################################
           
           

        
    '-------------------------------
    ' frame: frmSSCCIS
    '-------------------------------
    If (Not ps.AddFrame("frmSSC_MCIS", 4450, 2450, 4150, 1350, "Master Mode Receive input Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_MCIS_0", 150, 250, 2700, 300, "No master receive input selected")) Then Exit Function
        
        If (Not ps.AddOption("optSSC_MCIS_1", 150, 600, 3400, 300, "Master receive input MRST (P 0.5) selected")) Then Exit Function

       '############################################# Added by Jag  12/01/06#########################################################
         If (Not ps.AddOption("optSSC_MCIS_2", 150, 950, 3400, 300, "Master receive input MRST (P 1.4) selected")) Then Exit Function
       '############################################# Added by Jag ##################################################################
            
      
      
    '-------------------------------
    ' frame: frmSSCMIS
    '-------------------------------
    If (Not ps.AddFrame("frmSSC_MMIS", 4450, 3900, 4150, 1350, "Master Mode Transmit Output Select ")) Then Exit Function
        If (Not ps.AddOption("optSSC_MMIS_0", 150, 250, 2800, 300, "No master transmit output selected")) Then Exit Function
       
        If (Not ps.AddOption("optSSC_MMIS_1", 150, 600, 3600, 300, "Master transmit output MTSR (P 0.4) selected")) Then Exit Function
        
        '############################################# Added by Jag  12/01/06###########################################################
         If (Not ps.AddOption("optSSC_MMIS_2", 150, 950, 3600, 300, "Master transmit output MTSR (P 1.3) selected")) Then Exit Function
        '############################################# Added by Jag ####################################################################
            
        
        
       
  End If
  OnChangingPagePinSelection = 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 OnShowPagePinSelection(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPagePinSelectionError

  OnShowPagePinSelection = False
  
  Dim r As ProjectData
  Dim c As Object
  Dim e As Object
  Dim bDisabled As Boolean
  Dim vIndex As Variant
  Dim vToolIndex As Variant
  Dim sIndex As String
  Dim sPrefix As String
  Dim i As Integer

  vIndex = ps.Parameters.v("x")
  sIndex = "SSC"
  sPrefix = sIndex & "_"

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

  If (Pagename = "Pin Selection") Then
  
      Select Case (Controlname)
      
         Case "optSSCMS_0"
            r.v(SSC_PREFIX & "CONH_P_MS") = 0
            Call CheckResetSSC(r)
            
         Case "optSSCMS_1"
            r.v(SSC_PREFIX & "CONH_P_MS") = 1
            Call CheckResetSSC(r)
            
         Case "optSSC_SIS_0"
               r.v(SSC_PREFIX & "PISEL_CIS") = 0
               If r.v(SSC_PREFIX & "SSEL_SIS") = 1 Then
                  r.v(SSC_PREFIX & "SSEL_SIS") = 0
                  Call ReleaseAlternateInputPin(r, "SCK_1(Input)")
               End If
               If r.v(SSC_PREFIX & "SSEL1_SIS") = 1 Then
                  r.v(SSC_PREFIX & "SSEL1_SIS") = 0
                  Call ReleaseAlternateInputPin(r, "SCK_0(Input)")
               End If
                
         Case "optSSC_SIS_1"
              r.v(SSC_PREFIX & "PISEL_CIS") = 1
              r.v(SSC_PREFIX & "SSEL_SIS") = 1
              Call RequestAlternateInputPin(r, "SCK_1(Input)")
              If r.v(SSC_PREFIX & "SSEL1_SIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL1_SIS") = 0
                 Call ReleaseAlternateInputPin(r, "SCK_0(Input)")
              End If
         Case "optSSC_SIS_2"
              r.v(SSC_PREFIX & "PISEL_CIS") = 0
              r.v(SSC_PREFIX & "SSEL1_SIS") = 1
              Call RequestAlternateInputPin(r, "SCK_0(Input)")
              If r.v(SSC_PREFIX & "SSEL_SIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL_SIS") = 0
                 Call ReleaseAlternateInputPin(r, "SCK_1(Input)")
              End If
         
         Case "optSSC_CIS_0"
              r.v(SSC_PREFIX & "PISEL_SIS") = 0
              If r.v(SSC_PREFIX & "SSEL_CIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MTSR_1(Slave_Receive)")
              End If
              If r.v(SSC_PREFIX & "SSEL1_CIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL1_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MTSR_0(Slave_Receive)")
              End If
             
         Case "optSSC_CIS_1"
              r.v(SSC_PREFIX & "PISEL_SIS") = 1
              r.v(SSC_PREFIX & "SSEL_CIS") = 1
              Call RequestAlternateInputPin(r, "MTSR_1(Slave_Receive)")
              If r.v(SSC_PREFIX & "SSEL1_CIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL1_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MTSR_0(Slave_Receive)")
              End If
         
         Case "optSSC_CIS_2"
              r.v(SSC_PREFIX & "PISEL_SIS") = 0
              r.v(SSC_PREFIX & "SSEL1_CIS") = 1
              Call RequestAlternateInputPin(r, "MTSR_0(Slave_Receive)")
              If r.v(SSC_PREFIX & "SSEL_CIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MTSR_1(Slave_Receive)")
              End If
         Case "optSSC_MIS_0"
              If r.v(SSC_PREFIX & "SSEL_MIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MRST_1(Slave_Transmit)")
              End If
              If r.v(SSC_PREFIX & "SSEL1_MIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL1_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MRST_0(Slave_Transmit)")
              End If

         Case "optSSC_MIS_1"
              r.v(SSC_PREFIX & "SSEL_MIS") = 1
              Call RequestAlternateOutputPin(r, "MRST_1(Slave_Transmit)", ALT_FUN1)
              If r.v(SSC_PREFIX & "SSEL1_MIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL1_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MRST_0(Slave_Transmit)")
              End If
         
         Case "optSSC_MIS_2"
              r.v(SSC_PREFIX & "SSEL1_MIS") = 1
              Call RequestAlternateOutputPin(r, "MRST_0(Slave_Transmit)", ALT_FUN1)
              If r.v(SSC_PREFIX & "SSEL_MIS") = 1 Then
                 r.v(SSC_PREFIX & "SSEL_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MRST_1(Slave_Transmit)")
              End If
         
         Case "optSSC_MSIS_0"
              If r.v(SSC_PREFIX & "MSEL_SIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_SIS") = 0
                 Call ReleaseAlternateOutputPin(r, "SCK_1(Output)")
              End If
              If r.v(SSC_PREFIX & "MSEL1_SIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_SIS") = 0
                 Call ReleaseAlternateOutputPin(r, "SCK_0(Output)")
              End If
         Case "optSSC_MSIS_1"
              r.v(SSC_PREFIX & "MSEL_SIS") = 1
              Call RequestAlternateOutputPin(r, "SCK_1(Output)", ALT_FUN1)
              If r.v(SSC_PREFIX & "MSEL1_SIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_SIS") = 0
                 Call ReleaseAlternateOutputPin(r, "SCK_0(Output)")
              End If
           
         Case "optSSC_MSIS_2"
              r.v(SSC_PREFIX & "MSEL1_SIS") = 1
              Call RequestAlternateOutputPin(r, "SCK_0(Output)", ALT_FUN1)
              If r.v(SSC_PREFIX & "MSEL_SIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_SIS") = 0
                 Call ReleaseAlternateOutputPin(r, "SCK_1(Output)")
              End If
         Case "optSSC_MCIS_0"
              r.v(SSC_PREFIX & "PISEL_MIS") = 0
              If r.v(SSC_PREFIX & "MSEL_CIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MRST_1(Master_Receive)")
              End If
              If r.v(SSC_PREFIX & "MSEL1_CIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MRST_0(Master_Receive)")
              End If

         Case "optSSC_MCIS_1"
              r.v(SSC_PREFIX & "PISEL_MIS") = 1
              r.v(SSC_PREFIX & "MSEL_CIS") = 1
              Call RequestAlternateInputPin(r, "MRST_1(Master_Receive)")
              If r.v(SSC_PREFIX & "MSEL1_CIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MRST_0(Master_Receive)")
              End If
         Case "optSSC_MCIS_2"
              r.v(SSC_PREFIX & "PISEL_MIS") = 0
              r.v(SSC_PREFIX & "MSEL1_CIS") = 1
              Call RequestAlternateInputPin(r, "MRST_0(Master_Receive)")
              If r.v(SSC_PREFIX & "MSEL_CIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_CIS") = 0
                 Call ReleaseAlternateInputPin(r, "MRST_1(Master_Receive)")
              End If
         Case "optSSC_MMIS_0"
              If r.v(SSC_PREFIX & "MSEL_MIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MTSR_1(Master_Transmit)")
              End If
              If r.v(SSC_PREFIX & "MSEL1_MIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MTSR_0(Master_Transmit)")
              End If
         Case "optSSC_MMIS_1"
              r.v(SSC_PREFIX & "MSEL_MIS") = 1
              Call RequestAlternateOutputPin(r, "MTSR_1(Master_Transmit)", ALT_FUN1)
              If r.v(SSC_PREFIX & "MSEL1_MIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL1_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MTSR_0(Master_Transmit)")
              End If
         Case "optSSC_MMIS_2"
              r.v(SSC_PREFIX & "MSEL1_MIS") = 1
              Call RequestAlternateOutputPin(r, "MTSR_0(Master_Transmit)", ALT_FUN1)
              If r.v(SSC_PREFIX & "MSEL_MIS") = 1 Then
                 r.v(SSC_PREFIX & "MSEL_MIS") = 0
                 Call ReleaseAlternateOutputPin(r, "MTSR_1(Master_Transmit)")
              End If
       End Select
        
        

       With c("optSSCMS_0")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS"))
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONH_P_MS") = 0)
            If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                 If r.v(SSC_PREFIX & "MSEL_SIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL_SIS") = 0
                    Call ReleaseAlternateOutputPin(r, "SCK_1(Output)")
                 End If
                 
                 If r.v(SSC_PREFIX & "MSEL_MIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL_MIS") = 0
                    Call ReleaseAlternateOutputPin(r, "MTSR_1(Master_Transmit)")
                 End If
                 
                 If r.v(SSC_PREFIX & "MSEL_CIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL_CIS") = 0
                    Call ReleaseAlternateInputPin(r, "MRST_1(Master_Receive)")
                 End If
                
                 If r.v(SSC_PREFIX & "MSEL1_SIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL1_SIS") = 0
                    Call ReleaseAlternateOutputPin(r, "SCK_0(Output)")
                 End If
                 
                 If r.v(SSC_PREFIX & "MSEL1_MIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL1_MIS") = 0
                    Call ReleaseAlternateOutputPin(r, "MTSR_0(Master_Transmit)")
                 End If
                
                 If r.v(SSC_PREFIX & "MSEL1_CIS") = 1 Then
                    r.v(SSC_PREFIX & "MSEL1_CIS") = 0
                    Call ReleaseAlternateInputPin(r, "MRST_0(Master_Receive)")
                 End If
            End If
        End With
        

        With e("optSSCMS_0")
            If (bDisabled) Then
              .DisabledToolTipText = TOOLTIP_DISABLED_IF
              .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vIndex)
            End If
        End With

       With c("optSSCMS_1")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS"))
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONH_P_MS") = 1)
            If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
               
               '****************** Commented by jag on 30/01/06 **************************
                'r.v(SSC_PREFIX & "CONH_P_PEN") = 0
               '****************** Commented by jag on 30/01/06 **************************
               ' The above statement is commented because phase error is applicable to both master and slave modes.
               ' But the baud rate error is applicable only in the slave mode hence the following statement is to disable baud rate error enable.
               ' The above statement may be added by mistake instead of adding r.v(SSC_PREFIX & "CONH_P_TEN") = 0 because tranmitt error enable is
               ' also applicable only in slave mode.
               '****************** Added by jag on 30/01/06 **************************
                r.v(SSC_PREFIX & "CONH_P_TEN") = 0
               '****************** Added by jag on 30/01/06 **************************
                r.v(SSC_PREFIX & "CONH_P_BEN") = 0
            
                 If r.v(SSC_PREFIX & "SSEL_SIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL_SIS") = 0
                    Call ReleaseAlternateInputPin(r, "SCK_1(Input)")
                 End If
                 
                 If r.v(SSC_PREFIX & "SSEL_CIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL_CIS") = 0
                    Call ReleaseAlternateInputPin(r, "MTSR_1(Slave_Receive)")
                 End If
                 
                 If r.v(SSC_PREFIX & "SSEL_MIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL_MIS") = 0
                    Call ReleaseAlternateOutputPin(r, "MRST_1(Slave_Transmit)")
                 End If
                
                 If r.v(SSC_PREFIX & "SSEL1_SIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL1_SIS") = 0
                    Call ReleaseAlternateInputPin(r, "SCK_0(Input)")
                 End If

                 If r.v(SSC_PREFIX & "SSEL1_CIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL1_CIS") = 0
                    Call ReleaseAlternateInputPin(r, "MTSR_0(Slave_Receive)")
                 End If
                 
                 If r.v(SSC_PREFIX & "SSEL1_MIS") = 1 Then
                    r.v(SSC_PREFIX & "SSEL1_MIS") = 0
                    Call ReleaseAlternateOutputPin(r, "MRST_0(Slave_Transmit)")
                 End If
            End If
        End With
        
        With e("optSSCMS_1")
            If (bDisabled) Then
              .DisabledToolTipText = TOOLTIP_DISABLED_IF
              .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vIndex)
            End If
        End With
       With c("optSSC_SIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL_SIS") = 0)
        End With
        
        With e("optSSC_SIS_0")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
            End If
          End If
        End With

       With c("optSSC_SIS_1")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "SCK_1(Input)")))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v("SSC_SSEL_SIS") = 1)
            If (r.v("SSC_SSEL_SIS") = 1) Then
            
            End If
        End With
        
        With e("optSSC_SIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
                Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "SCK_1(Input)")
                End If
            End If
          End If
        End With


       '##################################################### Added by jag 13/01/06 #################################################################################
         With c("optSSC_SIS_2")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "SCK_0(Input)")))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v("SSC_SSEL1_SIS") = 1)
            If (r.v("SSC_SSEL1_SIS") = 1) Then
            
            End If
        End With
        
        With e("optSSC_SIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
                Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "SCK_0(Input)")
                End If
            End If
          End If
        End With
        
      '##################################################### Added by jag 13/01/06 #################################################################################

        With c("optSSC_CIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL_CIS") = 0)
        End With
        
        With e("optSSC_CIS_0")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
            End If
         End If
        End With
        
       
        With c("optSSC_CIS_1")
            'original code commented by jag 16/01/06
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_1(Slave_Receive)")))
                     
            
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_1(Slave_Receive)")) _
                     Or (r.v(SSC_PREFIX & "SSEL1_SIS") = 1))
            
            
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
            'If r.v(SSC_PREFIX & "SSEL1_SIS") = 1 Then
            '   .Enabled = bDisabled
            'Else
            '   .Enabled = Not bDisabled
            'End If
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
            
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL_CIS") = 1)
        End With
        
        With e("optSSC_CIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_1(Slave_Receive)")
'                End If
'
    '-------------------------------------------------- Tool tip for disabled pins 16/01/06 ---------------------------------------
              If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
              ElseIf (r.v(SSC_PREFIX & "SSEL1_SIS") = 1) Then
                     .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock input P0.3 is not selected")
                
              Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_1(Slave_Receive)")
              End If

             
    '-------------------------------------------------- Tool tip for disabled pins 16/01/06 ---------------------------------------
        
            End If
            
          End If
        End With

      '##################################################### Added by jag 13/01/06 #################################################################################
        With c("optSSC_CIS_2")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_0)")))
              
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_0(Slave_Receive)")) _
              Or (r.v(SSC_PREFIX & "SSEL_SIS") = 1))
            
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "SSEL_SIS") = 1 Then
'               .Enabled = bDisabled
'             Else
'               .Enabled = Not bDisabled
'            End If
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
            
            .Enabled = Not bDisabled 'original code
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL1_CIS") = 1)
        End With
      
        With e("optSSC_CIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_0)")
'                End If
     '-------------------------------------------------- Tool tip for disabled pins 16/01/06 ---------------------------------------
              If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
              
              ElseIf (r.v(SSC_PREFIX & "SSEL_SIS") = 1) Then
                     .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock input P1.2 is not selected")
                
              Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_0(Slave_Receive)")
              End If
    '-------------------------------------------------- Tool tip for disabled pins 16/01/06 ---------------------------------------
           End If
            
          End If
        End With
      '##################################################### Added by jag 13/01/06 #################################################################################


        With c("optSSC_MIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL_MIS") = 0)
        End With
        
        With e("optSSC_MIS_0")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
            End If
         End If
        End With
        
       
        With c("optSSC_MIS_1")
             'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_1(Slave_Transmit)")))
              bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_1(Slave_Transmit)")) _
               Or (r.v(SSC_PREFIX & "SSEL1_SIS") = 1))
          
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "SSEL1_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
            
            .Enabled = Not bDisabled  'original code
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL_MIS") = 1)
        End With
        
        With e("optSSC_MIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_1(Slave_Transmit)")
'                End If
           
           '-------------------------------------- Tool tip for disabled pins 16/01/06----------------------------------------
             If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
              ElseIf (r.v(SSC_PREFIX & "SSEL1_SIS") = 1) Then
                     .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock input P0.3 is not selected")
                
              Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_1(Slave_Transmit)")
              End If
           '-------------------------------------- Tool tip for disabled pins 16/01/06----------------------------------------
 
            End If
          End If
        End With

      '##################################################### Added by jag 13/01/06 #################################################################################
       With c("optSSC_MIS_2")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_0")))
            
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 1) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_0(Slave_Transmit)")) _
              Or (r.v(SSC_PREFIX & "SSEL_SIS") = 1))
           
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "SSEL_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
            
            .Enabled = Not bDisabled 'Original code
            .Value = -CInt(r.v(SSC_PREFIX & "SSEL1_MIS") = 1)
        End With
        
        With e("optSSC_MIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_0")
'                End If
'------------------------------------------------- Tool tip for disabled pins 16/01/06----------------------------------------------------------------
                 If (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
                 
                 ElseIf (r.v(SSC_PREFIX & "SSEL_SIS") = 1) Then
                     .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock input P1.2 is not selected")
                 Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_0(Slave_Transmit)")
                 End If
'------------------------------------------------- Tool tip for disabled pins 16/01/06----------------------------------------------------------------
            End If
          End If
        End With
      '##################################################### Added by jag 13/01/06 #################################################################################



       With c("optSSC_MSIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_SIS") = 0)
       End With
       
       With e("optSSC_MSIS_0")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
            End If
         End If
        End With
       
       With c("optSSC_MSIS_1")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "SCK_1(Output)")))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_SIS") = 1)
        End With
        
        With e("optSSC_MSIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
                Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "SCK_1(Output)")
                End If
            End If
          End If
        End With

      '##################################################### Added by jag 13/01/06 #################################################################################
       With c("optSSC_MSIS_2")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "SCK_0(Output)")))
            .Enabled = Not bDisabled 'original code
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL1_SIS") = 1)
        End With
        
        With e("optSSC_MSIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
                Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "SCK_0(Output)")
                End If
            End If
          End If
        End With
      '##################################################### Added by jag 13/01/06 #################################################################################

        With c("optSSC_MCIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_CIS") = 0)
        End With
        
        With e("optSSC_MCIS_0")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
            End If
         End If
        End With
        
        
        With c("optSSC_MCIS_1")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_1(Master_Receive)")))
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_1(Master_Receive)")) _
             Or (r.v(SSC_PREFIX & "MSEL1_SIS") = 1))
            
            '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "MSEL1_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
           '----------------------------------- Added to disable selection if different clock ip is selected-------------
           
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_CIS") = 1)
        End With
        
        With e("optSSC_MCIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_1(Master_Receive)")
'                End If
'
'----------------------------------------------------- Tool tip for disabled pins 16/01/06 -------------------------------------------------
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
                
                ElseIf (r.v(SSC_PREFIX & "MSEL1_SIS") = 1) Then
                   .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock output P0.3 is not selected")
                Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_1(Master_Receive)")
                End If
'------------------------------------------------------- Tool tip for disabled pins 16/01/06 -------------------------------------------------
                
            End If
          End If
        End With

      '##################################################### Added by jag 13/01/06 #################################################################################
       With c("optSSC_MCIS_2")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_0")))
            
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MRST_0(Master_Receive)")) _
             Or (r.v(SSC_PREFIX & "MSEL_SIS") = 1))
           
           '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "MSEL_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
           '----------------------------------- Added to disable selection if different clock ip is selected-------------
             
            .Enabled = Not bDisabled 'original code
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL1_CIS") = 1)
        End With
        
        With e("optSSC_MCIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_0")
'                End If
    '-------------------------------------------------------- Tool tip for disabled pins --------------------------------------------------------------------------
             If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
             
             ElseIf (r.v(SSC_PREFIX & "MSEL_SIS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock output P1.2 is not selected")
             Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MRST_0(Master_Receive)")
             End If
   '-------------------------------------------------------- Tool tip for disabled pins --------------------------------------------------------------------------
           End If
          End If
        End With
      '##################################################### Added by jag 13/01/06 #################################################################################

        With c("optSSC_MMIS_0")
            bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1))
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_MIS") = 0)
        End With
        
        With e("optSSC_MMIS_0")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
            End If
         End If
        End With
        
        With c("optSSC_MMIS_1")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_1(Master_Transmit)")))
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_1(Master_Transmit)")) _
             Or (r.v(SSC_PREFIX & "MSEL1_SIS") = 1))
             
            '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "MSEL1_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
           '----------------------------------- Added to disable selection if different clock ip is selected-------------
           
            .Enabled = Not bDisabled
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL_MIS") = 1)
        End With
        
        With e("optSSC_MMIS_1")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_1(Master_Transmit)")
'                End If
'
' --------------------------------------------------- Tool tip for disabled pins 16/01/06 ------------------------------------------------------------
                 If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
                 
                 ElseIf (r.v(SSC_PREFIX & "MSEL1_SIS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock output P0.3 is not selected")
                 Else
                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_1(Master_Transmit)")
                 End If
' --------------------------------------------------- Tool tip for disabled pins 16/01/06 ------------------------------------------------------------
           End If
          End If
        End With

      '##################################################### Added by jag 13/01/06 #################################################################################
        With c("optSSC_MMIS_2")
            'bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_0")))
             bDisabled = ((r.v(SSC_PREFIX & "CONH_P_MS") = 0) Or (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (Not IsAlternatePinFree(r, "MTSR_0(Master_Transmit)")) _
             Or (r.v(SSC_PREFIX & "MSEL_SIS") = 1))
           
           '----------------------------------- Added to disable selection if different clock ip is selected-------------
'            If r.v(SSC_PREFIX & "MSEL_SIS") = 1 Then
'               .Enabled = bDisabled
'            Else
'               .Enabled = Not bDisabled
'            End If
          '----------------------------------- Added to disable selection if different clock ip is selected-------------
           
            .Enabled = Not bDisabled  'original code
            .Value = -CInt(r.v(SSC_PREFIX & "MSEL1_MIS") = 1)
        End With
        
        With e("optSSC_MMIS_2")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
            Else
'                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
'                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
'                Else
'                    .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_0")
'                End If
'----------------------------------- Tool tip for disabled pins --------------------------------------------------------------------------------------
                If (r.v(SSC_PREFIX & "CONH_P_MS") = 0) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the master mode is not selected")
                ElseIf (r.v(SSC_PREFIX & "MSEL_SIS") = 1) Then
                     .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the clock output P1.2 is not selected")
                Else
                     .DisabledToolTipText = .DisabledToolTipText & GetDisabledAlternatePinToolTip(r, "MTSR_0(Master_Transmit)")
                End If
'----------------------------------- Tool tip for disabled pins --------------------------------------------------------------------------------------
            End If
          End If
        End With
      '##################################################### Added by jag 13/01/06 #################################################################################
 
  End If

  OnShowPagePinSelection = True
  Exit Function

OnShowPagePinSelectionError:
  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 OnLoadPageControl(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageControl = False

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

  OnLoadPageControl = 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 OnChangingPageControl(ps As Object, Pagename As String) As Boolean
  On Error Resume Next
  Dim iPin As Integer
  
  OnChangingPageControl = False
  
  If (Not ps.ExtenderCollection("Control").Loaded) And (Pagename = "Control") Then
    ps.ExtenderCollection("Control").Loaded = True
  
    '-------------------------------
    ' frame: Data Control
    '-------------------------------
    If (Not ps.AddFrame("Data Control", 100, 200, 4200, 1200, "Data Control")) Then Exit Function
        If (Not ps.AddCombo("cboSSCBM", 2325, 300, 1300, 315)) Then Exit Function
        If (Not ps.AddLabel("lblSSCBM", 0, 200, 350, 1700, 395, "Data Width (BM)")) Then Exit Function
 
    '-------------------------------
    ' frame: frmErrCon
    '-------------------------------
    If (Not ps.AddFrame("frmErrCon", 100, 1500, 4200, 2400, "Error Control")) Then Exit Function
        If (Not ps.AddCheck("chkSSCTEN", 200, 200, 2600, 380, "Check transmit errors (TEN)")) Then Exit Function
        If (Not ps.AddCheck("chkSSCREN", 200, 550, 2600, 380, "Check receive errors (REN)")) Then Exit Function
        If (Not ps.AddCheck("chkSSCPEN", 200, 900, 2600, 380, "Check phase errors (PEN)")) Then Exit Function
        If (Not ps.AddCheck("chkSSCBEN", 200, 1250, 2600, 380, "Check baud rate errors (BEN)")) Then Exit Function
        If (Not ps.AddCheck("chkSSCAREN", 350, 1650, 3300, 380, "SSC is automatically reset upon baud rate error (AREN)")) Then Exit Function
 
    '-------------------------------
    ' frame: frmSSCPO
    '-------------------------------
    If (Not ps.AddFrame("frmSSCPO", 100, 4050, 4200, 1250, "Clock Polarity Control (PO)")) Then Exit Function
        If (Not ps.AddOption("optSSCPO_0", 200, 250, 3350, 375, "Idle clock line is low, leading clock edge is low-to-high transition")) Then Exit Function
        If (Not ps.AddOption("optSSCPO_1", 200, 700, 3450, 380, "Idle clock line is high, leading clock edge is high-to-low transition")) Then Exit Function

    '-------------------------------
    ' frame: frmSSCHB
    '-------------------------------
    If (Not ps.AddFrame("frmSSCHB", 4425, 200, 4150, 1200, "Heading Control (HB)")) Then Exit Function
        If (Not ps.AddOption("optSSCHB_0", 200, 350, 2400, 300, "Transmit/Receive LSB first")) Then Exit Function
        If (Not ps.AddOption("optSSCHB_1", 200, 850, 2400, 300, "Transmit/Receive MSB first")) Then Exit Function

    '-------------------------------
    ' frame: frmIC
    '-------------------------------
    If (Not ps.AddFrame("frmIC", 4425, 1500, 4150, 1100, "Interrupt Control")) Then Exit Function
        If (Not ps.AddCheck("chkSSCIE", 200, 300, 2800, 380, "Enable general SSC interrupt (IE)")) Then Exit Function

    If (Not ps.AddFrame("frmLM", 4425, 2800, 4150, 1100, "Loop Back Mode")) Then Exit Function
        If (Not ps.AddCheck("chklbm", 200, 300, 2700, 380, "Enable Loop Back Mode (LB)")) Then Exit Function
    
    '-------------------------------
    ' frame: frmSSCPH
    '-------------------------------
    If (Not ps.AddFrame("frmSSCPH", 4425, 4050, 4150, 1250, "Clock Phase Control (PH)")) Then Exit Function
        If (Not ps.AddOption("optSSCPH_0", 200, 250, 3600, 380, "Shift transmit data on the leading clock edge, latch on trailing edge")) Then Exit Function
        If (Not ps.AddOption("optSSCPH_1", 200, 700, 3600, 380, "Latch receive data on the leading clock edge, shift on trailing edge")) Then Exit Function

  End If
  OnChangingPageControl = 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 OnShowPageControl(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageControlError

  OnShowPageControl = False

  Dim r           As ProjectData
  Dim c           As Object
  Dim e           As Object
  Dim i           As Integer
  Dim vToolIndex  As Variant
  Dim vIndex      As Variant
  Dim bDisabled   As Boolean

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

  If (Pagename = "Control") Then
  
    Select Case (Controlname)
    
        Case "cboSSCBM"
            r.v(SSC_PREFIX & "CONL_P_BM") = c("cboSSCBM").ListIndex + 1
            
        Case "chkSSCTEN"
            r.v(SSC_PREFIX & "CONH_P_TEN") = v(1)
        Case "chkSSCREN"
            r.v(SSC_PREFIX & "CONH_P_REN") = v(1)
        Case "chkSSCPEN"
            r.v(SSC_PREFIX & "CONH_P_PEN") = v(1)
        Case "chkSSCBEN"
            r.v(SSC_PREFIX & "CONH_P_BEN") = v(1)
            r.v("SSC_CONH_P_AREN") = 0
        Case "chkSSCAREN"
            r.v(SSC_PREFIX & "CONH_P_AREN") = v(1)

        Case "optSSCPO_0"
            r.v(SSC_PREFIX & "CONL_P_PO") = 0
        Case "optSSCPO_1"
            r.v(SSC_PREFIX & "CONL_P_PO") = 1
         
        Case "optSSCHB_0"
            r.v(SSC_PREFIX & "CONL_P_HB") = 0
        Case "optSSCHB_1"
            r.v(SSC_PREFIX & "CONL_P_HB") = 1

        Case "chkSSCIE"
            r.v(SSC_PREFIX & "USE_ISR") = v(1)
            r.v(CORE_PREFIX & "IEN1_ESSC") = v(1)
  
        Case "chklbm"
            r.v(SSC_PREFIX & "CONL_P_LB") = v(1)

        Case "optSSCPH_0"
            r.v(SSC_PREFIX & "CONL_P_PH") = 0
        Case "optSSCPH_1"
            r.v(SSC_PREFIX & "CONL_P_PH") = 1

    End Select
            
'--------------------------------------------------------------------------------------
' on show
'--------------------------------------------------------------------------------------

        With c("lblSSCBM")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
        End With
        
        With e("lblSSCBM")
        If (bDisabled) Then
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
       
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
        End If
        End With
    
        With c("cboSSCBM")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Clear
            For i = 2 To 8
            .AddItem " " & i
            Next i
                .ListIndex = r.v(SSC_PREFIX & "CONL_P_BM") - 1
        End With
     
        With e("cboSSCBM")
        If (bDisabled) Then
          
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
           
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
        End If
        End With
        
        With c("chkSSCTEN")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (r.v(SSC_PREFIX & "CONH_P_MS") = 1) _
                         Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v(SSC_PREFIX & "CONH_P_TEN")
        End With
        
        With e("chkSSCTEN")
            If (bDisabled) Then
                .DisabledToolTipText = TOOLTIP_DISABLED_IF
                If (IsModuleClockDisabled(r, vToolIndex)) Then
                    .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vIndex)
             ElseIf (Not SSCPinSelected(r)) Then
          
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the pins are not selected")
          
                ElseIf (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                    .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
                End If
          End If
        End With
     
        With c("chkSSCREN")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v(SSC_PREFIX & "CONH_P_REN")
        End With
        
        With e("chkSSCREN")
            If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
             End If
        End With
     
        With c("chkSSCPEN")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v(SSC_PREFIX & "CONH_P_PEN")
        End With
        
        With e("chkSSCPEN")
          If (bDisabled) Then
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
          
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
             End If
         
        End With
     
        With c("chkSSCBEN")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or (r.v(SSC_PREFIX & "CONH_P_MS") = 1) _
                         Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v(SSC_PREFIX & "CONH_P_BEN")
        End With
        
        With e("chkSSCBEN")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
             ElseIf (Not SSCPinSelected(r)) Then
          
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the pins are not selected")
          
          
            ElseIf (r.v(SSC_PREFIX & "CONH_P_MS") = 1) Then
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the slave mode is not selected")
          End If
          End If
          
        End With
     
        With c("chkSSCAREN")
            bDisabled = (((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) And (r.v(SSC_PREFIX & "CONH_P_BEN") = 1)) Or (r.v(SSC_PREFIX & "CONH_P_BEN")) = 0) _
                         Or Not SSCPinSelected(r)
           .Enabled = Not bDisabled
           .Value = r.v(SSC_PREFIX & "CONH_P_AREN")
        End With
        
        With e("chkSSCAREN")
          If (bDisabled) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
             If (IsModuleClockDisabled(r, vToolIndex)) Then
                .DisabledToolTipText = .DisabledToolTipText & GetTooltipModuleClockDisabled(r, vToolIndex)
             ElseIf (Not SSCPinSelected(r)) Then
          
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the pins are not selected")
            ElseIf (r.v(SSC_PREFIX & "CONH_P_BEN") = 0) Then
                .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("the check baud rate error (BEN) is disabled")
           End If
           End If
          
        End With
     
     
          With c("optSSCHB_0")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_HB") = 0)
          End With
        
        With e("optSSCHB_0")
      If (bDisabled) Then
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
           
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

        With c("optSSCHB_1")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_HB") = 1)
        End With
        
        With e("optSSCHB_1")
      If (bDisabled) Then
          
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With
        
       With c("chkSSCIE")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v("SSC_USE_ISR")
        End With
        
        With e("chkSSCIE")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

       With c("chklbm")
            bDisabled = (r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1) Or Not SSCPinSelected(r)
            .Enabled = Not bDisabled
            .Value = r.v(SSC_PREFIX & "CONL_P_LB")
        End With
        
        With e("chklbm")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

        With c("optSSCPO_0")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_PO") = 0)
        End With
    
        With e("optSSCPO_0")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With
    
        With c("optSSCPO_1")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_PO") = 1)
        End With
    
        With e("optSSCPO_1")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

        With c("optSSCPH_0")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_PH") = 0)
        End With

        With e("optSSCPH_0")
      If (bDisabled) Then
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

        With c("optSSCPH_1")
            bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
            .Enabled = Not (bDisabled)
            .Value = -CInt(r.v(SSC_PREFIX & "CONL_P_PH") = 1)
        End With

        With e("optSSCPH_1")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
        End With

  End If

  OnShowPageControl = True
  Exit Function

OnShowPageControlError:
  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 OnLoadPageBaudrate(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageBaudrate = False

  If (Not ps.AddPage("Baud Rate")) Then Exit Function

  OnLoadPageBaudrate = 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 OnChangingPageBaudrate(ps As Object, Pagename As String) As Boolean
  On Error Resume Next

  OnChangingPageBaudrate = False
  
  If (Not ps.ExtenderCollection("Baud Rate").Loaded) And (Pagename = "Baud Rate") Then
    ps.ExtenderCollection("Baud Rate").Loaded = True
    '-------------------------------
    ' frame: frmSSCBR
    '-------------------------------
    If (Not ps.AddFrame("frmSSCBR", 100, 100, 8475, 2550, "Baud Rate ")) Then Exit Function

        If (Not ps.Addtext("txtRequiredBaudrate", 1800, 600, 1000, 300)) Then Exit Function
        If (Not ps.AddLabel("lblRequiredBaudrate", 0, 200, 600, 1450, 400, "Required baud rate [kbaud]")) Then Exit Function

        If (Not ps.AddLabel("lbltMinBaudrate", 1, 1800, 1200, 1000, 300, " ")) Then Exit Function
        If (Not ps.AddLabel("lblMinBaudrate", 0, 200, 1200, 1175, 400, "Min. baud rate [kbaud]")) Then Exit Function

        If (Not ps.AddLabel("lbltMaxBaudrate", 1, 1800, 1800, 1000, 300, "")) Then Exit Function
        If (Not ps.AddLabel("lblMaxBaudrate", 0, 200, 1800, 1175, 400, "Max. baud rate [kbaud]")) Then Exit Function

        If (Not ps.AddLabel("lbltRealBaudrate", 1, 6125, 600, 1000, 300, "")) Then Exit Function
        If (Not ps.AddLabel("lblRealBaudrate", 0, 4500, 600, 1200, 400, "Real baud rate [kbaud]")) Then Exit Function

        If (Not ps.AddLabel("lbltPercentage", 1, 6125, 1200, 1000, 300, "")) Then Exit Function
        If (Not ps.AddLabel("lblPercentage", 0, 4500, 1200, 1200, 400, "Percentage of deviation [%]")) Then Exit Function

        If (Not ps.Addtext("txtSSCBR", 6125, 1800, 1000, 300)) Then Exit Function
        If (Not ps.AddLabel("lblSSCBR", 0, 4500, 1800, 1200, 400, "Reload value (SSC_BR)")) Then Exit Function

  End If
  OnChangingPageBaudrate = 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 OnShowPageBaudrate(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageBaudrateError

  OnShowPageBaudrate = False

  Dim r           As ProjectData
  Dim c           As Object
  Dim e           As Object
  Dim bDisabled   As Boolean
  Dim vIndex      As Variant
  Dim vTemp       As Variant
  Dim Baudrate    As BaudrateType
  Dim MaxBaudRate As BaudrateType

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
  
  If (Pagename = "Baud Rate") Then
    
    '-------------------------------------------------------------------------
    ' page: Baudrate (action)
    '-------------------------------------------------------------------------

    Select Case (Controlname)
      
        Case "txtRequiredBaudrate"
             Baudrate = ConvertBaudrate(r.l("SSC_Baudrate"))
            
             MaxBaudRate = ConvertBaudrate(GetSSCMaxBaudrate(r, vIndex))
 
              If (IsInputFormatOK(v(1), "F", c("lblRequiredBaudrate").Caption)) Then
              
               If (IsInputValueOK(Format(v(1) * Baudrate.dDivider, SSC_PRECISION), _
                   Format(GetSSCMinBaudrate(r, vIndex), SSC_PRECISION), _
                   Format(Format(GetSSCMaxBaudrate(r, vIndex) / MaxBaudRate.dDivider, _
                   SSC_PRECISION) * MaxBaudRate.dDivider, SSC_PRECISION))) Then
                 r.d("SSC_Baudrate") = v(1) * Baudrate.dDivider  ' convert to baud
                 
                 Call UpdateSSCBaudrate(r, vIndex)
               Else
                 Exit Function
               End If
             Else
               Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: txtSSCBR (action)
        '---------------------------------------------------------------------
        Case "txtSSCBR"
             If (IsInputFormatOK(v(1), "H4", c("lblSSCBR").Caption, _
                 1 - r.l(SSC_PREFIX & "CONH_P_MS"), 65535)) Then
               r.v(SSC_PREFIX & "BR") = v(1)
               r.d("SSC_Baudrate") = Format(GetSSCRealBaudrate(r, vIndex), "0.0000")
             Else
                 Exit Function
             End If

      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: Baudrate (show)
    '-------------------------------------------------------------------------
    bDisabled = IsModuleClockDisabled(r, vIndex) Or Not SSCPinSelected(r)
    '-------------------------------------------------------------------------
    ' control: txtRequiredBaudrate (show)
    '-------------------------------------------------------------------------
    With c("txtRequiredBaudrate")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Text = CALCULATION_NOT_POSSIBLE
        c("lblRequiredBaudrate").Caption = "Required baud rate [baud]"
      Else
        Baudrate = ConvertBaudrate(r.d("SSC_Baudrate"))
        .Text = Format(Baudrate.dValue, SSC_PRECISION)
        c("lblRequiredBaudrate").Caption = "Required baud rate [" & Baudrate.sUnit & "]"
      End If
    End With

    With e("txtRequiredBaudrate")
      If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblRequiredBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lblRequiredBaudrate")
      .Enabled = Not (bDisabled)
    End With
    
    '-------------------------------------------------------------------------
    ' control: txtRealBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lbltRealBaudrate")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Caption = CALCULATION_NOT_POSSIBLE
        c("lblRealBaudrate").Caption = "Real baud rate [baud]"
      Else
        Baudrate = ConvertBaudrate(GetSSCRealBaudrate(r, vIndex))
        .Caption = Format(Baudrate.dValue, SSC_PRECISION)
        c("lblRealBaudrate").Caption = "Real baud rate [" & Baudrate.sUnit & "]"
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblRealBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lblRealBaudrate")
      .Enabled = Not (bDisabled)
    End With

    '-------------------------------------------------------------------------
    ' control: txtMinBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lbltMinBaudrate")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Caption = CALCULATION_NOT_POSSIBLE
        c("lblMinBaudrate").Caption = "Min. baud rate [baud]"
      Else
        Baudrate = ConvertBaudrate(GetSSCMinBaudrate(r, vIndex))
        .Caption = Format(Baudrate.dValue, SSC_PRECISION)
        c("lblMinBaudrate").Caption = "Min. baud rate [" & Baudrate.sUnit & "]"
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblMinBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lblMinBaudrate")
      .Enabled = Not (bDisabled)
    End With
   
    '-------------------------------------------------------------------------
    ' control: txtPercentage (show)
    '-------------------------------------------------------------------------
    With c("lbltPercentage")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Caption = CALCULATION_NOT_POSSIBLE
      Else
        .Caption = Format((GetSSCRealBaudrate(r, vIndex) - r.d("SSC_Baudrate")) / _
                         r.d("SSC_Baudrate") * 100, "0.000")
      End If

    End With
    
    '-------------------------------------------------------------------------
    ' control: lblPercentage (show)
    '-------------------------------------------------------------------------
    With c("lblPercentage")
      .Enabled = Not (bDisabled)
    End With

    '-------------------------------------------------------------------------
    ' control: txtMaxBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lbltMaxBaudrate")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Caption = CALCULATION_NOT_POSSIBLE
        c("lblMaxBaudrate").Caption = "Max. baud rate [baud]"
      Else
        Baudrate = ConvertBaudrate(GetSSCMaxBaudrate(r, vIndex))
        .Caption = Format(Baudrate.dValue, SSC_PRECISION)
        c("lblMaxBaudrate").Caption = "Max. baud rate [" & Baudrate.sUnit & "]"
      End If
    End With
    
    '-------------------------------------------------------------------------
    ' control: lblMaxBaudrate (show)
    '-------------------------------------------------------------------------
    With c("lblMaxBaudrate")
      .Enabled = Not (bDisabled)
    End With
    
    '-------------------------------------------------------------------------
    ' control: txtSSCBR (show)
    '-------------------------------------------------------------------------
    With c("txtSSCBR")
      .Enabled = Not (bDisabled)
      If (bDisabled) Then
        .Text = CALCULATION_NOT_POSSIBLE
      Else
          Call UpdateSSCBaudrate(r, vIndex) 'ashish
        .Text = FormatTextOutput(r.l(SSC_PREFIX & "BR"), "H4")
      End If
    End With

    With e("txtSSCBR")
      If (bDisabled) Then
          .DisabledToolTipText = TOOLTIP_DISABLED_IF
            
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblSSCBR (show)
    '-------------------------------------------------------------------------
    With c("lblSSCBR")
      .Enabled = Not (bDisabled)
    End With

  End If

  OnShowPageBaudrate = True
  Exit Function

OnShowPageBaudrateError:
  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
 Dim pos As Long

  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, 4600, 700, CAPTION_FRA_USE_INIT)) Then Exit Function
      If (Not ps.AddCheck("chkSSC_USE_Init", 200, 270, 2100, 380, "SSC_vInit")) Then Exit Function
      If (Not ps.Addtext("txtSSC_NAME_Init", 2650, 300, 1800, 315)) Then Exit Function

    '-------------------------------
    ' frame: fra_CFile
    '-------------------------------
    If (Not ps.AddFrame("fra_CFile", 4800, 100, 3800, 700, CAPTION_FRA_CFILE)) Then Exit Function
      If (Not ps.Addtext("txtSSC_CFile", 1475, 250, 2100, 325)) Then Exit Function
      If (Not ps.AddLabel("lblSSC_CFile", 0, 200, 300, 1250, 275, CAPTION_LBL_CFILE)) Then Exit Function

        '-------------------------------
    ' frame: fraLibrary1
    '-------------------------------
        If (Not ps.AddFrame("fraLibrary1", 100, 900, 8475, 3200, CAPTION_FRA_LIBRARY1)) Then Exit Function
    pos = 0

    ' Functions and Macros
    If (Not ps.AddCheck("chkSSC_USE_Isr", 200, 270 + pos * 300, 1000, 380, "SSC_vIsr")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_Isr", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_SendData", 200, 270 + pos * 300, 1600, 380, "SSC_vSendData")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_SendData", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_GetData", 200, 270 + pos * 300, 1400, 380, "SSC_vGetData")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_GetData", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_Error", 200, 270 + pos * 300, 1300, 380, "SSC_ubError")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_Error", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1
    
    If (Not ps.AddCheck("chkSSC_USE_Busy", 200, 270 + pos * 300, 1300, 380, "SSC_ubBusy")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_Busy", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_ProgrammingMode", 200, 270 + pos * 300, 2300, 380, "SSC_ubProgrammingMode")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_ProgrammingMode", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_OperatingMode", 200, 270 + pos * 300, 2100, 380, "SSC_ubOperatingMode")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_OperatingMode", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1

    If (Not ps.AddCheck("chkSSC_USE_SetLoopBackMode", 200, 270 + pos * 300, 2300, 380, "SSC_ubSetLoopBackMode")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_SetLoopBackMode", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function
    pos = pos + 1
    
    If (Not ps.AddCheck("chkSSC_USE_ResetLoopBackMode", 200, 270 + pos * 300, 2500, 380, "SSC_ubResetLoopBackMode")) Then Exit Function
    If (Not ps.Addtext("txtSSC_NAME_ResetLoopBackMode", 2800, 300 + pos * 300, 2500, 315)) Then Exit Function

    pos = pos + 1
    
    
  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 sName As String

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection
  Set func = New FunctionClass
  
If (Pagename = "Functions") Then
    Call RefreshFunctionDescriptions(func, r)

  Select Case Controlname
        Case "chkSSC_USE_Init"
            r.v("SSC_USE_Init") = v(1)
    
        Case "txtSSC_NAME_Init"
            If (IsInputFormatOK(v(1), FORMAT_FUNCTIONS, c("chkSSC_USE_Init").Caption)) Then
                r.v("SSC_NAME_Init") = v(1)
            Else
                Exit Function
            End If

        Case "txtSSC_CFile"
            If (IsInputFormatOK(v(1), FORMAT_FILES, c("lblSSC_CFile").Caption)) Then
                r.v("SSC_CFile") = v(1)
            Else
               Exit Function
            End If
    End Select     ' case Controlname

    If (Not UpdateFunction(ps, Controlname, v, "Isr")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "SendData")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "GetData")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "Error")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "Busy")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "ProgrammingMode")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "OperatingMode")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "SetLoopBackMode")) Then Exit Function
    If (Not UpdateFunction(ps, Controlname, v, "ResetLoopBackMode")) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Functions (show)
    '-------------------------------------------------------------------------
    Call RefreshFunctionDescriptions(func, r)

    '-------------------------------------------------------------------------
    ' control: chkSSC_USE_Init (show)
    '-------------------------------------------------------------------------
   With c("chkSSC_USE_Init")
    bDisabled = ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Or Not SSCPinSelected(r)
    .Enabled = Not bDisabled
   .Value = -CInt(r.v("SSC_USE_Init") = 1)
   End With
   
   With e("chkSSC_USE_Init")
   If (bDisabled) Then
           .DisabledToolTipText = TOOLTIP_DISABLED_IF
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
           
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
           Else
           .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
          End If
       
     Else
   .EnabledTooltipText = FormatFunctionToolTip(r, func, "SSC_NAME_Init")
   End If
 End With
    '-------------------------------------------------------------------------
    ' control: txtSSC_NAME_Init (show)
'    '-------------------------------------------------------------------------
    With c("txtSSC_NAME_Init")
        bDisabled = (r.v("SSC_USE_Init") = 0) Or Not SSCPinSelected(r)
        .Enabled = Not bDisabled
        .Text = FormatTextOutput(r.s("SSC_NAME_Init"), "S")
    End With

    With e("txtSSC_NAME_Init")
        If (bDisabled) Then
           
            .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_FUNC_NAME)
            
        End If
    End With
  
    If (Not ShowFunction(ps, v, func, "Isr")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "SendData")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "GetData")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "Error")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "Busy")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "ProgrammingMode")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "OperatingMode")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "SetLoopBackMode")) Then Exit Function
    If (Not ShowFunction(ps, v, func, "ResetLoopBackMode")) Then Exit Function

    '-------------------------------------------------------------------------
    ' control: txtSSC_CFile (show)
    '-------------------------------------------------------------------------

    With c("lblSSC_CFile")
        bDisabled = (r.v("SSC_USE_Init") = 0) Or Not SSCPinSelected(r)
        .Enabled = Not bDisabled
    End With

    With e("lblSSC_CFile")
        If (bDisabled) Then
            .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_CFILE_NAME)
        End If
    End With

    With c("txtSSC_CFile")
        bDisabled = (r.v("SSC_USE_Init") = 0) Or Not SSCPinSelected(r)
        .Enabled = Not bDisabled
        .Text = FormatTextOutput(r.v("SSC_CFile"), "S")
    End With

    With e("txtSSC_CFile")
        If (bDisabled) Then
         If (Not SSCPinSelected(r)) Then
           .DisabledToolTipText = FormatNormalToolTip("this text is disabled because the pins are not selected")
           Else
            .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_CFILE_NAME)
        End If
        End If
    End With

  End If
  OnShowPageFunctions = True
  Exit Function

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


'*****************************************************************************
'Description:
'-----------------------------------------------------------------------------
'Parameters:
'        r               reference to the Project Data Object
'        Controlname     control name
'        v()             value array
'        sName           function keyword
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function UpdateFunction(ps As Peripherals, Controlname As String, v() As Variant, sName As String) As Boolean
  On Error GoTo ExitLabel
  UpdateFunction = False

  Dim r As ProjectData
  Dim c As Collection

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

  '---------------------------------------------------------------------
  ' control: chkSSC_USE_.. (action)
  '---------------------------------------------------------------------
  If (Controlname = "chkSSC_USE_" & sName) Then
    r.v("SSC_USE_" & sName) = v(1)
  End If

  '---------------------------------------------------------------------
  ' control: txtSSC_NAME_.. (action)
  '---------------------------------------------------------------------
  If (Controlname = "txtSSC_NAME_" & sName) Then
    If (IsInputFormatOK(v(1), FORMAT_FUNCTIONS, c("chkSSC_USE_" & sName).Caption)) Then
        r.v("SSC_NAME_" & sName) = v(1)
    Else
        Exit Function
    End If
  End If

  UpdateFunction = True
ExitLabel:
End Function


'*****************************************************************************
'Description:
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        v()             value array
'        func            reference to the function object
'        sName           function keyword
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function ShowFunction(ps As Peripherals, v() As Variant, func As FunctionClass, sName As String) As Boolean
  On Error GoTo ExitLabel
  ShowFunction = False
    
  Dim r As ProjectData
  Dim c As Collection
  Dim e As Collection
  Dim bDisabled As Boolean

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

  '-------------------------------------------------------------------------
  ' control: chkSSC_USE_.. (show)
  '-------------------------------------------------------------------------
  ' action on showing the control
  With c("chkSSC_USE_" & sName)
    ' disable condition
    Select Case sName

        Case "Isr"      ' ISR functions are always disabled
            bDisabled = True

        Case Else
            bDisabled = (r.v("SSC_USE_Init") = 0) Or Not SSCPinSelected(r)

    End Select

    .Enabled = Not bDisabled
    .Value = -CInt((r.v("SSC_USE_Init") = 1) And (r.v("SSC_USE_" & sName) = 1))
  End With


  With e("chkSSC_USE_" & sName)
    If (bDisabled) Then
        ' tooltip if control is disabled
        Select Case sName
            Case "Isr"      ' ISR functions are always disabled
                .DisabledToolTipText = TOOLTIP_DISABLED_ISR & vbCrLf & FormatFunctionToolTip(r, func, "SSC_NAME_" & sName)

            Case Else
            
            If ((r.v(SCU_PREFIX & "PMCON1_SSC_DIS") = 1)) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("ssc module clock is not enabled")
            ElseIf (Not SSCPinSelected(r)) Then
            .DisabledToolTipText = TOOLTIP_DISABLED_IF
            .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip("The pins are not selected")
              Else
            .DisabledToolTipText = GetDisabledFunctionTooltipEntry(func, "SSC_NAME_" & sName)
            .DisabledToolTipText = .DisabledToolTipText & FormatDisabledToolTip(TOOLTIP_DESELECTED_INIT)
          End If
        End Select
    Else
        ' tooltip if control is enabled
        .EnabledTooltipText = FormatFunctionToolTip(r, func, "SSC_NAME_" & sName)
    End If
  End With

  '-------------------------------------------------------------------------
  ' control: txtSSC_NAME_... (show)
  '-------------------------------------------------------------------------
  With c("txtSSC_NAME_" & sName)
    bDisabled = c("chkSSC_USE_" & sName).Value = 0
    .Enabled = Not bDisabled
    .Text = FormatTextOutput(r.s("SSC_NAME_" & sName), "S")
  End With

  With e("txtSSC_NAME_" & sName)
    If (bDisabled) Then
        .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_FUNC_NAME)
    End If
  End With

  ShowFunction = True
ExitLabel:
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

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

    '-------------------------------------------------------------------------
    ' frame: frmCAPCOMx_HFile
    '-------------------------------------------------------------------------
    If (Not ps.AddFrame("fraSSC_HFile", 100, 100, 4150, 700, CAPTION_FRA_HFILE)) Then Exit Function
      If (Not ps.Addtext("txtSSC_HFile", 1475, 250, 2500, 325)) Then Exit Function
      If (Not ps.AddLabel("lblSSC_HFile", 0, 200, 300, 1250, 300, CAPTION_LBL_HFILE)) Then Exit Function

  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 bDisabled As Boolean
  Dim iChannel As Integer

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


  If (Pagename = "Parameters") Then
    '-------------------------------------------------------------------------
    ' page: Parameters (action)
    '-------------------------------------------------------------------------
    Select Case Controlname
        Case "txtSSC_HFile"
            If (IsInputFormatOK(v(1), FORMAT_FILES, c("lblSSC_HFile").Caption)) Then
                r.v("SSC_HFile") = v(1)
            End If

    End Select

    '-------------------------------------------------------------------------
    ' page: Parameters (show)
    '-------------------------------------------------------------------------
    '-------------------------------------------------------------------------
    ' control: lblSSC_HFile (show)
    '-------------------------------------------------------------------------
    With c("lblSSC_HFile")
      bDisabled = (r.v("SSC_USE_Init") = 0)
      .Enabled = Not bDisabled
    End With

    With e("lblSSC_HFile")
      If (bDisabled) Then
        .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_HFILE_NAME)
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtSSC_HFile (show)
    '-------------------------------------------------------------------------
    With c("txtSSC_HFile")
      bDisabled = (r.v("SSC_USE_Init") = 0)
      .Enabled = Not bDisabled
      .Text = FormatTextOutput(r.v("SSC_HFile"), "S")
    End With

    With e("txtSSC_HFile")
      If (bDisabled) Then
        .DisabledToolTipText = FormatNormalToolTip(TOOLTIP_DISABLED_HFILE_NAME)
      End If
    End With


  End If         ' if Pagename

  OnShowPageParameters = True
  Exit Function

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


