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

📄 tio5_noise.c

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

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

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

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

	void		TIO5_noise_init( void );		/* Initialize TIO5 noise processing input mode */
	void		TIO5_noiseInt( void );	/* Process TIO5 noise processing input interrupt (user processing) */

/************************************************************************/
/*		Define macro						*/
/************************************************************************/

/*** Noise processing input (TIO5) ***/

							/* 0123 4567	*/
#define	IEB3_MASK		(unsigned char)0xc0	/* 1100 0000B	*/
#define	IEB3_Tin3		(unsigned char)0x00	/* 0000 0000B	*/
							/* ++---------- Input event bus 3 : TIN3		*/

							/* 0123 4567 89AB CDEF	*/
#define	TIN3_MASK		(unsigned short)0x0700	/* 0000 0111 0000 0000B	*/
#define	TIN3_HLevel		(unsigned short)0x0600	/* 0000 0110 0000 0000B	*/
							/*	 +++--------- Set high on TIN3 to be the active level */

							/* 0123 4567	*/
#define	TIO5_Noise		(unsigned char)0x9e	/* 1001 1110B	*/
							/* |||| |+++--- Set TIO5 noise processing input mode	*/
							/* |||+-+------ Measurement input source :		*/
							/* |||			Input event bus 3 selected	*/
							/* +++--------- Select clock bus 0			*/

#define	TIO5_NoiseTime		(unsigned short)100 - 1	/* Count value for noise judgment time 			*/

/*""FUNC COMMENT""*******************************************************
 * Function name: TIO5_noise_init()
 *-----------------------------------------------------------------------
 * Description	: Count value for noise judgment timeInitial settings for TIO5 noise processing input mode
 * 		: - While using TIO5 in noise processing input mode,
 * 		:   this function detects high level on TIN3 via input event 3
 * 		: - The count source used for this operation is clock bus 0
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	: The prescaler, clock bus, etc. are set separately from the above
 * 		: ICU's interrupt control related registers are set separately from the above
 * 		: Port input function must be enabled
 * 		: This function must be executed while interrupts are disabled
 *""FUNC COMMENT END""***************************************************/
void	TIO5_noise_init()
{
	unsigned char	temp;

/*** Setting input event bus 3 ***/

	CKIEBCR = ( CKIEBCR & ~IEB3_MASK) | IEB3_Tin3;		/* Select input event bus 3 for input */

/*** Setting noise processing input mode (TIO5) ***/

	TIO5CR = TIO5_Noise;					/* Set TIO5 noise processing input mode */
	TIO5RL0 = TIO5_NoiseTime;				/* Set TIO5 noise judgment time */

/*** Setting P153 (TIN3) high level active ***/

	TINCR0 = ( TINCR0 & ~TIN3_MASK) | TIN3_HLevel;		/* Set high on TIN3 to be the active level */
	P15MOD |= 0x10;						/* Select P153 for TIN3 */

/*** Setting interrupt (TIO5) ***/

	temp = TIOIR1;
	temp |= ( TIOIS7 | TIOIS6 | TIOIS4);
	temp &= ~( TIOIS5 | TIOIM5);				/* Enable TIO5 interrupt */
	TIOIR1 = temp;

/*** Setting interrupt (TIN3) ***/

	temp = TINIR1;
	temp |= ( TINIS4 | TINIS5 | TINIS6) | TINIM3;		/* Disable TIN3 interrupt */
	TINIR1 = temp;

/*** Starting count ***/

	TIOPRO = ~TIO5PRO;					/* Enable TIO5 enable protect rewrite */
	TIOCEN = 0xffff;					/* Starting count TIO5 */
}

#if 0
/*""FUNC COMMENT""*******************************************************
 * Function name: TIO5_noiseInt()
 *-----------------------------------------------------------------------
 * Description	: Process TIO5 interrupt
 *-----------------------------------------------------------------------
 * Argument	: -
 *-----------------------------------------------------------------------
 * Returns	: -
 *-----------------------------------------------------------------------
 * Notes	:
 *""FUNC COMMENT END""***************************************************/
void	TIO5_noiseInt()
{
}
#endif

⌨️ 快捷键说明

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