?? main.lst
字號:
C51 COMPILER V7.02b MAIN 07/17/2007 21:54:37 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <reg52.h>
2
3 #define uchar unsigned char
4 #define uint unsigned int
5
6 code unsigned char seg7code[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39}; //顯示段碼
7
8
9 /*************lcd函數定義*******************************/
10 void LCD_en_command(unsigned char command);//write command function
11 void LCD_en_dat(unsigned char temp);//write data function
12 void LCD_init(void);//lcd initize function
13 void delay_nms(unsigned int n);//delay function
14 void delay1(uint ticks);//delay function
15
16
17 /*************初始化定時器及計數器的函數*******************************/
18 void initsys();
19
20 /*************ad控制管腳定義*******************************/
21 sbit cs=P3^3;
22 sbit wr=P3^5;
23 sbit rd=P3^4;
24 /*************讀AD0804子程序*******************************/
25 unsigned char adc0804( void ) //讀AD0804子程序
26 { unsigned char addata,i;
27 1 rd=1;wr=1;//int1=1; //讀ADC0804前準備
28 1 P1=0xff; //P1全部置一準備
29 1 cs=0;wr=0;wr=1; //啟動ADC0804開始測電壓
30 1 rd=0; //開始讀轉換后數據
31 1 i=i; i=i; //無意義語句,用于延時等待ADC0804讀數完畢
32 1 addata=P1;//讀出的數據賦與addate
33 1 rd=1;cs=1;//讀數完畢
34 1 return(addata);//返回最后讀出的數據
35 1 }
36 /*************ADC0804讀出的數據處理*******************************/
37 unsigned int datpro(void)//ADC0804讀出的數據處理
38 { unsigned char x;
39 1 unsigned int dianyah,dianyal; //用于存儲讀出數據的高字節和低字節
40 1 unsigned int dianya=0; //存儲最后處理完的結果 注意數據類型
41 1 for(x=0;x<10;x++) //將10次測得的結果存儲在dianya中
42 1 {dianya=adc0804()+dianya; }
43 1 dianya=dianya/10; //求平均值
44 1 dianyah=dianya&0xf0; //屏蔽低四位
45 1 dianyah=dianyah>>4; //右移四位 取出高四位
46 1 dianyal=dianya&0x0f; //屏蔽高四位 取出低四位
47 1 dianya=dianyal*20+dianyah*320; //最后的結果是一個四位數,便于顯示
48 1 return(dianya);//返回最后處理結果
49 1 }
50 /*************顯示輸出函數******************************/
51 void AD_LCD()
52 { unsigned long date;
53 1 //unsigned long date1;
54 1 date=datpro(); //調用數據處理最后結果
55 1
C51 COMPILER V7.02b MAIN 07/17/2007 21:54:37 PAGE 2
56 1
57 1 /************千位********************************/
58 1 LCD_en_command(0xc5);
59 1 LCD_en_dat(seg7code[date/1000]);
60 1 delay_nms(20);
61 1 /*********輸出得是.***********************************/
62 1 LCD_en_command(0xc6);//輸出得是.
63 1 LCD_en_dat(46);
64 1 delay_nms(20);
65 1 /**********百位***************************************/
66 1 LCD_en_command(0xc7);
67 1 LCD_en_dat(seg7code[date%1000/100]);
68 1 delay_nms(20);
69 1 /*********十位**************************************/
70 1 LCD_en_command(0xc8);
71 1 LCD_en_dat(seg7code[date%100/10]);
72 1 delay_nms(20);
73 1 /*********個位**************************************/
74 1 LCD_en_command(0xc9);
75 1 LCD_en_dat(seg7code[date%10]);
76 1 delay_nms(20);
77 1 /*********輸出得是V*************************************/
78 1 LCD_en_command(0xca);//輸出得是V
79 1 LCD_en_dat(86);
80 1 delay_nms(20);
81 1 }
82
83 main()
84 {
85 1 LCD_init();
86 1 while(1)
87 1 {
88 2 AD_LCD();
89 2 }
90 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 378 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 4
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 + -