资源简介
ADC0809 protues电路仿真设计,有C语言源代码!
代码片段和文件信息
#include
#define uint unsigned int
#define uchar unsigned char
sbit RS = P2^0;
sbit RW = P2^1;
sbit E = P2^2;
sbit ADDA = P2^5;
sbit ADDB = P2^6;
sbit ADDC = P2^7;
sbit start = P2^4;
sbit OE = P3^1;
sbit EOC = P3^2;
double LSB = 0.01961;
uchar table[]={ 0x300x310x320x0330x340x350x360x370x0380x39
0x410x420x430x440x450x46
};
uchar temp;
void check_busy()
{
uchar busy;
E = 0;
RS = 0;
RW = 1;
E = 1;
busy = P0;
E = 0;
while((busy>>7) == 0x01)
{
E= 1;
busy = P0;
E = 0;
}
}
void delay(uint i)
{
while(i--);
}
void write_com(uchar com)
{
check_busy();
E = 0;
RW = 0;
RS = 0;
P0 = com;
E = 1;
delay(20);
E = 0;
}
void write_data(uchar data_lcd)
{
check_busy();
E = 0;
RW = 0;
RS = 1;
E = 1;
P0 = data_lcd;
E = 0;
}
void write_str(uchar addruchar *p)
{
write_com(addr);
while(*p != 0x00)
{
write_data(*p);
p++;
}
}
void init_lcd(void)
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
}
void display()
{
write_str(0x80“Ch0:“);
write_str(0xc0“Ch1:“);
write_str(0x94“Ch2:“);
write_str(0xd4“Ch3:“);
}
uchar AD_0809(uchar addr)
{
uchar temp ;
addr = addr << 5;
P2 &= 0x1f;
P2 |= addr;
OE = 0;
start = 0;
start = 1;
start = 0;
while(EOC);
OE = 1;
temp = P1;
OE = 0;
return temp;
}
void show_num(uchar ch)
{
double data_AD;
switch(ch)
{
case 0x00:{write_com(0x85);break;}
case 0x01:{write_com(0xc5);break;}
case 0x02:{write_com(0x99);break;}
case 0x03:{write_com(0xd9);break;}
default : break;
}
data_AD = (double)(AD_0809(ch)* LSB*10);
write_data(table[(uint)data_AD/10]);
write_data(table[(uint)data_AD%10]);
delay(1);
write_data(‘.‘);
data_AD = data_AD - (uint)data_AD;
data_AD *= 10;
write_data(table[(uint)data_AD]);
data_AD = data_AD - (uint)data_AD;
data_AD *= 10;
write_data(table[(uint)data_AD]);
data_AD = data_AD - (uint)data_AD;
data_AD *= 10;
write_data(table[(uint)data_AD]);
data_AD = data_AD - (uint)data_AD;
data_AD *= 10;
write_data(table[(uint)data_AD]);
}
void main()
{
init_lcd();
display();
while(1)
{
show_num(0x00);
show_num(0x01);
show_num(0x02);
show_num(0x03);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 177 2011-08-26 21:32 ad0809_me\AD0809.plg
文件 55238 2011-08-27 19:39 ad0809_me\AD0809.uvopt
文件 13253 2011-08-26 21:54 ad0809_me\AD0809.uvproj
文件 55236 2011-08-27 15:02 ad0809_me\AD0809_uvopt.bak
文件 0 2011-08-26 21:32 ad0809_me\AD0809_uvproj.bak
文件 153169 2011-08-27 19:39 ad0809_me\ADDA.DSN
文件 768 2011-08-28 10:20 ad0809_me\ADDA.PWI
文件 2340 2011-08-27 19:19 ad0809_me\code\AD0809.c
文件 143624 2011-08-27 15:02 ad0809_me\Last Loaded ADDA.DBK
文件 9273 2011-08-27 19:19 ad0809_me\ouotput\AD0809
文件 4743 2011-08-27 19:19 ad0809_me\ouotput\AD0809.hex
文件 94 2011-08-27 19:19 ad0809_me\ouotput\AD0809.lnp
文件 6479 2011-08-27 19:19 ad0809_me\ouotput\AD0809.lst
文件 12416 2011-08-27 19:19 ad0809_me\ouotput\AD0809.m51
文件 9555 2011-08-27 19:19 ad0809_me\ouotput\AD0809.obj
文件 4017 2011-08-27 19:19 ad0809_me\ouotput\AD0809.plg
目录 0 2011-08-27 19:47 ad0809_me\code
目录 0 2011-08-27 19:47 ad0809_me\ouotput
目录 0 2011-08-28 10:20 ad0809_me
----------- --------- ---------- ----- ----
470382 19
评论
共有 条评论