📄 init.lst
字号:
C51 COMPILER V7.50 INIT 12/03/2005 12:09:15 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE INIT
OBJECT MODULE PLACED IN Init.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Init.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <head.h> // SFR declarations
2 /*************************************************
3 * VERSION: 1.0,2005.10.27
4 * AUTHOR: Xiong Xiaojun,BUAA
5 * FUNCTION: SYSCLK
6 **************************************************/
7 void SYSCLK_Init (void)
8 {
9 1 int i; // delay counter
10 1 OSCXCN = 0x67; // start external oscillator with
11 1 // 14.7456MHz crystal
12 1 for (i=0; i < 255; i++) ; // XTLVLD blanking interval (>1ms)
13 1 while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
14 1 OSCICN = 0x88; // select external oscillator as SYSCLK
15 1 // source and enable missing clock detector
16 1 }
17 //-----------------------------------------------------------------------------
18 // PORT_Init
19 //-----------------------------------------------------------------------------
20 //
21 // Configure the Crossbar and GPIO ports
22 // P0 PORT
23 // 0 1 2 3 4 5 6 7
24 // TX0 RX0 SCK MISO MOSI NSS TX1 RX1
25
26 void PORT_Init (void)
27 {
28 1 // P0.0 = UART TX0 (Push-Pull Output)
29 1 // P0.1 = UART RX0 (Open-Drain Output/Input)
30 1 // P0.2 = SMBus SDA (Open-Drain Output/Input)
31 1 // P0.3 = SMBus SCL (Open-Drain Output/Input)
32 1 // P0.4 = T0 (Open-Drain Output/Input)
33 1 // P0.5 = T1 (Open-Drain Output/Input)
34 1 // P0.6 = T4 (Open-Drain Output/Input)
35 1 XBR0 = 0x05; // XBAR0: Initial Reset Value
36 1 XBR1 = 0x0A; // XBAR1: Initial Reset Value
37 1 XBR2 = 0x48; // XBAR2: Initial Reset Value
38 1
39 1 P0MDOUT = 0x00; // Output configuration for P0
40 1 P1MDOUT = 0xff;
41 1 P2MDOUT = 0xff;
42 1 P3MDOUT = 0x38;
43 1
44 1 }
45
46 /*************************************************
47 * VERSION: 1.0,2005.10.27
48 * AUTHOR: Xiong Xiaojun,BUAA
49 * FUNCTION: Serial initialize
50 **************************************************/
51 // SCON
52 // SM0 SM1 SM2 REN TB8 RB8 TI RI
53 // TCON
54 // TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
55
C51 COMPILER V7.50 INIT 12/03/2005 12:09:15 PAGE 2
56 // TMOD
57 // GATE1 C/T M1 M0 GATE0 C/T M1 M0
58 // M1 M0 = 01 16 BIT Timer
59 // M1 M0 = 10 AutoLoad 8 bit
60
61 // T2CON
62 // TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2
63 void Serial_Init(void)
64 {
65 1 SCON0 = 0x50; // Serial Port Control Register
66 1 PCON = 0x00; // Power Control Register
67 1 }
68 //************1ms定时器的初始化*********************
69 /*************************************************
70 * VERSION: 1.0,2003.4.14
71 * AUTHOR: Xiong Xiaojun,BUAA
72 * FUNCTION: 1ms Timer initialize
73 **************************************************/
74 void Timer_Init(void)
75 {
76 1 CKCON = 0x00; // Clock Control Register
77 1 TH0 = 0x00; // Timer 0 High Byte
78 1 TL0 = 0x00; // Timer 0 Low Byte
79 1 TH1 = 0x00; // Timer 1 High Byte
80 1 TL1 = 0x00; // Timer 1 Low Byte
81 1 TMOD = 0x55; // Timer Mode Register
82 1 TCON = 0x00; // Timer Control Register
83 1
84 1 RCAP2H = 0xFF; // Timer 2 Capture Register High Byte
85 1 RCAP2L = 0xD9; // Timer 2 Capture Register Low Byte
86 1 TH2 = 0x00; // Timer 2 High Byte
87 1 TL2 = 0x00; // Timer 2 Low Byte
88 1 T2CON = 0x34; // Timer 2 Control Register
89 1
90 1 TMR3RLL = 0xB0; // Timer 3 Reload Register Low Byte
91 1 TMR3RLH = 0x3C; // Timer 3 Reload Register High Byte
92 1 TMR3H = 0x3C; // Timer 3 High Byte
93 1 TMR3L = 0xB0; // Timer 3 Low Byte
94 1 TMR3CN = 0x00; // Timer 3 Control Register
95 1
96 1 RCAP4H = 0x00; // Timer 4 Capture Register High Byte
97 1 RCAP4L = 0x00; // Timer 4 Capture Register Low Byte
98 1 TH4 = 0x00; // Timer 4 High Byte
99 1 TL4 = 0x00; // Timer 4 Low Byte
100 1 T4CON = 0x08; // Timer 4 Control Register
101 1 }
102 void AD0_Init(void)
103 {
104 1 REF0CN = 0x07; // Reference Control Register
105 1 //----------------------------------------------------------------
106 1 // ADC Configuration
107 1 //----------------------------------------------------------------
108 1 AMX0CF = 0x60; // AMUX Configuration Register
109 1 AMX0SL = 0x08; // AMUX Channel Select Register
110 1 ADC0CF = 0x58; // ADC Configuration Register
111 1 ADC0CN = 0x80; // ADC Control Register
112 1 }
113 void SMB_Init(void)
114 {
115 1 SMB0CN = 0x44; // SMBus Control Register
116 1 SMB0ADR = 0x00; // SMBus Address Register
117 1 SMB0CR = 0xc4; // SMBus Clock Rate Register 100kbps
C51 COMPILER V7.50 INIT 12/03/2005 12:09:15 PAGE 3
118 1 EIE1 |= 0x02; //Extended Interrupt Enable 1
119 1 }
120 /*************************************************
121 * VERSION: 1.0,2003.4.14
122 * AUTHOR: Xiong Xiaojun,BUAA
123 * FUNCTION: Parameter initialize
124 **************************************************/
125 void Para_Init(void)
126 {
127 1 TimeCount = 0;
128 1 Count = 0;
129 1 LED = 1; // led off
130 1 ENABLE = 0; // disable
131 1 ZEROFLAG = 1;
132 1 READFLAG = 1;
133 1 PRINTFLAG = 1;
134 1 HumidityCount = 0;
135 1 HumidityFreq = 0;
136 1 TempCount = 0;
137 1 Readoverflag = 0;
138 1 StartReadflag = 0;
139 1 RWflag = I2CREAD; // read
140 1 // RWflag = I2CWRITE; // write
141 1 TempValue = 0;
142 1 JQOverFlag = 0;
143 1 }
144 void Init(void)
145 {
146 1 SYSCLK_Init ();
147 1 PORT_Init ();
148 1 Serial_Init();
149 1 Timer_Init();
150 1 AD0_Init();
151 1 Para_Init();
152 1 SMB_Init();
153 1 delay(6000);
154 1 Lcd_Init();
155 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 211 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -