#include
at 0x2000 xdata char sinetable[13];
at 0x80 sfr sineout;
char dacout;
char i;
void timer_isr(void) interrupt 1
{
TF0=0;
dacout = sinetable[i++];
TH0= 0xff;
TL0=0xfb;
TR0=1;
if(i>13)
{
dacout = sinetable[0];
i=1;
}
}
void main()
{
sinetable [0] = 128; //0
sinetable [1] =192; //30
sinetable [2] =238; //60
sinetable [3] =255; //90
sinetable [4] =238;
sinetable [5] =192;
sinetable [6] =128;
sinetable [7] =64;
sinetable [8] =17;
sinetable [9] =0;
sinetable [10] =17;
sinetable [11] =64;
sinetable [12] =128;
i=0;
IE=0x82;
TMOD=0x01;
TCON = 0x01;
TH0 = 0xff;
TL0 = 0xFb;
TR0=1;
dacout = sinetable [i++];
for (;;);
}
Comments
Post a Comment