51_LanQiaoBei/模板/蓝桥杯全模块测试例程/DS18B20温度模块/User/Listings/main.lst

157 lines
5.7 KiB
Plaintext
Raw Normal View History

2025-04-13 01:02:19 +08:00
C51 COMPILER V9.59.0.0 MAIN 05/02/2024 15:57:33 PAGE 1
C51 COMPILER V9.59.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Objects\main.obj
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(8,SPEED) BROWSE INCDIR(..\Driver) DEBUG OBJECTEXTEND PRI
-NT(.\Listings\main.lst) TABS(2) OBJECT(.\Objects\main.obj)
line level source
1 #include "main.h"
2 /* LED<45><44>ʾ */
3 uchar ucLed[8] = {0, 0, 0, 0, 0, 0, 0, 0};
4
5 /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ */
6 uchar Seg_Slow_Down; // <20><><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD>
7 uchar Seg_Buf[8] = {10, 10, 10, 10, 10, 10, 10, 10}; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ֵ
8 uchar Seg_Pos; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ
9 uchar Seg_Point[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // ijλ<C4B3>Ƿ<EFBFBD><C7B7><EFBFBD>ʾС<CABE><D0A1><EFBFBD><EFBFBD>
10
11 /* <20><><EFBFBD>̷<EFBFBD><CCB7><EFBFBD> */
12 uchar Key_Slow_Down;
13
14 /* <20><><EFBFBD><EFBFBD> */
15 uint temperature_value_10x; // <20><EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
16 bit C_F_flag; // <20><><EFBFBD>϶<EFBFBD>ת<EFBFBD><D7AA><EFBFBD>϶<EFBFBD>
17
18 #define N 10
19 uint data_array[N]; // <20><><EFBFBD>ڴ<EFBFBD>С
20 uint sum_temp; // <20>ܺ<EFBFBD>
21 uchar index_temp; // <20><><EFBFBD><EFBFBD>
22 uchar arr_count; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
23
24 uint filter(uint new_data)
25 {
26 1 sum_temp -= data_array[index_temp];
27 1 data_array[index_temp] = new_data;
28 1 sum_temp += data_array[index_temp];
29 1 index_temp = (++index_temp) % N; // <20><>֤index_temp<6D><70>0~N-1֮<31><D6AE><EFBFBD><EFBFBD>ת
30 1 arr_count = (++arr_count == N + 1) ? N : arr_count; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
31 1 return sum_temp / arr_count;
32 1 }
33
34 /* <20><><EFBFBD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
35 void Key_Proc()
36 {
37 1 static uchar Key_Val, Key_Down, Key_Up, Key_Old;
38 1 if (Key_Slow_Down)
39 1 return;
40 1 Key_Slow_Down = 1;
41 1
42 1 Key_Val = Key_Read();
43 1 Key_Down = Key_Val & (Key_Old ^ Key_Val);
44 1 Key_Up = ~Key_Val & (Key_Old ^ Key_Val);
45 1 Key_Old = Key_Val;
46 1 if (Key_Down == 4)
47 1 C_F_flag ^= 1;
48 1 }
49 /* <20><><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
50 void Seg_Proc()
51 {
52 1 if (Seg_Slow_Down)
53 1 return;
54 1 Seg_Slow_Down = 1;
C51 COMPILER V9.59.0.0 MAIN 05/02/2024 15:57:33 PAGE 2
55 1 temperature_value_10x = filter(rd_temperature() * 10);
56 1 if (C_F_flag)
57 1 temperature_value_10x = temperature_value_10x * 1.8 + 320; // <20><><EFBFBD>϶<EFBFBD>
58 1 Seg_Buf[0] = temperature_value_10x / 1000 % 10;
59 1 Seg_Buf[1] = temperature_value_10x / 100 % 10;
60 1 Seg_Buf[2] = temperature_value_10x / 10 % 10;
61 1 Seg_Buf[3] = temperature_value_10x % 10;
62 1 Seg_Buf[4] = (C_F_flag) ? 12 : 11;
63 1 Seg_Point[2] = 1;
64 1 }
65
66 /* LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
67 void Led_Proc()
68 {
69 1 }
70
71 /* <20><>ʱ<EFBFBD><CAB1>0<EFBFBD>жϳ<D0B6>ʼ<EFBFBD><CABC> */
72 void Timer0_Init(void) // 1<><31><EFBFBD><EFBFBD>@12.000MHz
73 {
74 1 AUXR &= 0x7F; // <20><>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>12Tģʽ
75 1 TMOD &= 0xF0; // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>ģʽ
76 1 TL0 = 0x18; // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>ʼֵ
77 1 TH0 = 0xFC; // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1>ʼֵ
78 1 TF0 = 0; // <20><><EFBFBD><EFBFBD>TF0<46><30>־
79 1 TR0 = 1; // <20><>ʱ<EFBFBD><CAB1>0<EFBFBD><30>ʼ<EFBFBD><CABC>ʱ
80 1 ET0 = 1;
81 1 EA = 1;
82 1 }
83
84 /* <20><>ʱ<EFBFBD><CAB1>0<EFBFBD>жϺ<D0B6><CFBA><EFBFBD> */
85 void Timer0_ISR(void) interrupt 1
86 {
87 1 if (++Key_Slow_Down == 10)
88 1 Key_Slow_Down = 0;
89 1 if (++Seg_Slow_Down == 500)
90 1 Seg_Slow_Down = 0;
91 1 if (++Seg_Pos == 8)
92 1 Seg_Pos = 0;
93 1 Seg_Disp(Seg_Pos, Seg_Buf[Seg_Pos], Seg_Point[Seg_Pos]);
94 1 Led_Disp(Seg_Pos, ucLed[Seg_Pos]);
95 1 }
96
97 void Delay750ms(void) //@12.000MHz
98 {
99 1 unsigned char data i, j, k;
100 1
101 1 _nop_();
102 1 _nop_();
103 1 i = 35;
104 1 j = 51;
105 1 k = 182;
106 1 do
107 1 {
108 2 do
109 2 {
110 3 while (--k)
111 3 ;
112 3 } while (--j);
113 2 } while (--i);
114 1 }
115
116 void main()
C51 COMPILER V9.59.0.0 MAIN 05/02/2024 15:57:33 PAGE 3
117 {
118 1 System_Init();
119 1 Timer0_Init();
120 1 rd_temperature();
121 1 Delay750ms();
122 1 while (1)
123 1 {
124 2 Key_Proc();
125 2 Seg_Proc();
126 2 Led_Proc();
127 2 }
128 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 477 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 57 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)