📄 reshiqi.c
字号:
//------------------------------------------------------
//Product: xx-rsq0002
//Designer: l jinwei
//Date: 2008-01-15
//------------------------------------------------------
#include <ht46r47.h>
#pragma vector TmrInt @0x8
#define Rly _pa1
#define WaterIn _pb0
#define Irin _pa6
#define Buzzer _pa4
#define Ledda _pb1
#define Ledclk _pb2
#define Ledstb _pd0
#define _pbc0 _15_0
#define _pbc1 _15_1
#define _pbc2 _15_2
#define _pac0 _13_0
#define _pac1 _13_1
#define _pac2 _13_2
#define _pac3 _13_3
#define _pac4 _13_4
#define _pac6 _13_6
#define uchar unsigned char
//-------------------------------
//------------------------------------------------------
uchar KeyBuf @0x40;
uchar DispBuf1 @0x41;
uchar DispBuf2 @0x42;
uchar LedBuf @0x44;
uchar IrBuf @0x45;
uchar Time @0x46;
#define Key1 _40_0
#define Key2 _40_1
#define Key3 _40_2
#define Leda1 _44_0
uchar TmrCnt;
uchar KeyCnt;
uchar BeepCnt;
uchar ErrCnt;
uchar r1;
uchar Adcnt;
uchar Adavr;
uchar Temp,Temp1,Temp2;
uchar Cnt1,Cnt2;
uchar TooHighCnt;
uchar Leddata;
uchar L1,L2,L3,L4,L5,L6,L7,L8,L9;
uchar a,b,k,j,z,reg1,reg2;
uchar hrl,hrh;
uchar BeepTimes;
uchar Time1;
uchar IrbitBuf;
unsigned long Adsum;
bit Flag2ms,Flag2ms1;
bit KeyValid;
bit PowerFlag,EnBeep;
bit Flag05s,Flag05s1,Flag05s2,Flag05s3,Flag05s4;
bit Buf,TempFlag;
bit Irbit,y,x;
bit Key1Flag,Key1Flag1;
bit Key2Flag,Key2Flag1;
bit work,k2,TooHigh;
bit Error,TimeF1;
bit ErrorCode,k4,k5,k6;
bit IrFlag,yingdaoFlag;
void TmrInt(); // timer/event 0
void KeyProcess();
void Keycan();
void TimeCreate();
void AdSub();
void GetTemperature();
void BeepControl();
void ErrorDetect();
void Seg2Port(uchar dbuf);
void Led();
void Display();
void Display1();
void Led1();
void Ircontrol();
void Led3();
void baowen();
void Led2();
void dingshi();
void baojing();
void ErrorDetect();
const unsigned char LEDTAB1[12]=
{
0xE0, // 0
0x00, // 1
0xD0, // 2
0x90, // 3
0x30, // 4
0xB0, // 5
0xF0, // 6
0x00, // 7
0xF0, // 8
0xB0, // 9
0xF0, // E
0x00, // OFF
};
const unsigned char LEDTAB2[12]=
{
0x0F, // 0
0x03, // 1
0x0A, // 2
0x0B, // 3
0x03, // 4
0x09, // 5
0x09, // 6
0x0B, // 7
0x0B, // 8
0x0B, // 9
0x08, // E
0x00, // OFF
};
const unsigned char LEDTAB3[9]=
{
0xC0,
0xC1,
0xC2,
0xC3,
0xC4,
0xC5,
0xC6,
0xC8,
0xCA,
};
const unsigned char LEDTAB4[3]=
{
0x08,
0x04,
0x02,
};
const unsigned char TempTAB2[191]=
{
0,// 165.6061 021
1,// 157.2916 022
2,// 149.4431 023
3,// 142.0318 024
3,// 025
4,// 135.0309 026
5,// 128.4156 027
6,// 122.1623 028
7,// 116.2494 029
7,// 030
8,// 110.6564 031
9,// 105.3643 032
10,// 100.3553 033
10,// 034
11,// 95.6128 035
12,// 91.121 036
12,// 037
13,// 86.8654 038
14,// 82.8323 039
14,// 040
15,// 79.009 041
16,// 75.3833 042
16,// 043
17,// 71.9441 044
17,// 045
18,// 68.6807 046
18,// 047
19,// 65.5832 048
20,// 62.6424 049
20,// 050
21,// 59.8495 051
21,// 052
22,// 57.1963 053
22,// 054
23,// 54.675 055
23,// 056
24,// 52.2786 057
25,// 058
25,// 50 059
25,// 060
26,// 47.833 061
26,// 062
27,// 45.7714 063
27,// 064
28,// 43.8097 065
28,// 066
29,// 41.9425 067
29,// 068
30,// 069
30,// 40.1647 070
30,// 071
31,// 38.4716 072
31,// 073
32,// 36.8589 074
32,// 075
33,// 35.3221 076
33,// 077
33,// 078
34,// 33.8575 079
34,// 080
35,// 32.4612 081
35,// 082
36,// 31.1297 083
36,// 084
36,// 085
37,// 29.8597 086
37,// 087
38,// 28.6481 088
38,// 089
39,// 27.4918 090
39,// 091
39,// 092
40,// 26.3881 093
40,// 094
41,// 25.3344 095
41,// 096
41,// 097
42,// 24.3281 098
42,// 099
43,// 23.3669 100
43,// 101
43,// 102
44,// 22.4485 103
44,// 104
45,// 21.5708 105
45,// 106
46,// 20.7319 107
46,// 108
46,// 109
47,// 19.9298 110
47,// 111
48,// 19.1627 112
48,// 113
48,// 114
49,// 18.4289 115
49,// 116
50,// 17.7269 117
50,// 118
50,// 119
51,// 17.0551 120
51,// 121
52,// 16.412 122
52,// 123
52,// 124
53,// 15.7964 125
53,// 126
54,// 15.2069 127
54,// 128
54,// 129
55,// 14.6422 130
55,// 131
56,// 14.1013 132
56,// 133
57,// 13.583 134
57,// 135
57,// 136
58,// 13.0862 137
58,// 138
59,// 12.61 139
59,// 140
60,// 12.1534 141
60,// 142
60,// 143
61,// 11.7155 144
61,// 145
62,// 11.2956 146
62,// 147
63,// 10.8926 148
63,// 149
63,// 150
64,// 10.506 151
64,// 152
65,// 10.1349 153
65,// 154
66,// 9.7786 155
66,// 156
67,// 9.4366 157
67,// 158
68,// 9.1081 159
68,// 160
69,// 8.7926 161
69,// 162
70,// 8.4895 163
70,// 164
70,// 165
71,// 8.1983 166
71,// 167
72,// 7.9184 168
72,// 169
73,// 7.6494 170
74,// 7.3907 171
74,// 172
75,// 7.142 173
75,// 174
76,// 6.9028 175
76,// 176
77,// 6.6727 177
77,// 178
78,// 6.4513 179
78,// 180
79,// 6.2382 181
79,// 182
80,// 6.0332 183
81,// 5.8359 184
81,// 185
82,// 5.6458 186
82,// 187
83,// 5.4629 188
84,// 5.2866 189
84,// 190
85,// 5.1169 191
86,// 4.9533 192
86,// 193
87,// 4.7958 194
88,// 4.6439 195
88,// 196
89,// 4.4975 197
90,// 4.3564 198
90,// 199
91,// 4.2203 200
92,// 4.0891 201
92,// 202
93,// 3.9625 203
94,// 3.8404 204
95,// 3.7226 205
96,// 3.6089 206
96,// 207
97,// 3.4992 208
98,// 3.3932 209
99,// 3.291 210
100// 3.1923 211
};
//---------------------------------------------
void main()
{
_emi=0; //(1,2)
_eti=0;
_pac=0b01000000;
_pbc=0b00000001;
_pdc=0;
_pa=0b01000000;
_pb=0b00000001;
_pd=0;
_eadi=0;
_eei=0;
//-------------ramClear------------------- //(3)
for (_mp=0x40;_mp!=0x80;_mp++){_iar=0;};
BeepCnt=0; //(4)
_acsr=0;
_adcr=0b00001000;
_tmrc=0x92;
_tmr=0;
_eti=1;
_emi=1;
_pbc0=1;
_pac6=1;
Adcnt=255;
ErrCnt=16;
Leddata=0;
Rly=0;
a=0;
Irbit=x=1;
y=0;
b=0;
k=0;
L7=0xF0;
Temp1=75;
ErrorCode=0;
IrFlag=0;
while(1){ //(5)
_clrwdt();
if(Flag2ms)
{Flag2ms=0;
Keycan();
Led();
KeyProcess();
BeepControl();
Ircontrol();
GetTemperature();
AdSub();
TimeCreate();
Led2();
dingshi();
Led3();
baowen();
baojing();
ErrorDetect();
}
}
}
//------------------------------------------------------
void Display1()
{ uchar i;
for(i=0;i<8;i++)
{
Ledclk=0;
if(Leda1){Ledda=1;}
else{Ledda=0;}
LedBuf>>=1;
Ledclk=1;
_delay(1);
}
}
//------------------------------------------------------
void Display()
{
Ledclk=1;
_delay(1);
Ledstb=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -