senddat.lst
来自「绝对原创」· LST 代码 · 共 415 行 · 第 1/2 页
LST
415 行
C51 COMPILER V7.07 SENDDAT 08/26/2006 11:15:07 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE SENDDAT
OBJECT MODULE PLACED IN SendDat.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SendDat.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*********************************************************************************************************
-****
2 * 函数名称 :
3 * 功能描述 :
4 * 实际参数 :
5 * 返回值 :
6 * 说明 :
7 **********************************************************************************************************
-****/
8
9 #include "define.h"
10
11 bit AllowReceipt_Flag ; // 容许接受标志位
12 bit Wirte_Flash_Flag ; // 改写FLASH标志
13
14 uint xdata Site_TempDat[10] ; // 设置温度数据
15 uchar xdata Receive_Dat[6] ; // 接收到的数据
16 uchar xdata Send_DatBag[6] ; // 发送数据包
17
18 uchar Receive_Finger ; // 接收指针
19
20 uchar Send_Finger ; // 发送指针
21 uchar Send_Counter ; // 发送计数器
22 uchar Breed_Dat ; // 数据种类,暂时有4种,F0,E0,D0,C0
23
24 /*********************************************************************************************************
-****
25 * 函数名称 :
26 * 功能描述 :
27 * 实际参数 :
28 * 返回值 :
29 * 说明 : 处理发送温度数据子程序,变BCD码,及小数点运算,
30 **********************************************************************************************************
-****/
31 uchar BCD(uchar temp_data)
32 {
33 1 uchar a ;
34 1
35 1 a = (temp_data / 10) % 10 ;
36 1 a <<= 4 ;
37 1 a |= (temp_data % 10) ;
38 1
39 1 return(a) ;
40 1 }
41
42 /*********************************************************************************************************
-****
43 * 函数名称 : uint ChangeBCD(uint ack_data,uint sit_temp)
44 * 功能描述 :
45 * 实际参数 :
46 * 返回值 :
47 * 说明 : 处理发送温度数据子程序,变BCD码,及小数点运算,作假
48 **********************************************************************************************************
-****/
49
C51 COMPILER V7.07 SENDDAT 08/26/2006 11:15:07 PAGE 2
50 uint ChangeBCD(uint ack_data,uint sit_temp)
51 {
52 1 uchar temp ;
53 1 uint temp_dat;//dat1 ;
54 1
55 1 sit_temp >>= 2 ;
56 1 temp_dat = (ack_data >> 2) ; // 取整数,去小数点
57 1 temp = (uchar)(ack_data & 0x03) ;
58 1 if (temp >= 2) // 四舍五入,2 X 0.25 = 0.5 度
59 1 temp_dat++ ;
60 1
61 1 if (sit_temp) // 设置温度不为0时
62 1 if (temp_dat > sit_temp) // 实际温度比设置温度大时,
63 1 {
64 2 if (temp_dat > (sit_temp + 3))
65 2 {
66 3 temp_dat -= 3 ;
67 3 }
68 2 else
69 2 {
70 3 temp_dat = sit_temp ;
71 3 }
72 2
73 2 // dat1 =((temp_dat - sit_temp) >> 1) ; // 过冲温度除2
74 2 // temp_dat = (sit_temp + dat1) ;
75 2 }
76 1
77 1 temp = ((temp_dat / 1000) % 10) ; // 取温度千位数
78 1 temp <<= 4 ;
79 1 temp |= ((temp_dat / 100) % 10) & 0x0f ; // 取温度百位数
80 1
81 1 ack_data = temp ;
82 1
83 1 ack_data <<= 8 ;
84 1
85 1 temp = ((temp_dat / 10) % 10) ; /* 取温度十位数 */
86 1 temp <<= 4 ;
87 1 temp |= ((temp_dat % 10) & 0x0f) ; /* 取温度十位数和个位数 */
88 1
89 1 ack_data |= temp ;
90 1 return(ack_data) ;
91 1 }
92
93 /*********************************************************************************************************
-****
94 * 函数名称 :
95 * 功能描述 :
96 * 实际参数 :
97 * 返回值 :
98 * 说明 : BCD码转十进制,再左移两位,即比实际值打四倍,后两位为小数点位
99 **********************************************************************************************************
-****/
100
101 uint ChangeHex(uchar *change_dat)
102 {
103 1 uint dat0 ;
104 1
105 1 dat0 = (*change_dat >> 4) * 1000 ; // 千位数
106 1 dat0 += (*change_dat & 0x0f) * 100 ; // 百位数
107 1 dat0 += (*(change_dat + 1) >> 4) * 10 ; // 十位数
108 1 dat0 += *(change_dat + 1) & 0x0f ; // 个位数
109 1 dat0 <<= 2 ; // 乘以4倍
C51 COMPILER V7.07 SENDDAT 08/26/2006 11:15:07 PAGE 3
110 1
111 1 return(dat0) ;
112 1 }
113
114 /*********************************************************************************************************
-****
115 * 函数名称 : void SendDat(void)
116 * 功能描述 :
117 * 实际参数 :
118 * 返回值 :
119 * 说明 : 发送数据
120 **********************************************************************************************************
-****/
121
122 void SendDat(void)
123 {
124 1 uint send_array ;
125 1
126 1 if (Send_Counter == 0) // 已发送完毕一帧数据(6组数据)
127 1 {
128 2 if (Breed_Dat) // 有发送
129 2 {
130 3 Send_Counter = 6 ; // 一帧6个数据
131 3
132 3 switch (Breed_Dat)
133 3 {
134 4 case 1:
135 4 Send_DatBag[5] = 0xd1 ; // 数据代码
136 4 Send_DatBag[4] = 0x00 ;
137 4 Send_DatBag[3] = (BCD(Check_TempTimeCycle)) ; // 时间不需要增大4倍
138 4
139 4 Breed_Dat = 2 ; // 发送下一组数据
140 4
141 4 break ;
142 4
143 4 case 2: // 温度数据
144 4 send_array = ChangeBCD(Fact_Temp[Send_Finger],Site_TempDat[Send_Finger]) ; // 转BCD码
145 4
146 4 Send_DatBag[5] = 0xf0 | Send_Finger ; // 数据代码
147 4 Send_DatBag[4] = (uchar)(send_array >> 8) ;
148 4 Send_DatBag[3] = (uchar)send_array ;
149 4
150 4 if (Send_Finger < 9)
151 4 Send_Finger++ ;
152 4 else
153 4 {
154 5 Breed_Dat = 3 ;
155 5 Send_Finger = 0 ;
156 5 }
157 4
158 4 break ;
159 4
160 4 case 3: // 热电偶状态
161 4 Send_DatBag[5] = 0xe0 | Send_Finger ; // 数据代码
162 4 Send_DatBag[4] = 0x00 ;
163 4 Send_DatBag[3] = Thermocouple_Open[Send_Finger] ;
164 4
165 4 if (Send_Finger < 9)
166 4 Send_Finger++ ;
167 4 else
168 4 {
169 5 Breed_Dat = 4 ;
C51 COMPILER V7.07 SENDDAT 08/26/2006 11:15:07 PAGE 4
170 5 Send_Finger = 0 ;
171 5 }
172 4
173 4 break ;
174 4
175 4 case 4: // 温度校正值
176 4 Send_DatBag[5] = 0xc0 | Send_Finger ; // 数据代码
177 4 Send_DatBag[4] = Road_AdhystSign[Send_Finger] ; // 校正符号
178 4 Send_DatBag[3] = BCD(Road_AdjustDat[Send_Finger] >> 2) ;// 校正值
179 4
180 4 if (Send_Finger < 9)
181 4 Send_Finger++ ;
182 4 else
183 4 {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?