include ADuC812 include max define SV 0x7 unsigned char mTikPulse Viho

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "ADuC812.h"
#include "max.h"
#define SV 0x7
unsigned char mTikPulse, T, VihodZaPredeli;
unsigned char mTikPer1s=175, mCountTik=0;
unsigned char des, edin = 0x80;
char mas[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0xFF, 0x6F};
void WriteMax(unsigned char xdata *regnum, unsigned char val){
unsigned char oldDPP=DPP;
DPP=8;
*regnum=val;
DPP=oldDPP;
}
//========Timer INTERRUPT=========
void t0ISR(void) interrupt 1
{
TR0=0;
TH0=0;
TL0=0;
TR0=1;
mCountTik++;
mTikPulse++;
if (mCountTik == mTikPer1s) {
des = (T/10);
edin =(T-T/10);
WriteMax(SV,0x01);
while(1){
WriteMax(EXT_LO , 0x01);
WriteMax(EXT_HI , mas[des]);
WriteMax(EXT_LO , 0x00);
WriteMax(EXT_LO , 0x02);
WriteMax(EXT_HI , mas[edin]);
WriteMax(EXT_LO , 0x00);
}
}
return;
}
void t2ISR(void) interrupt 5
{
if (EXF2 == 1){
EXF2 = 0;
T = 4*mTikPulse;
mTikPulse = 0;
if ((T>=8)|(T<=28)) mCountTik = 0;
}
if (TF2 == 1){
TF0 = 0;
}
return;
}
//================================
void main(void){
PLLCON = 0; //16MHZ
while(!(PLLCON&LOCK));
EA=1;
//Timer0 and 2 On
TMOD|=0x01;
TR0=1;
ET0=1;
T2CON = 0x9;
ET2=1;
T2CON |= 0x4;
while(1){
}
}