📄 uart0.lst
字号:
C51 COMPILER V8.02 UART0 07/29/2008 10:46:19 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE UART0
OBJECT MODULE PLACED IN UART0.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE UART0.C BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "C8051F020.h"
2 #include "string.h"
3
4 // Peripheral specific initialization functions,
5 // Called from the Init_Device() function
6 void Reset_Sources_Init()
7 {
8 1 WDTCN = 0xDE;
9 1 WDTCN = 0xAD;
10 1 }
11
12 void Timer2_Init()
13 {
14 1 CKCON = 0x20; //T2按系统时钟计数
15 1 T2CON = 0x30; //工作方式2
16 1 RCAP2L = 0x70; //波特率2400,重载值65536-11059200/2400/32=65536-144=65392=0xff70
17 1 RCAP2H = 0xFF;
18 1 TL2 = 0xFF;
19 1 TH2 = 0xFF;
20 1 T2CON|= 0x04; //启动T2
21 1
22 1 }
23
24 void UART0_Init()
25 {
26 1 SCON0 = 0x40; //方式1,波特率不加倍
27 1 }
28
29 void Port_IO_Init()
30 {
31 1
32 1
33 1 XBR0 = 0x04; //UART0配置端口,并使能交叉开关
34 1 XBR2 = 0x40;
35 1 }
36
37 void Oscillator_Init()
38 {
39 1 int i = 0;
40 1 OSCXCN = 0x77;
41 1 for (i = 0; i < 3000; i++); // Wait 1ms for initialization
42 1 while ((OSCXCN & 0x80) == 0);
43 1 OSCICN = 0x0C;
44 1 }
45
46 void Interrupts_Init()
47 {
48 1 IE = 0x10; //开UART中断
49 1 }
50
51 // Initialization function for device,
52 // Call Init_Device() from your main program
53
54 char c[]={"China"}; //中断方式
55 char i=0,length;
C51 COMPILER V8.02 UART0 07/29/2008 10:46:19 PAGE 2
56 void main(void)
57 {
58 1 //char c[]={"China"}; 查询方式
59 1 //char i=0,length;
60 1 Reset_Sources_Init();
61 1 Oscillator_Init();
62 1 Interrupts_Init();
63 1 Port_IO_Init();
64 1 Timer2_Init();
65 1 UART0_Init();
66 1 EA=1;
67 1 length=strlen(c);
68 1 SBUF0=c[i];
69 1 while(1);
70 1
71 1 //for(i=0;i<length;i++) 查询方式
72 1 //{
73 1 // SBUF0=c[i];
74 1 // while(!TI0);
75 1 // TI0=0;
76 1 //}
77 1
78 1 }
79
80 void interrupt_UART0 (void) interrupt 4
81 {
82 1 TI0=0;
83 1 if (i<length)
84 1 {
85 2 i++;
86 2 SBUF0=c[i];
87 2 }
88 1 else
89 1 {
90 2 EA=0;
91 2 }
92 1
93 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 156 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 ----
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 + -