⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cc6.c

📁 keil c51 UV3 最新版编译器的例子程序4。
💻 C
📖 第 1 页 / 共 3 页
字号:

    CCU6_CC62SRL    = (ubyte) (Value & 0x00FF);    //  Load Channel Shadow Register CC62
  }

  if ( ChName == 3)          //  if Channel_3
  {
    CCU6_CC63SRH    = (ubyte) (Value >> 8);        //  Load Channel Shadow Register CC63

    CCU6_CC63SRL    = (ubyte) (Value & 0x00FF);    //  Load Channel Shadow Register CC63
  }

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

} //  End of function CC6_vLoadChannelShadowRegister


//****************************************************************************
// @Function      void CC6_vSetStatusBit(ubyte ChName) 
//
//----------------------------------------------------------------------------
// @Description   This function sets the capture / compare modifikation 
//                status bit of the selected CC6 channel. 
//                The following definitions are available for ChName: 
//                CC6_CHANNEL_0 .. CC6_CHANNEL_3 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    ChName: 
//                Name of the CC6 channel to be used
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (SetStatusBit,1)

// USER CODE END

void CC6_vSetStatusBit(ubyte ChName)
{

  SFR_PAGE(_cc0, SST2);          // switch to page 0

  if ( ChName == 0)              //  if Channel_0
    CCU6_CMPMODIFL   |= 0x01;         //  Set Compare State Modification

  if ( ChName == 1)              //  if Channel_1
    CCU6_CMPMODIFL   |= 0x02;         //  Set Compare State Modification

  if ( ChName == 2)              //  if Channel_2
    CCU6_CMPMODIFL   |= 0x04;         //  Set Compare State Modification

  if ( ChName == 3)              //  if Channel_3
    CCU6_CMPMODIFL   |= 0x40;         //  Set Compare State Modification

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

} //  End of function CC6_vSetStatusBit


//****************************************************************************
// @Function      void CC6_vResetStatusBit(ubyte ChName) 
//
//----------------------------------------------------------------------------
// @Description   This function resets the capture / compare modifikation 
//                status bit of the selected CC6 channel. 
//                The following definitions are available for ChName: 
//                CC6_CHANNEL_0 .. CC6_CHANNEL_3 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    ChName: 
//                Name of the CC6 channel to be used
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (ResetStatusBit,1)

// USER CODE END

void CC6_vResetStatusBit(ubyte ChName)
{

  SFR_PAGE(_cc0, SST2);          // switch to page 0

  if ( ChName == 0)              //  if Channel_0
    CCU6_CMPMODIFH   |= 0x01;         //  Reset Compare State Modification

  if ( ChName == 1)              //  if Channel_1
    CCU6_CMPMODIFH   |= 0x02;         //  Reset Compare State Modification

  if ( ChName == 2)              //  if Channel_2
    CCU6_CMPMODIFH   |= 0x04;         //  Reset Compare State Modification

  if ( ChName == 3)              //  if Channel_3
    CCU6_CMPMODIFH   |= 0x40;         //  Reset Compare State Modification

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

} //  End of function CC6_vResetStatusBit


//****************************************************************************
// @Function      void CC6_uwSetTmrCounter(ubyte TimerNr, uword Value) 
//
//----------------------------------------------------------------------------
// @Description   This function loads the selected CC6 timer counter register 
//                with the parameter Value . It is possible to use this 
//                function only if the selected timer is stopped.
//                
//                The following definitions for TimerNr are available: 
//                CC6_TIMER_12
//                CC6_TIMER_13
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    TimerNr: 
//                Name of the CC6 timer to be used
// @Parameters    Value: 
//                16-bit value with which the CC6 counter register is to be 
//                loaded
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (SetTmrCounter,1)

// USER CODE END

void CC6_uwSetTmrCounter(ubyte TimerNr, uword Value)
{

  SFR_PAGE(_cc3, SST2);          // switch to page 3

  if ( TimerNr == 12)          //  if Timer_12
  {
    CCU6_T12L      = (ubyte) (0x00FF & Value);   //  Timer T12 Counter Register Low
    CCU6_T12H      = (ubyte) (Value >> 8);       //  Timer T12 Counter Register High
  }

  if ( TimerNr == 13)          //  if Timer_13
  {
    CCU6_T13L      = (ubyte) (0x00FF & Value);   //  Timer T13 Counter Register Low
    CCU6_T13H      = (ubyte) (Value >> 8);       //  Timer T13 Counter Register High
  }

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

} //  End of function CC6_uwSetTmrCounter


//****************************************************************************
// @Function      uword CC6_uwGetChannelShadowRegister(ubyte ChName) 
//
//----------------------------------------------------------------------------
// @Description   This function returns the content of the CC6 
//                capture/compare shadow register of the selected channel.
//                
//                The following definitions are available for RegName: 
//                CC6_CHANNEL_0 .. CC6_CHANNEL_3 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue   Current 16-bit value of the CC6 shadow register
//
//----------------------------------------------------------------------------
// @Parameters    ChName: 
//                Name of the CC6 channel to be readed
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (GetChannelShadowRegister,1)

// USER CODE END

uword CC6_uwGetChannelShadowRegister(ubyte ChName)
{

  uword Value = 0;

  SFR_PAGE(_cc0, SST2);          // switch to page 0

  if ( ChName == 0)                               //  if Channel_0
    Value = (uword)((CCU6_CC60SRH << 8) + CCU6_CC60SRL);    //  Compare Shadow Register

  if ( ChName == 1)                               //  if Channel_1
    Value = (uword)((CCU6_CC61SRH << 8) + CCU6_CC61SRL);    //  Compare Shadow Register

  if ( ChName == 2)                               //  if Channel_2
    Value = (uword)((CCU6_CC62SRH << 8) + CCU6_CC62SRL);    //  Compare Shadow Register

  if ( ChName == 3)                               //  if Channel_3
    Value = (uword)((CCU6_CC63SRH << 8) + CCU6_CC63SRL);    //  Compare Shadow Register

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

  return (Value);

} //  End of function CC6_uwGetChannelShadowRegister


//****************************************************************************
// @Function      uword CC6_uwGetTmrCounter(ubyte TimerNr) 
//
//----------------------------------------------------------------------------
// @Description   This function returns the contents of the selected CC6 
//                timer counter register.
//                
//                The following definitions for TimerNr are available: 
//                CC6_TIMER_12
//                CC6_TIMER_13
//
//----------------------------------------------------------------------------
// @Returnvalue   16-bit counter value
//
//----------------------------------------------------------------------------
// @Parameters    TimerNr: 
//                Name of the CC6 timer to be used
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (GetTmrCounter,1)

// USER CODE END

uword CC6_uwGetTmrCounter(ubyte TimerNr)
{

  uword Value = 0;

  SFR_PAGE(_cc3, SST2);          // switch to page 3

  if ( TimerNr == 12)                            //  if Timer_12
    Value      = (uword) ((CCU6_T12H << 8) + CCU6_T12L);   //  Timer T12 Reload Value

  if ( TimerNr == 13)                            //  if Timer_13
    Value      = (uword) ((CCU6_T13H << 8) + CCU6_T13L);   //  Timer T12 Reload Value

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

  return (Value);

} //  End of function CC6_uwGetTmrCounter


//****************************************************************************
// @Function      uword CC6_uwGetChannelRegister(ubyte ChName) 
//
//----------------------------------------------------------------------------
// @Description   This function returns the content of the CC6 
//                capture/compare register of the selected channel.
//                
//                The following definitions are available for RegName: 
//                CC6_CHANNEL_0 .. CC6_CHANNEL_3 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue   Current 16-bit value of the CC6 register
//
//----------------------------------------------------------------------------
// @Parameters    ChName: 
//                Name of the CC6 channel to be readed
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (GetChannelRegister,1)

// USER CODE END

uword CC6_uwGetChannelRegister(ubyte ChName)
{

  uword Value = 0;

  SFR_PAGE(_cc1, SST2);          // switch to page 1

  if ( ChName == 0)                             //  if Channel_0
    Value = (uword)((CCU6_CC60RH << 8) + CCU6_CC60RL);    //  Capture/Compare Register for Channel CC60

  if ( ChName == 1)                             //  if Channel_1
    Value = (uword)((CCU6_CC61RH << 8) + CCU6_CC61RL);    //  Capture/Compare Register for Channel CC61

  if ( ChName == 2)                             //  if Channel_2
    Value = (uword)((CCU6_CC62RH << 8) + CCU6_CC62RL);    //  Capture/Compare Register for Channel CC62

  if ( ChName == 3)                             //  if Channel_3
    Value = (uword)((CCU6_CC63RH << 8) + CCU6_CC63RL);    //  Capture/Compare Register for Channel CC63

  SFR_PAGE(_cc0, RST2);          // restore the old CCU page

  return (Value);

} //  End of function CC6_uwGetChannelRegister


// USER CODE BEGIN (CCU6_General,10)

// USER CODE END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -