DAC0832數(shù)模轉(zhuǎn)換實(shí)驗(yàn)
#include
#define uchar unsigned char
#define uint unsigned int
uchar tt;
uint temp;
void delay(uint z)
{
uint x,y;
for(x=110;x>0;x--)
for(y=z;y>0;y--);
}
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
for(temp=0x80;temp<0xff;temp++)
{
P0=temp;
delay(10);
}
for(temp=0xff;temp>0x80;temp--)
{
P0=temp;
delay(10);
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++;
}
評(píng)論