📄 12864_main.lst
字号:
C51 COMPILER V7.09 12864_MAIN 04/14/2009 09:36:31 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE 12864_MAIN
OBJECT MODULE PLACED IN 12864_main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 12864_main.c OMF2 OPTIMIZE(9,SIZE) BROWSE DEBUG
line level source
1 //--------------------------------------------------------------
2 //--管脚的分配关系:
3 //****************P27------LCD__RS------第4脚,并行的数据命令选择信号
4 //****************P26------LCD__RW------ 第5脚,并行的读写选择信号
5 //****************P25------LCD__E ------ 第6脚,并行的使能信号
6 //****************P24------LCD__PSB ---- 第15脚,并行接口选择信号
7 //****************P23------LCD__RST ---- 第17脚,复位信号
8 //****************P1^6-----I2C_SDA------ eeprom data line
9 //****************P1^7-----I2C_SDA------ eeprom clock line
10 /*2009年1月13日,eeprom 的时序完全好,不可修改 程序已经优化
11 *********************************************************************************
12 *********************************************************************************
13 *********************************************************************************
14 ********************************************************************************/
15
16 #include "reg52.h"
17 #include "declare.h"
18 #include "stdio.h" //-----该函数中有把整数和字符连接在一起的函数
19 #include "key.h"
20
21 #include "communicate.h"
22 //----------------------------------------------------库函数定义
23 unsigned char xdata str1[20];
24 unsigned char xdata str2[20];
25 unsigned char xdata str3[20];
26 unsigned char xdata str4[20];
27 char set[]="设置";
28 char clr_set[] =" ";
29 char key_flag=0; //是否向eeprom里面写数据的判断条件
30 extern char select_t=0; //键盘功能选择
31
32 //extern unsigned int xdata RxBuf[30];
33 unsigned char total_t[4]={2,50,2,50};
34 unsigned char prodata[4]={0,0,0,0};
35 unsigned int bai[4]={0,0,0,0};
36 unsigned int shi[4]={0,0,0,0};
37 unsigned char cnt=20;//--------------------定时器计数-----------------
38 unsigned char a=0;
39 unsigned char send_flag=1;
40 //unsigned char ok1[]='S'; // use for test
41 //--------------------------------------------------------------------
42 //char count=0;
43 //extern uchar receive[6]={0};
44 void T0Initial();//------------------------T0定时初始化中断函数
45 void velocity_show(); //-----------------------显示设置参数
46 void read_eeprom();
47 void write_eeprom();
48 extern void process_data();
49 void evaluate();
50 //--------------------------------------------------------------------
51
52 sbit key_set=P1^2;
53 sbit key_add=P1^0;
54 sbit key_dec=P1^1;
55 sbit key_ok=P1^3; //-----------------------确定按键,同时也是串口发送数据标志
C51 COMPILER V7.09 12864_MAIN 04/14/2009 09:36:31 PAGE 2
56
57 void main()
58 {
59 1 //char j;
60 1 //********************************************************************
61 1 init_timer1(); //串口初始化
62 1 LCD_init(); //lcd初始化
63 1 LCD_write_char( 0x01, 0 ); //LCD清屏
64 1 delay_nms(100);
65 1
66 1 PHOTO_DISP(TU_TAB1); //-------显示图形我的电脑
67 1 delay_nms(1000); //延迟--------一段时间
68 1 LCD_write_char( 0x01, 0 ); //清屏
69 1 delay_nms(100);
70 1 PHOTO_DISP(BIRD); //显示图形--自己画的
71 1 delay_nms(1300);
72 1 LCD_write_char( 0x01, 0 ); //清屏
73 1
74 1
75 1 T0Initial(); //--------------------------初始化T0-----------------
76 1
77 1
78 1 while(1)
79 1 {
80 2 Key_read (); //键盘扫描
81 2 process_data();
82 2
83 2 if(key_ok==0) //---确定
84 2 {
85 3 select_t=0; //----擦掉显示
86 3 //write_eeprom(); //写进eeprom
87 3 //TI=1; //----发送数据
88 3 send_flag=1;
89 3 }
90 2
91 2 switch(select_t)
92 2 {
93 3 case 1:
94 3 LCD_write_string(6,0,set);
95 3 LCD_write_string(6,1,clr_set);
96 3 LCD_write_string(14,0,clr_set);
97 3 LCD_write_string(14,1,clr_set);
98 3 break;
99 3 case 2:
100 3 LCD_write_string(6,1,set);
101 3 LCD_write_string(6,0,clr_set);
102 3 LCD_write_string(14,0,clr_set);
103 3 LCD_write_string(14,1,clr_set);
104 3 break;
105 3 case 3:
106 3 LCD_write_string(14,0,set);
107 3 LCD_write_string(6,0,clr_set);
108 3 LCD_write_string(6,1,clr_set);
109 3 LCD_write_string(14,1,clr_set);
110 3 break;
111 3 case 4:
112 3 LCD_write_string(14,1,set);
113 3 LCD_write_string(6,0,clr_set);
114 3 LCD_write_string(14,0,clr_set);
115 3 LCD_write_string(6,1,clr_set);
116 3 break;
117 3 case 0:
C51 COMPILER V7.09 12864_MAIN 04/14/2009 09:36:31 PAGE 3
118 3 LCD_write_string(6,0,clr_set);
119 3 LCD_write_string(6,1,clr_set);
120 3 LCD_write_string(14,0,clr_set);
121 3 LCD_write_string(14,1,clr_set);
122 3 break;
123 3 default:
124 3 break;
125 3 }
126 2 //------------------------------------
127 2 velocity_show(); //LCD show function
128 2 //---------------------------------------------------------------------------------
129 2 }
130 1 }
131
132 //----------------LCD SHOW FUNCTION--------------------------------
133
134 void velocity_show()
135 {
136 1 //---Warning !!the data type of readI2C is very important ,
137 1 //----otherwise showing result is wrong, such as ,1 is like to be 256
138 1 // int i,j;
139 1 // i=
140 1 process_data();
141 1 sprintf(str1,"数据N1=%d%dms",(RxBuf[0]-0x30),(RxBuf[1]-0x30)); //串口传递的是ASCALL码,需要转换
142 1 // sprintf(str2,"t2延时=%d%dms",bai[1],shi[1]);
143 1 sprintf(str2,"数据N2=%d%dms",(RxBuf[2]-0x30),(RxBuf[3]-0x30));
144 1 // sprintf(str3,"t3进棉=%d%dms",bai[2],shi[2]);
145 1 sprintf(str3,"数据N3=%d%dms",(RxBuf[4]-0x30),(RxBuf[5]-0x30));
146 1 // sprintf(str4,"t4延时=%d%dms",bai[3],shi[3]);
147 1
148 1
149 1 sprintf(str4,"数据N4=%d%dms",(RxBuf[6]-0x30),(RxBuf[7]-0x30));
150 1
151 1 LCD_write_string(0,0,str1);
152 1 LCD_write_string(0,1,str2);
153 1 LCD_write_string(0,2,str3);
154 1 LCD_write_string(0,3,str4);
155 1 }
156 //---------------处理数据子函数-----------------------------------
157 extern void process_data()
158 {
159 1 unsigned char i;
160 1
161 1 for(i=0;i<4;i++)
162 1 {
163 2 //prodata[i]=(int)readI2c(i);
164 2 prodata[i]=total_t[i];
165 2 bai[i]=prodata[i]/10;
166 2 shi[i]=prodata[i]%10;
167 2 }
168 1 }
169
170
171 //----------------键盘程序----------------------------------
172 ///---------------P1.0做加法-------------------
173 //----------------P1.1做减法-------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -