📄 watchtimer.c
字号:
/*
* $Id: watchtimer.c,v 1.8 2007/10/23 07:52:04 sunny Exp $
*/
/*
*******************************************************************************
**
** 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.
**
** Copyright(C) NEC Electronics Corporation 2002 - 2005
** All rights reserved by NEC Electronics Corporation.
**
** This program should be used on your own responsibility.
** NEC Electronics Corporation assumes no responsibility for any losses
** incurred by customers or third parties arising from the use of this file.
**
** Filename : watchtimer.c
** Abstract : This file implements device driver for watchtimer module.
** APIlib : NEC78K0KX2.lib V1.01 [09 Aug. 2005]
**
** Device : uPD78F0537
**
** Compiler : NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
** Include files
*******************************************************************************
*/
#include "unet.h"
#include "watchtimer.h"
/*
*******************************************************************************
** MacroDefine
*******************************************************************************
*/
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes the watch timer module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void WT_Init( void )
{
WTM = 0;
WTPR = 1; /* low priority level */
WTMK = 0;
WTIPR = 1; /* low priority level */
WTIMK = 0;
WTM.7 = 1; /* watch timer clock: fw = fsub */
ClrIORBit(WTM, 0x0c); /* watch time: 2^13/fw (0.25s at 32.768Kz) */
SetIORBit(WTM, 0x04);
ClrIORBit(WTM, 0x70); /* interval time: 2^5/fw */
SetIORBit(WTM, 0x10);
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function restarts the watch timer after stopping.
**
** Parameters:
** None
**
** Returns:
** MD_OK
**
**-----------------------------------------------------------------------------
*/
MD_STATUS WT_Start( void )
{
/* Enable watch timer operation */
WTM1 = 1;
/* Start the 5-bit counter */
WTM0 = 1;
WTMK = 0; /* INTWT enable */
WTIMK = 0; /* INTWTI enable */
return MD_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -