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

📄 k0r_sfr_set.c

📁 nec单片机一个样例程序
💻 C
字号:
/***************************************************************************************************************
;														
;    NNNNNN          NN  EEEEEEEEEEEEEEEEEE     CCCCCCCCCCCCCCC							
;    NNNNNNNN        NN  EEEEEE               CCCCCC           							
;    NNNNNNNNNN      NN  EEEEEE              CCCCCC            							
;    NN  NNNNNNNN    NN  EEEEEEEEEEEEEEEEE   CCCCCC            							
;    NN    NNNNNNNN  NN  EEEEEE              CCCCCC            							
;    NN      NNNNNNNNNN  EEEEEE               CCCCCC          							
;    NN          NNNNNN    EEEEEEEEEEEEEEEE     CCCCCCCCCCCCCCC							
;														
;    NEC Electronics	78K0R/Kx3 Series									
;丂丂														
;亂License Agreement亃
;. This sample program is subject to change without notice.
;
;. NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual
;  property rights of third parties by or arising from the use of this sample program. No license, express,
;  implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of
;  NEC Electronics or others.
;
;. Descriptions of commands, program, and other related information in this sample program are provided for
;  illustrative purposes in semiconductor product operation and application examples. The incorporation of
;  this sample program in the design of a customer's equipment shall be done under the full responsibility of
;  the customer. NEC Electronics assumes no responsibility for any losses incurred by customers or third parties
;  arising from the use of this sample program.
;
;丂Please use this sample program under the agreement listed above.
;
;***************************************************************************************************************
;	78K0R/Kx3 Series	sample program								
;***************************************************************************************************************
;	Interval timer/Square wave output(TIMER ARRAY UNIT) "SFR Setting"
;***************************************************************************************************************
; [History]
;	2007.07
;	     12 new
;***************************************************************************************************************/

#pragma	sfr							/* definition for using SFR */

void STM_IINI(void);
void STM_ISTT(void);
void STM_ISTP(void);

/***************************************************************************
*	Title	:	Interval timer/Square wave output(TIMER ARRAY UNIT)
*			initial setting
****************************************************************************
*	Module	:	void STM_IINI(void)
*	Arg		:
*	Ret		:
*---------------------------------------------------------------------------
*	Note	:
***************************************************************************/
void STM_IINI(void)
{

	TAU0EN = 1;						/* supplies input clock */


	TPS0 = 0x0050;					/* timer clock (CK01) = fCLK/(2^5) 4 us */

	TMR02 = 0x8000;					/* CKS02=1: operation clock CK01 set by PRS register */
									/* CCS02=0: operation clock MCK specified by CKS02 bit */
									/* MASTER02=0: stand-alone mode */
									/* STS022-0=0: only software trigger start is valid */
									/* MD023-0=0: interval timer mode, no timer interrupt when counting starts */
	


	TDR02 = 2500-1;					/* interval period = 10.000ms(4us * 2500) */


	TOM0 = 0b0000000000000000;		/* TOM00-7=0: timer output (TO0-7) mode: toggle mode */

	TOL0 = 0b0000000000000000;		/* TOL00-7=0: timer output (TO0-7) level: postive logic output (active-high) */

	TO0 = 0b0000000000000000;		/* TO00-7=0: timer output (TO0-7) value: "0" */


	TOE0L.2 = 1;					/* Enables the TO02 output operation by counting operation */
 									/* (Enables to Square wave output) */

	P1.7 = 0;						/* P17(TO02) */
	PM1.7 = 0;						/* output */

}

/***************************************************************************
*	Title	:	Interval timer/Square wave output(TIMER ARRAY UNIT)
*			operation start	
****************************************************************************
*	Module	:	void STM_ISTT(void)
*	Arg		:
*	Ret		:
*---------------------------------------------------------------------------
*	Note	:
***************************************************************************/
void STM_ISTT(void)
{
	TOE0L.2 = 1;					/* Enables the TO02 output operation by counting operation */
									/* (Enables to Square wave output) */
	TS0L.2 = 1;						/* TS02=1: TE02 is set to 1 and the counter operation becomes enabled */

	TMIF02 = 0;						/* clear interrupt request flag (INTTM02) */
	TMMK02 = 0;						/* clear interrupt mask flag (INTTM02) */
}

/***************************************************************************
*	Title	:	Interval timer/Square wave output(TIMER ARRAY UNIT)
*			operation stop
****************************************************************************
*	Module	:	void STM_ISTP(void)
*	Arg		:
*	Ret		:
*---------------------------------------------------------------------------
*	Note	:
***************************************************************************/
void STM_ISTP(void)
{
	TT0L.2 = 1;						/* Operation is stopped of Channel2 */
	TOE0L.2 = 0;					/* timer output (TO2) operation stopped by count operation */
 									/* (Enables to Square wave output) */
}

⌨️ 快捷键说明

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