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

📄 hardwareinit.c

📁 自己写的单片机串并口通讯程序
💻 C
字号:
#include "..\inc\44b.h"
#include "..\inc\function.h"
#include "..inc\constant.h"

void Port_Init(void)
{
	//CAUTION:Follow the configuration order for setting the ports. 
	// 1) setting value 
	 // 2) setting control register 
	 // 3) configure pull-up resistor.  

	//16bit data bus configuration  

	// PORT A GROUP
	/*  BIT 9		8	7	6	5	4	3	2	1	0	*/
	/*        A24	A23	A22	A21	A20	A19	A18	A17	A16	A0	*/	      
	/*        1		1	1	1	1	1	1	1	1	1	*/
	rPCONA = 0x1ff;	

	// PORT B GROUP
	/*  BIT 10	9		8		7		6		5		4		3		2		1		0		*/
	/*	/CS5	/CS4	/CS3	/CS2	/CS1	nWBE3	nWBE2	/SRAS	/SCAS	SCLK	SCKE	*/
	/*	EXT		NIC		USB		IDE		SMC		NC		NC		Sdram	Sdram	Sdram	Sdram	*/
	/*      1,        1,   1,   1,    1,    1,       1,     1,    1,    1,   1          */
	rPDATB = 0x3ff;
	rPCONB = 0x1ff;
    
	//PORT C GROUP
	//BUSWIDTH=16													*/
	/*  PC15		14		13		12		11		10		9		8	*/
	/*	I		I		RXD1	TXD1	I		I		I		I	*/
	/*	NC		NC		Uart1	Uart1	NC		NC		NC		NC	*/
	/*   00		00		11		11		00		00		00		00	*/

	/*  PC7		6		5		4		3		2		1		0	*/
	/*   I		I		I		I		I		I		I		I	*/
	/*   NC		NC		NC		NC		SMCALE	SMCCLE	SMCCE	SMCRB*/
	/*   00		00		00		00		01		01		01		00	*/
	rPDATC = 0x0;	//All IO is high
	rPCONC = 0x50450000;	
	rPUPC  = 0x0;	//PULL UP RESISTOR should be enabled to I/O

	//PORT D GROUP
	/*  PORT D GROUP(I/O OR LCD)										*/
	/*  BIT7		6		5		4		3		2		1		0	*/
	/*      VF		VM		VLINE	VCLK	VD3		VD2		VD1		VD0	*/
	/*	   00		00		00		00		00		00		00		00	*/
	rPDATD= 0xff;
	rPCOND= 0x5555;	
	rPUPD = 0x0;
	//These pins must be set only after CPU's internal LCD controller is enable
	
	//PORT E GROUP 
	/*  Bit 8		7		6		5		4		3		2		1		0		*/
	/*      LcdBL	LED4	LED5	LED6	LED7	BEEP	RXD0	TXD0	LcdDisp	*/ 
	/*      01		01		01		01		01		01		10		10		01		*/
	rPDATE	= 0x1fe;
	//rPCONE	= 0x696a;//0110,1001,0110,1010	
	rPCONE	= 0x556A;    //0101,0101,0110,1010
	rPUPE	= 0x0;
	
	//PORT F GROUP
	/*  Bit8		7		6		5		 4		3		2		1		0		*/   
	/*  IISCLK	IISDI	IISDO	IISLRCK	Input	Input	Input	IICSDA	IICSCL	*/
	/*	100		100		100		100		00		00		00		10		10		*/
	rPDATF = 0x1ff;
	rPCONF = 0x192C05;
	rPUPF  = 0x0;

	//PORT G GROUP
	/*  BIT7		6		5		4		3		2		1		0	 */
	/*	INT7		INT6		INT5		INT4		INT3		INT2		INT1		INT0	*/
	/*    S3		S4		S5		S6		NIC		EXT		IDE		USB	*/
	/*      11      11      11      11      11      11      11      11       */
	rPDATG = 0xFF;
	rPCONG = 0x114;//0001,0001,0100
	rPUPG  = 0x0;	//should be enabled  
	rSPUCR=0x7;  //D15-D0 pull-up disable

	/*定义非Cache区*/
	rNCACHBE0=((Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12); 
	/*所有的外部硬件中断为低电平触发*/
	rEXTINT=0x0;

//Misc
//USBN9603's A0 pin	->	CPU's A1
//IDE's CS0			->	CPU's A2
//IDE's CS1			->	CPU's A1
//IDE's A2			->	CPU's A3
//IDE's A1			->	CPU's A5
//IDE's A0			->	CPU's A4
}


void Timer_Init(void)
{

	pISR_URXD0 = uart_recvdata;
	pISR_EINT0 =parallel;
	rINTCON =0x00000000;


	rINTMSK &= ~BIT_EINT0;
	rINTMSK &= ~BIT_URXD0;

	rINTMSK &= ~BIT_GLOBAL;
	rI_PMST = 0x0fe4;             

}

⌨️ 快捷键说明

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