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

📄 tid0_evcnt_main.c

📁 瑞萨CAN通讯单片机程序
💻 C
字号:
/*""FILE COMMENT""*****************************************************
 *	M32R C Programming		Rev. 1.00
 *		 < Sample Program for TIO5 noise processing input mode (main routine) >
 *
 *	Copyright (c) 2003 Renesas Technology Corporation
 *			   And Renesas Solutions Corporation
 *			   All Rights Reserved
 *********************************************************************/

/************************************************************************/
/*		Include file						*/
/************************************************************************/

#include		"..\inc\sfr32170_pragma.h"

/************************************************************************/
/*		Function prototype declaration				*/
/************************************************************************/

	void		main(void);				/* Main function */
	void		init_func(void);			/* Initial setup function */
	void		port_init(void);			/* Initialize port */

/************************************************************************/
/*		Definition of external reference			*/
/************************************************************************/

extern	void		DisInt( void );				/* Interrupt disable function */
extern	void		EnInt( void );				/* Interrupt enable function */

extern	void		TID0_evcnt();				/* Initialize TID0 event count mode */

/*""FUNC COMMENT""*******************************************************
 * Function name: port_init()
 *-----------------------------------------------------------------------
 * Description	: Initialize port
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	:
 *""FUNC COMMENT END""***************************************************/
void port_init(void)
{
	PIEN = PIEN0;						/* Enable port input */

	P10DATA = 0x00;						/* Output data (must be set prior to mode) */
	P10DIR = 0xff;						/* P100-P107 : Output mode */
	P10MOD = 0x00;						/* P100-P107 : Input/output port */

	P11DATA = 0x00;						/* Output data (must be set prior to mode) */
	P11DIR = 0xff;						/* P110-P117 : Output mode */
	P11MOD = 0x00;						/* P110-P117 : Input/output port */
}

/*""FUNC COMMENT""*******************************************************
 * Function name: init_func()
 *-----------------------------------------------------------------------
 * Description	: Call various initialization functions
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	:
 *""FUNC COMMENT END""***************************************************/
void init_func(void)
{
	port_init();						/* Initialize those related to port */
}

/*""FUNC COMMENT""*******************************************************
 * Function name: main()
 *-----------------------------------------------------------------------
 * Description	: While using TID0 in event count mode, this function counts TIN24 events.
 * 		: The count value is forwarded to ports 10 and 11.
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	:
 *""FUNC COMMENT END""***************************************************/
void main(void)
{
	unsigned short	*P10P11DATA;

	P10P11DATA = (unsigned short *)&P10DATA;

	DisInt();						/* Disable interrupt */

	init_func();

	TID0_evcnt();						/* TID0 count start */

	EnInt();						/* Enable interrupt */

	while(1) {
		*P10P11DATA = TID0CT;
	}
}

⌨️ 快捷键说明

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