📄 system.c
字号:
//====================================================================//
//文件:System.c
//描述:系统初始化程序集
//备注:包括上电后的时钟初始化、端口、功能模块等
//作者:xinqiang 2006 08 12 Mz Designed 小丑
//====================================================================//
#include "C8051F020.h"
#include "intrins.h" //包含此头文件可直接操作内核的寄存器以及一些定义好的宏
sbit LCD_ON = P1^6; //LCD背光灯控制开关
//===================================================//
//程序:void System_Initial(void)
//描述:串行口初始化程序,初始化波特率、模式等
//参数:无
//返回:无
//Note: Edit by Mz xinqiang zhang(小丑)
//Date: 2006 08 10 beijing
//===================================================//
void System_Initial(void)
{
unsigned char i; // delay counter
//看门狗初始化代码
WDTCN = 0xde; // disable watchdog timer
WDTCN = 0xad;
//系统时钟初始化代码
OSCXCN = 0x67; // start external oscillator with
// 25MHz crystal
for (i=0; i < 255; i++) _nop_(); // XTLVLD blanking interval (>1ms)
while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
OSCICN = 0x88; // select external oscillator as SYSCLK
// source and enable missing clock
// detector// */
//统端口初始化代码
// P4 = P4&0xfb;
EMI0CF = 0x38; //外部总线接口的模式:利用P4~P7,带块选择
//非复用方式 ALE为2个Systemclock
EMI0TC = 0xff;//a;//6;// 0xdc; //驱动控制MT22G06LCD时,要注意总线时序的配置,否则无法正常驱动LCD
XBR0 = 0x00; // Enable UART0 RX/TX Port
XBR1 = 0x00;
XBR2 &= 0x7f;
XBR2 |= 0x40; // Enable crossbar and weak pull-ups
P0MDOUT = 0x01; // enable TX0 as a push-pull output
// P0 = 0x08;
P1MDOUT = 0xff;
P1 = 0x00;
P2MDOUT = 0xff;
P2 = 0xff;
P3MDOUT = 0xff; //
P3 = 0xff;
/// LCD_ON = 0;
// LCD_ON = 1;
// P74OUT |= 0xff;
//其它的设置代码
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -