📄 timer.c
字号:
/*
*******************************************************************************
**
** This device driver was created by Applilet for the 78K0S/KB1+, 78K0S/KA1+,
** 78K0S/KY1+,78K0S/KU1+ 8-Bit Single-Chip Microcontrollers
**
** Copyright(C) NEC Electronics Corporation 2002-2006
** 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 device driver for the timer module.
** APIlib : NEC78K0SKX1+.lib V1.70 [7 Dec. 2006]
**
** Device : uPD78F9234
**
** Compiler : NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
** Include files
*******************************************************************************
*/
#include "macrodriver.h"
#include "timer.h"
/*
*******************************************************************************
** MacroDefine
*******************************************************************************
*/
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function initializes TMH1 module.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Init()
{
ClrIORBit(TMHMD1, 0x80); /*STOP COUNTER OPERATION*/
SetIORBit(MK0, 0x10); /* INTTMH1 disable */
ClrIORBit(IF0, 0x10);
/* Internal countclock 2M*/
TMHMD1 |= ( TM_TMH1_CLOCK << 4 );
/* TMH1 square wave output */
SetIORBit(TMHMD1, 0x1); /* enable output */
ClrIORBit(P4, 0x04);
ClrIORBit(PM4, 0x04); /* P42/TOH1 */
ClrIORBit(TMHMD1, 0x2); /*SET PWM MODE*/
CMP01 = TM_TMH1_SQUAREWIDTH; /*0xc7*/
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can start the TMH1 counter.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Start( )
{
SetIORBit(TMHMD1, 0x80);
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can stop the TMH1 counter operation.
**
** Parameters:
** None
**
** Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void TMH1_Stop( )
{
ClrIORBit(TMHMD1, 0x80);
}
/*
**-----------------------------------------------------------------------------
**
** Abstract:
** This function can change TMH1 condition.
**
** Parameters:
** *array_reg : value(s) to set condition
** array_num : value number
**
** Returns:
** MD_OK
** MD_ERROR
**
**-----------------------------------------------------------------------------
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -