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

📄 timer.c

📁 nec平台下的ucos版本
💻 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.
**
**  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 :	uPD78F0547
**
**  Compiler:  NEC/CC78K0
**
*******************************************************************************
*/

/*
*******************************************************************************
**  Include files
*******************************************************************************
*/
#include "includes.h"


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

/*TM01 pulse width measure*/

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function initializes TM00_module.
**
**  Parameters:
**	None
**   
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void TM00_Init( )
{
	TMC00=0x00;
	                       			/* internal count clock */
	PRM00 |= TM_TM00_CLOCK;
	SetIORBit(PR0H, 0x40);			/* low priority level */
	ClrIORBit(IF0H, 0x40);
	/* TM00 interval */
	ClrIORBit(CRC00,0x01);	
	CR000 = TM_TM00_INTERVALVALUE;
	
}
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function starts the TM00 counter. 
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void TM00_Start()
{
	TMC00 = 0x0c;				/* interval timer start */
	ClrIORBit(MK0H, 0x40);			/* INTTM000 enable */
}
		
/*
**-----------------------------------------------------------------------------
**
**  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 */
}
		
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	This function changes TM00 condition.
**	
**  Parameters:
**	USHORT* :	array_reg
**	USHORT :	array_num
**  Returns:
**	MD_OK
**	MD_ERROR
**
**-----------------------------------------------------------------------------
*/
MD_STATUS TM00_ChangeTimerCondition(USHORT* array_reg,USHORT array_num)
{
   switch (array_num){
         case 2:
                  CR010=*(array_reg + 1);
         case 1:
                  CR000=*(array_reg + 0);
                  break;
         default:
                  return MD_ERROR;
         }
	  return MD_OK;
}

⌨️ 快捷键说明

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