本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
求大神们帮忙看一下,这个程序为什么编译不了(正在做基于单片机的信号发生器的设计,拜托各位大神!!):
#include<reg51.h>
#include<absacc.h>
#define ucharunsigned char
#defineDAC_DATA P0
sbit nWR=P3^6;
sbit nCS=P2^7;
unsigned inta;
voidcleARMen();
voidkeyscan();
voiddelay1ms(unsigned char ms);
//正弦波产生子程序:
uchar codesin_tab[128]={64,67,70,73,76,79,82,85,88,91,94,96,99,102,104,106,
109,111,113,115,117,118,120,121,123,124,125,126,126,
127,127,127,127,127,127,127,126,126,125,124,123,121,
120,118,117,115,113,111,109,106,104,102,99,96,94,91,
88,85,82,79,76,73,70,67,64,60,57,54,51,48,45,42,39,
36,33,31,28,25,23,21,18,16,14,12,10,9,7,6,4,3,2,1,
1,0,0,0,0,0,0,0,1,1,2,3,4,6,7,9,10,12,14,16,18,21,23,
25,28,31,33,36,39,42,45,48,51,54,57,60
};
//三角波产生子程序:
uchar codesan_tab[128]={0,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,63,62,61,60,59,58,57,56,55,54,53,
52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,
34,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,
15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
};
//方波产生子程序:
uchar codePos_tab[128]={0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,
0,255
};
//锯齿波产生子程序:
uchar codeJuC_tab[128]={0,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,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,
108,109,110,111,112,113,114,115,116,117,118,119,120,
121,122,123,124,125,126,127
};
unsigned char code*DacPtr;
sbit K1=P1^4;
sbit K2=P1^5;
sbit K3=P1^6;
sbit K4=P1^7;
sbit K5=P1^3;
sbit K6=P1^2;
//
void main()
{
clearmen();
while(1)
{
keyscan();
}
}
//
voidkeyscan() /键控部分/
{
if(K1==0) /当K1按下时,产生正弦波/
{
while(K1==0);
DacPtr=sin_tab;
}
if(K2==0) /当K2按下时,产生三角波/
{
while(K2==0);
DacPtr=san_tab;
}
if(K3==0) /当K3按下时,产生方波/
{
while(K3==0);
DacPtr=Pos_tab;
}
if(K4==0) /当K4按下时,产生锯齿波/
{
while(K4==0);
DacPtr=JuC_tab;
}
if(K5==0) /当K5按下时,波形频率增大/
{
while(K5==0);
FreqControl+=1;
if(FreqControl>12)
{
FreqControl=1;
}
}
if(K6==0) /当K6按下时,波形频率减小/
{
while(K6==0);
FreqControl-=1;
if(FreqControl<=0)
{
FreqControl=12;
}
}
}
//================================================================
void clearmen()
{
DacPtr=sin_tab;
nCS=0;
DAC_DATA=0xff;
nWR=0;
P3=0xff;
TH1=255;
TL1=155;
TMOD=0x21;
P3=0x00;
a=0;
ET1=1;
TR1=1;
EA=1;
} |