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

📄 init.c

📁 瑞萨CAN通讯单片机程序
💻 C
字号:
/*""FILE COMMENT""***************************************************** *	M32R C Programming		Rev. 1.00 *		 < Sample Program for CAN init > * *	Copyright (c) 2003 Renesas Technology Corporation *			   And Renesas Solutions Corporation *			   All Rights Reserved *********************************************************************//************************************************************************//*		Include file						*//************************************************************************/#include		"..\inc\sfr32170_pragma.h"/************************************************************************//*		Function prototype declaration				*//************************************************************************/	void		can_init(void);/*""FUNC COMMENT""******************************************************* * Function name: void can_init(void) *----------------------------------------------------------------------- * Description	: Initializes CAN module *----------------------------------------------------------------------- * Argument	: - *----------------------------------------------------------------------- * Returns	: - *----------------------------------------------------------------------- * Notes	: *""FUNC COMMENT END""***************************************************/void can_init(void){	/* Setting input/output port operation mode register (CRX pin does not need to be set) */	P22MOD |= 0x80;				/* P220 used as CTX */	/* Setting interrupt controller */	ICAN0CR = 0x07;				/* CAN0 interrupt priority level 7 (interrupt disabled) */	/* Setting CAN0 related interrupt mask register */	CAN0SLIST = 0x0000;			/* Clear CAN0 slot transmit/receive-finished interrupt request */	CAN0ERIST = 0x00;			/* Clear CAN0 error interrupt request */	CAN0SLIMK = 0x0000;			/* Disable CAN0 slot transmit/receive-finished interrupt */	CAN0ERIMK = 0x00;			/* Disable CAN0 error interrupt */	/* Setting CAN configuration register */	CAN0CONF = 0x3680;			/* SJW=1, Sync(1)+Prop(5)+PH1(7)+PH2(7), sampling count = 1 */	CAN0BRP = (16 - 1);			/* Baud rate: 40 MHz / divided by 16 / 20 Tq -> 125 Kbps */	/* Setting ID mask register */	C0GMSKS0 = 0xff;			/* Global mask register */	C0GMSKS1 = 0xff;	C0GMSKE0 = 0xff;	C0GMSKE1 = 0xff;	C0GMSKE2 = 0xff;	C0LMSKAS0 = 0xff;			/* Local mask register A */	C0LMSKAS1 = 0xff;	C0LMSKAE0 = 0xff;	C0LMSKAE1 = 0xff;	C0LMSKAE2 = 0xff;	C0LMSKBS0 = 0xff;			/* Local mask register B */	C0LMSKBS1 = 0xff;	C0LMSKBE0 = 0xff;	C0LMSKBE1 = 0xff;	C0LMSKBE2 = 0xff;	/* To use in BasicCAN mode, set it up here. */	/*	 *	- Set IDE14/15 of CAN0EXTID	 *	- Set ID of slots 14/15	 *	- Set local mask registers A/B	 *	- Set slots 14/15 for data frame reception	 */	/* Setting CAN operation mode */	CAN0EXTID = 0x0000;			/* Select standard format frame */	/* Negating CAN reset */	CAN0CNT = 0x0000;			/* Clear FRST and RST bits and disable BasicCAN function */						/* Disable loopback function and select timestamp divide-by-1 */}

⌨️ 快捷键说明

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