Any one can help me!
i am doing Pulses wdith varying Between 1 to 5v in keil by using 89s52+0809adc.
but it not generate the pulses.
Code C - [expand] |
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
| #include<reg51.h>
void delay(int);
void BCD(void);
void delay_pulse(int );
sbit ALE=P0^6;
sbit SC=P0^5;
sbit EOC=P3^2;
sbit OE=P0^7;
sbit A0=P0^2;
sbit A1=P0^1;
sbit A2=P0^0;
//sbit clk=P1^7;
/*void timer0() interrupt 1 // Function to generate clock of frequency 500KHZ using Timer 0 interrupt.
{
clk=~clk;
}*/
unsigned char x,y;
void main()
{
P2=0xFF;
P0=0x00;
P3=0xFF;
while(1)
{
A0=0;
A1=0;
A2=0;
delay(1);
ALE=1;
delay(1);
SC=1;
delay(1);
ALE=0;
SC=0;
while(EOC==1);
while(EOC==0);
OE=1;
BCD();
delay(1);
OE=0;
}
}
void delay(int m)
{
int i,j;
for(i=0;i<=250;i++)
for(j=0;j<=m;j++);
}
void delay_pulse(int j)
{
int i,k;
for(i=0;i<=250;i++)
for(k=0;k<=j;k++);
}
void BCD()
{ int z;
x=P2;
y=x%10;
x=x/10;
z=y+48;
P1=0x00;
delay_pulse(z);
P1=0x01;
delay_pulse(z);
} |
Last edited by a moderator: