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

📄 cc6.c

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

  }


} //  End of function CC6_viNodeI0

//****************************************************************************
// @Function      void CC6_vStartTmr(ubyte TimerNr) 
//
//----------------------------------------------------------------------------
// @Description   This Function starts the selected CC6 timer. The timer 
//                continues counting from where it 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 started
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (StartTmr,1)

// USER CODE END

void CC6_vStartTmr(ubyte TimerNr)
{

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

  if ( TimerNr == 12)            //  if Timer_12
    CCU6_TCTR4L      |=  0x02;        //  Start Timer T12

  if ( TimerNr == 13)            //  if Timer_13
    CCU6_TCTR4H      |=  0x02;        //  Start Timer T13

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

} //  End of function CC6_vStartTmr


//****************************************************************************
// @Function      void CC6_vStopTmr(ubyte TimerNr) 
//
//----------------------------------------------------------------------------
// @Description   This Function stops the selected CC6 timer. The content of 
//                the timer register remains unchanged. 
//                
//                The following definitions for TimerNr are available: 
//                CC6_TIMER_12
//                CC6_TIMER_13
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    TimerNr: 
//                Name of the CC6 timer to be stopped
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (StopTmr,1)

// USER CODE END

void CC6_vStopTmr(ubyte TimerNr)
{

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

  if ( TimerNr == 12)            //  if Timer_12
    CCU6_TCTR4L      |=  0x01;        //  Timer T12 Run Set

  if ( TimerNr == 13)            //  if Timer_13
    CCU6_TCTR4H      |=  0x01;        //  Timer T13 Run Set

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

} //  End of function CC6_vStopTmr


//****************************************************************************
// @Function      void CC6_vResetTmr(ubyte TimerNr) 
//
//----------------------------------------------------------------------------
// @Description   This function sets the selected CC6 timer counter register 
//                to zero. Timer is not 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 cleared
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (ResetTmr,1)

// USER CODE END

void CC6_vResetTmr(ubyte TimerNr)
{

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

  if ( TimerNr == 12)            //  if Timer_12
    CCU6_TCTR4L      |=  0x04;        //  Timer T12 Run Set

  if ( TimerNr == 13)            //  if Timer_13
    CCU6_TCTR4H      |=  0x04;        //  Timer T13 Run Set

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

} //  End of function CC6_vResetTmr


//****************************************************************************
// @Function      void CC6_vSetTmrPeriod(ubyte TimerNr, uword Value) 
//
//----------------------------------------------------------------------------
// @Description   This function loads the period register of the selected CC6 
//                timer.
//                
//                Note: Call the function CC6_vEnableShadowTransfer() to 
//                enable the shadow transfer.
//                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 timer reload register is to 
//                be loaded
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (SetTmrPeriod,1)

// USER CODE END

void CC6_vSetTmrPeriod(ubyte TimerNr, uword Value)
{

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

  if ( TimerNr == 12)          //  if Timer_12
  {
    CCU6_T12PRL      = (ubyte) (0x00FF & Value);   //  Timer T12 Reload Value
    CCU6_T12PRH      = (ubyte) (Value >> 8);       //  Timer T12 Reload Value
  }

  if ( TimerNr == 13)          //  if Timer_13
  {
    CCU6_T13PRL       = (ubyte) (0x00FF & Value);   //  Timer T13 Reload Value
    CCU6_T13PRH       = (ubyte) (Value >> 8);       //  Timer T13 Reload Value
  }

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

} //  End of function CC6_vSetTmrPeriod


//****************************************************************************
// @Function      void CC6_vSetDeadTimePeriod(ubyte ubValue) 
//
//----------------------------------------------------------------------------
// @Description   This function loads the counter of the dead time register.
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    ubValue: 
//                Counter value (ubValue = 0x01 .. 0x3F)
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (SetDeadTimePeriod,1)

// USER CODE END

void CC6_vSetDeadTimePeriod(ubyte ubValue)
{

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

  CCU6_T12DTCL        = (ubValue);     //  Dead-Time Control Register Value

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

} //  End of function CC6_vSetDeadTimePeriod


//****************************************************************************
// @Function      void CC6_vEnableShadowTransfer(ubyte TimerNr) 
//
//----------------------------------------------------------------------------
// @Description   This function enables the transfer from the shadow 
//                registers to the actual CC6 registers.
//                
//                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
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (EnableShadowTransfer,1)

// USER CODE END

void CC6_vEnableShadowTransfer(ubyte TimerNr)
{

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

  if ( TimerNr == 12)            //  if Timer_12
    CCU6_TCTR4L      |=  0x40;   //  enable Timer T12 shadow transfer

  if ( TimerNr == 13)            //  if Timer_13
    CCU6_TCTR4H      |=  0x40;   //  enable Timer T13 shadow transfer

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

} //  End of function CC6_vEnableShadowTransfer


//****************************************************************************
// @Function      void CC6_vLoadChannelShadowRegister(ubyte ChName, uword 
//                Value) 
//
//----------------------------------------------------------------------------
// @Description   This function loads the selected CC6 channel shadow 
//                register with the parameter Value. 
//                
//                The following definitions are available for RegName: 
//                CC6_CHANNEL_0 .. CC6_CHANNEL_3 (see @Defines in header file)
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    ChName: 
//                Name of the CC6 channel to be loaded
// @Parameters    Value: 
//                16-bit Value with which the CC6 shadow register is to be 
//                loaded
//
//----------------------------------------------------------------------------
// @Date          09.02.2005
//
//****************************************************************************

// USER CODE BEGIN (LoadChannelShadowRegister,1)

// USER CODE END

void CC6_vLoadChannelShadowRegister(ubyte ChName, uword Value)
{

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

  if ( ChName == 0)          //  if Channel_0
  {
    CCU6_CC60SRH    = (ubyte) (Value >> 8);        //  Load Channel Shadow Register CC60

    CCU6_CC60SRL    = (ubyte) (Value & 0x00FF);    //  Load Channel Shadow Register CC60
  }

  if ( ChName == 1)          //  if Channel_1
  {
    CCU6_CC61SRH    = (ubyte) (Value >> 8);        //  Load Channel Shadow Register CC61

    CCU6_CC61SRL    = (ubyte) (Value & 0x00FF);    //  Load Channel Shadow Register CC61
  }

  if ( ChName == 2)          //  if Channel_2
  {
    CCU6_CC62SRH    = (ubyte) (Value >> 8);        //  Load Channel Shadow Register CC62

⌨️ 快捷键说明

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