📄 timer.bak
字号:
#include "ext_var.h"
#include "Timer.h"
/*-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes TM00_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**----------------------------------------------------------------------------*/
void TM00_Init()
{
TMC00=0x00;
CRC00=0x00; /* CRC00.0=0 */
/* f=fprs/256*/
PRM00 = 0x02; /* ES101=0,ES100=0,ES001=0,ES000=0,PRM001=1,PRM000=0*/
//TM00 = 0;
//CR000 = 31250*2; /* about 2s. */
CR000 = 31250; /* about 1s. */
MK0H.7=1; /* disable CR010 interrupt: INTTM010 */
}
/*-----------------------------------------------------------------------------
**
** Abstract:
** This function starts the TM00 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**----------------------------------------------------------------------------*/
void TM00_Start()
{
TMC00 = 0x0c; /* interval timer start */
// ClrIORBit(MK0H, 0x40); /* INTTM000 enable */
MK0H.6=0;
}
/*-----------------------------------------------------------------------------
**
** Abstract:
** This function stops the TM00 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**----------------------------------------------------------------------------*/
void TM00_Stop()
{
TMC00=0x0;
// SetIORBit(MK0H, 0x40); /* INTTM000 stop */
MK0H.6=1;
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can initialize TM50_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Init( void )
{
//ClrIORBit(TMC50, 0x80);
TMC50 = 0x00;
//TCL50 = TM_TM50_CLOCK; /* countclock=fx/8192 */
TCL50 = 0x07;
//SetIORBit(PR0H, 0x20); /* low priority level */
PR0H.5=0;
//ClrIORBit(IF0H, 0x20);
IF0H.5=0;
/* TM50 interval */
//CR50 = TM_TM50_INTERVALVALUE;
CR50 = 100; //delay 0.1s
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can start the TM50 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Start( void )
{
//ClrIORBit(MK0H, 0x20); /* INTTM50 enable */
MK0H.5=0;
/* TM50 interval */
//SetIORBit(TMC50, 0x80);
TMC50.7=1;
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can stop the TM50 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM50_Stop( void )
{
//SetIORBit(MK0H, 0x20); /* INTTM50 disable */
MK0H.5=1;
//ClrIORBit(TMC50, 0x80);
TMC50.7=0;
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function Initializes TM51_module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Init( void )
{
//ClrIORBit(TMC51, 0x80);
TMC51 = 0x00;
//TCL51 = TM_TM51_CLOCK; /* countclock=fx/256 */
TCL51 = 0x07;
//SetIORBit(PR1L, 0x08); /* low priority level */
PR1L.3=1;
//ClrIORBit(IF1L, 0x08);
IF1L.3=0;
/* TM51 interval */
//CR51 = TM_TM51_INTERVALVALUE;
CR51 = 199;
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function starts the TM51 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Start( void )
{
/* TM51 interval */
//ClrIORBit(MK1L, 0x08); /* INTTM51 enable */
MK1L.3=0;
//SetIORBit(TMC51, 0x80);
TMC51.7=1;
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function stops the TM51 counter and clear the count register.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TM51_Stop( void )
{
//SetIORBit(MK1L, 0x08); /* INTTM51 disable */
MK1L.3=1;
//ClrIORBit(TMC51, 0x80);
TMC51.7=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -