📄 tecclock.lst
字号:
C51 COMPILER V7.06 TECCLOCK 07/31/2008 22:35:03 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TECCLOCK
OBJECT MODULE PLACED IN tecclock.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE tecclock.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*1-VSS 2-VDD 3-V0 4-RS 5-R/W 6-E
2 *7-14 DB0-DB7 15-BLA 16-BLK
3 */
4 #define uchar unsigned char
5 #define uint unsigned int
6 #include "def.h"
7 #include <reg52.h>
8 #include <stdio.h>
9 #include <math.h>
10 #include <intrins.h>
11 #include <public.h>
12 //1602
13 extern void DelayMs(unsigned char ms);
14 extern void InitLcd();
15 extern void ShowString (unsigned char line,char *ptr);
16 extern uchar count,num,minute,second,temp;
17
18 //18B20
19 extern unsigned char ReadTemperature(void);
20
21 //1302
22 extern void Write_Ds1302_byte(unsigned char temp);
23 extern void Write_Ds1302( unsigned char address,unsigned char dat );
24 extern unsigned char Read_Ds1302 ( unsigned char address );
25 extern void Read_RTC(void);//read RTC
26 extern void Set_RTC(void);//set RTC
27 extern void chang();
28 /*****************************************************************************/
29 //主函数变量定义
30 uchar cTaskNo = 0;
31 uchar cScanSlotNo = 0;
32 uchar pCurrentSlot = 0;
33
34 //time0初始化
35 /*****************************************************************************/
36 extern uchar cTimeFlag;
37 extern void TimerInit();
38
39 //tecclockzhicuankou
40 /*****************************************************************************/
41 extern uchar code menu[];
42 extern void uart0int();
43 extern void uartsendstr(uchar *);
44 extern void putchar1(uchar );
45
46 /**********************************************************************/
47
48
49 //主函数的多任务处理
50 uchar code tTaskTable[MAX_SLOTNO][MAX_TASKNO] = {
51 1,0,0,0,0,
52 0,1,1,0,0,
53 1,0,0,1,0,
54 0,1,0,0,0,
55 1,0,1,0,0,
C51 COMPILER V7.06 TECCLOCK 07/31/2008 22:35:03 PAGE 2
56 0,1,0,1,0,
57 1,0,0,0,0,
58 0,1,1,0,0,
59 1,0,0,1,0,
60 0,1,0,0,0
61 };
62
63 uchar task_scan()
64 {
65 1 if(cTimeFlag == FALSE)
66 1 {
67 2 return FALSE;
68 2 }
69 1 else
70 1 {
71 2 cTimeFlag = FALSE;
72 2 cScanSlotNo ++;
73 2 if(cScanSlotNo >= MAX_SLOTNO)
74 2 {
75 3 cScanSlotNo = 0;
76 3 }
77 2 pCurrentSlot = cScanSlotNo;
78 2 return (TURE);
79 2 }
80 1 }
81
82 //读命令
83 void task1()
84 {
85 1 uchar tempstr[12];
86 1 if(gCommandDeal == TURE)
87 1 {
88 2 if(gUart0Buf[0] == 'a')
89 2 {
90 3 tempstr[0] = 'y';
91 3 tempstr[1] = 'S';
92 3 tempstr[2] = '\n';
93 3 tempstr[3] = 0;
94 3 uartsendstr(tempstr);
95 3
96 3 gUart0RecCount=0;
97 3 gCommandDeal=FALSE;
98 3
99 3 return;
100 3 }
101 2 if(gUart0Buf[0] == 't')
102 2 {
103 3 gTimeDisplay = TURE;
104 3
105 3 gUart0RecCount = 0;
106 3 gCommandDeal = FALSE;
107 3
108 3 //return;
109 3 }
110 2 gUart0RecCount = 0;
111 2 gCommandDeal = FALSE;
112 2 }
113 1 }
114
115 //在板子的LCD上显示时间
116 void task2()
117 {
C51 COMPILER V7.06 TECCLOCK 07/31/2008 22:35:03 PAGE 3
118 1 Read_RTC();
119 1 chang();
120 1 ShowString(0,l_tmpdate1);
121 1 }
122
123 //在板子上显示温度
124 void task3()
125 {
126 1 uchar temp1[] = {0x00,0x00,0x43,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
127 1 temp = ReadTemperature();
128 1 temp1[0] = temp/10 + 0x30;
129 1 temp1[1] = temp%10 + 0x30;
130 1 ShowString(1,temp1);
131 1 }
132
133 //在超级终端中显示时间
134 void task4()
135 {
136 1 uchar i;
137 1 if(gTimeDisplay == TURE)
138 1 {
139 2 SBUF = 0x0d;
140 2 while(!TI);
141 2 TI = 0;
142 2
143 2 for(i = 0;i < 16;i ++)
144 2 {
145 3 SBUF = l_tmpdate1[i];
146 3 while(!TI);
147 3 TI = 0;
148 3 }
149 2
150 2 }
151 1 }
152
153 //用于扩展
154 void task5()
155 {
156 1
157 1 }
158
159 void main(void)
160 {
161 1 void (*FunctionPionter[MAX_TASKNO])(void); //指针函数数组
162 1 uchar i;
163 1 InitLcd();
164 1 DelayMs(15); //延时15.6ms
165 1
166 1 sprintf(Test1,"t");//the first line
167 1 ShowString(0,Test1);
168 1
169 1 sprintf(TimeNum,"m");//the first line
170 1 ShowString(1,TimeNum);
171 1
172 1 Set_RTC(); //设置时钟
173 1
174 1 for(num=100;num>0;num--)
175 1 {
176 2 for(minute=20;minute>0;minute--)
177 2 {
178 3 for(count=248;count>0;count--)
179 3 {;}
C51 COMPILER V7.06 TECCLOCK 07/31/2008 22:35:03 PAGE 4
180 3 }
181 2 }
182 1
183 1 TimerInit();
184 1 uart0int();
185 1 uartsendstr(menu);
186 1
187 1 FunctionPionter[0] = task1;
188 1 FunctionPionter[1] = task2;
189 1 FunctionPionter[2] = task3;
190 1 FunctionPionter[3] = task4;
191 1 FunctionPionter[4] = task5;
192 1 while(1)
193 1 {
194 2 if(task_scan() == TURE)
195 2 {
196 3 for(i = 0;i < MAX_TASKNO;i ++)
197 3 {
198 4 if(tTaskTable[pCurrentSlot][i] == 1)
199 4 {
200 5 (*FunctionPionter[i])();
201 5 }
202 4 }
203 3 }
204 2 }
205 1 }
206
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 403 ----
CONSTANT SIZE = 69 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 3 43
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 + -