📄 timer.c
字号:
/*
*******************************************************************************
**
** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
**
** Filename : timer.c
** Abstract : This file implements a device driver for the timer module
** Device : uPD78F0547
** Compiler: NEC/CC78K0
**
*******************************************************************************
*/
#pragma sfr
/*
*******************************************************************************
** Include files
*******************************************************************************
*/
#include "timer_config.h"
/*
*******************************************************************************
** MacroDefine
*******************************************************************************
*/
#if TM00_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes TM00.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM00_Init(void)
{
/*
TMC00 = TM0n_TMC0n_Operation_Disable;
*/
#ifdef TM00_PRM0nValue
PRM00 = TM00_PRM0nValue;
#endif
#ifdef TM00_CRC0nValue
CRC00 = TM00_CRC0nValue;
#endif
#ifdef TM00_TOC0nValue
TOC00 = TM00_TOC0nValue;
#endif
#ifdef TM00_CR00nValue
CR000 = TM00_CR00nValue;
#endif
#ifdef TM00_CR01nValue
CR010 = TM00_CR01nValue;
#endif
/* TI000 and/or TI010 and/or TO00 pin setting */
/* INTTM000 and/or INTTM010 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function starts the TM00 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM00_Enable(void)
{
#ifdef TM00_TMC0nValue
TMC00 = TM00_TMC0nValue;
#endif
/* INTTM000 and/or INTTM010 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function stops the TM00 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM00_Disable(void)
{
/* Use register bit macro
TM0n_TMC0n_Operation_Disable
*/
TMC00 = TM0n_TMC0n_Operation_Disable;
/* INTTM000 and/or INTTM010 disable */
}
#endif
#if TM01_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can initialize TM01_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM01_Init(void)
{
/*
TMC01 = TM0n_TMC0n_Operation_Disable;
*/
#ifdef TM01_PRM0nValue
PRM01 = TM01_PRM0nValue;
#endif
#ifdef TM01_CRC0nValue
CRC01 = TM01_CRC0nValue;
#endif
#ifdef TM01_TOC0nValue
TOC01 = TM01_TOC0nValue;
#endif
#ifdef TM01_CR00nValue
CR001 = TM01_CR00nValue;
#endif
#ifdef TM01_CR01nValue
CR011 = TM01_CR01nValue;
#endif
/* TI001 and/or TI011 and/or TO01 pin setting */
/* INTTM001 and/or INTTM011 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function start the TM01 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM01_Enable(void)
{
#ifdef TM01_TMC0nValue
TMC01 = TM01_TMC0nValue;
#endif
/* INTTM001 and/or INTTM011 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This fnction stop the TM01 module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM01_Disable(void)
{
/* Use register bit macro
TM0n_TMC0n_Operation_Disable
*/
TMC01 = TM0n_TMC0n_Operation_Disable;
/* INTTM001 and/or INTTM011 disable */
}
#endif
#if TM50_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can initialize TM50_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Init(void)
{
/*
TMC50 = TM5n_TMC5n_Operation_Disable;
*/
#ifdef TM50_TCL5nValue
TCL50 = TM50_TCL5nValue;
#endif
#ifdef TM50_CR5nValue
CR50 = TM50_CR5nValue;
#endif
/* TI50 or TO50 pin setting */
/* INTTM50 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can start the TM50 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Enable(void)
{
#ifdef TM50_TMC5nValue
TMC50 = TM50_TMC5nValue;
#endif
/* INTTM50 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can stop the TM50 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Disable(void)
{
/* Use register bit macro
TM5n_TMC5n_Operation_Disable
*/
TMC50 = TM5n_TMC5n_Operation_Disable;
/* INTTM50 disable */
}
#endif
#if TM51_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function Initializes TM51_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Init(void)
{
/*
TMC51 = TM5n_TMC5n_Operation_Disable;
*/
#ifdef TM51_TCL5nValue
TCL51 = TM51_TCL5nValue;
#endif
#ifdef TM51_CR5nValue
CR51 = TM51_CR5nValue;
#endif
/* TI51 or TO51 pin setting */
/* INTTM51 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function starts the TM51 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Enable(void)
{
#ifdef TM51_TMC5nValue
TMC51 = TM51_TMC5nValue;
#endif
/* INTTM51 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function stops the TM51 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Disable(void)
{
/* Use register bit macro
TM5n_TMC5n_Operation_Disable
*/
TMC51 = TM5n_TMC5n_Operation_Disable;
/* INTTM51 disable */
}
#endif
#if TMH0_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes TMH0 module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Init(void)
{
/*
TMHMD0 = TMHn_TMHMDn_Operation_Stop;
*/
#ifdef TMH0_CMP0nValue
CMP00 = TMH0_CMP0nValue;
#endif
#ifdef TMH0_CMP1nValue
CMP10 = TMH0_CMP1nValue;
#endif
/* TOH0 pin setting */
/* INTTMH0 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can start the TMH0 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Enable(void)
{
#ifdef TMH0_TMHMDnValue
TMHMD0 = TMH0_TMHMDnValue;
#endif
/* INTTMH0 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can stop the TMH0 counter operation.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Disable(void)
{
/* Use register bit macro
TMHn_TMHMDn_Operation_Stop
*/
TMHMD0 = TMHn_TMHMDn_Operation_Stop;
/* INTTMH0 disable */
}
#endif
#if TMH1_NotUse==0
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes TMH1_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Init(void)
{
/*
TMHMD1 = TMHn_TMHMDn_Operation_Stop;
*/
#ifdef TMH1_TMCYC1Value
TMCYC1 = TMH1_TMCYC1Value;
#endif
#ifdef TMH1_CMP0nValue
CMP01 = TMH1_CMP0nValue;
#endif
#ifdef TMH1_CMP1nValue
CMP11 = TMH1_CMP1nValue;
#endif
/* TOH1 pin setting */
/* INTTMH1 priority */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can start the TMH1 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Enable(void)
{
#ifdef TMH1_TMHMDnValue
TMHMD1 = TMH1_TMHMDnValue;
#endif
/* INTTMH1 enable */
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can stop the TMH1 counter operation.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Disable(void)
{
/* Use register bit macro
TMHn_TMHMDn_Operation_Stop
*/
TMHMD1 = TMHn_TMHMDn_Operation_Stop;
/* INTTMH1 disable */
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -