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

📄 timer.c

📁 NEC 的无线通讯方案
💻 C
字号:
/*
* $Id: timer.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 : timer.c
**  Abstract : This file implements a device driver for the timer module
**  APIlib:  NEC78K0KX2.lib V1.01 [09 Aug. 2005]
**
**  Device :	uPD78F0537
**
**  Compiler:  NEC/CC78K0
**
*******************************************************************************
*/

/*
*******************************************************************************
**  Include files
*******************************************************************************
*/
#include "unet.h"
#include "timer.h"
#include "unet.h"


/*
*******************************************************************************
**  MacroDefine
*******************************************************************************
*/
/*TM00 pulse width measure*/

/*TM01 pulse width measure*/

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function initializes TMH0 module.
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Init( void )
{
	ClrIORBit(TMHMD0, 0x80);
	 		/* internal countclock */
	TMHMD0 |= (TM_TMH0_CLOCK << 4);

	SetIORBit(PR0H, 0x10);			/* low priority level */
	ClrIORBit(IF0H, 0x10);
	/* TMH0 interval timer */
	ClrIORBit(TMHMD0, 0x8c);
	CMP00 = TM_TMH0_INTERVALVALUE;

	tick_count = 0;
	timer_1ms_flag = 0;
	TMH0_Start();
}

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function can start the TMH0 counter.
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Start( void )
{
	SetIORBit(TMHMD0, 0x80);
	ClrIORBit(MK0H, 0x10);			/* INTTMH0 enable */
}

#if 0
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function can stop the TMH0 counter operation.
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void TMH0_Stop( void )
{
	ClrIORBit(TMHMD0, 0x80);
	SetIORBit(MK0H, 0x10);			/* INTTMH0 disable */
}

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function can change TMH0 condition.
**
**  Parameters:
**	UCHAR* :	array_reg
**	UCHAR :	array_num
**  Returns:
**	MD_OK
**	MD_ERROR
**
**-----------------------------------------------------------------------------
*/
MD_STATUS TMH0_ChangeTimerCondition(UCHAR* array_reg,UCHAR array_num)
{
   switch (array_num){
         case 2:
                  CMP10=*(array_reg + 1);
         case 1:
                  CMP00=*(array_reg + 0);
                  break;
         default:
                  return MD_ERROR;
         }
	  return MD_OK;
}
#endif

⌨️ 快捷键说明

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