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

📄 appinit.c

📁 本人编写的无线电话程序,给予PIC18C801设计,包括了uCOS的移植以及菜单,自己设计的拼音注入法,完整地一级汉字库,希望对大家有所帮助
💻 C
字号:
#include "includes.h"
#include <timers.h>
#include <usart.h>
#include <i2c.h>

void HW_Bd_Init(void){
	//system oscillator = 14.7456MHz	
	//Under 3V VCC, the operating frequency can only reach 16MHz
	//Init the oscillator system
	PSPCONbits.CMLK1 = 1;
	PSPCONbits.CMLK0 = 1;
	OSCCON = 0b00000000;	//Disable the PLL, use primary oscillator input
	//Init the external memory interface and chip select pins
	PSPCONbits.CMLK1 = 1;
	PSPCONbits.CMLK0 = 1;
	MEMCON = 0b00110000;	
	//Init ports
	
	//Init timers
	IPR1bits.TMR1IP = 0;	//set timer1 interrupt as low priority
	WriteTimer1(0xffff-18432);	//10ms at 14.7456MHz
	OpenTimer1(	TIMER_INT_ON &
				T1_16BIT_RW &
				T1_SOURCE_INT &
				T1_PS_1_8 &
				T1_OSC1EN_OFF &
				T1_SYNC_EXT_OFF);
	//Init the COM port
	OpenUSART(	USART_TX_INT_ON &
				USART_RX_INT_ON &
				USART_ASYNCH_MODE &
				USART_EIGHT_BIT &
				USART_CONT_RX &
				USART_BRGH_HIGH,
				7);	//value is for 14.7456MHz
	//I2C
	OpenI2C(MASTER, SLEW_ON);
	SSPADD = 9;		// under 14.7456MHz, bit rate is about 368k
	//Interrupt
	RCONbits.IPEN = 1;
	IPR1bits.RCIP = 1;
}

⌨️ 快捷键说明

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