• 大小: 64KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: 其他
  • 标签:

资源简介

利用AT89S51和DAC0832实现的函数信号发生器,可产生方波,正弦波、三角波以及锯齿波。并可以实现调频和调幅两各功能,而且可频率实时显示.绝对原创. 2011.5.21 现在已转软件开发,今天看到大家反应太贵,现下调到了5分,然后根据原理图焊板时请在P0口加上上拉电阻,不然得不到输出波形

资源截图

代码片段和文件信息

#include 

#include 

#define uchar unsigned char

#define DA0832 XBYTE[0xffff]


uchar code tab[10]={0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f};

uchar code tosin[256]={0x800x830x860x890x8d0x900x930x960x990x9c0x9f0xa20xa50xa80xab0xae0xb10xb40xb70xba0xbc0xbf0xc20xc5

0xc70xca0xcc0xcf0xd10xd40xd60xd80xda0xdd0xdf0xe10xe30xe50xe70xe90xea0xec0xee0xef0xf10xf20xf40xf5

0xf60xf70xf80xf90xfa0xfb0xfc0xfd0xfd0xfe0xff0xff0xff0xff0xff0xff0xff0xff0xff0xff0xff0xff0xfe0xfd

0xfd0xfc0xfb0xfa0xf90xf80xf70xf60xf50xf40xf20xf10xef0xee0xec0xea0xe90xe70xe50xe30xe10xde0xdd0xda

0xd80xd60xd40xd10xcf0xcc0xca0xc70xc50xc20xbf0xbc0xba0xb70xb40xb10xae0xab0xa80xa50xa20x9f0x9c0x99

0x960x930x900x8d0x890x860x830x800x800x7c0x790x760x720x6f0x6c0x690x660x630x600x5d0x5a0x570x550x51

0x4e0x4c0x480x450x430x400x3d0x3a0x380x350x330x300x2e0x2b0x290x270x250x220x200x1e0x1c0x1a0x180x16

0x150x130x110x100x0e0x0d0x0b0x0a0x090x080x070x060x050x040x030x020x020x010x000x000x000x000x000x00

0x000x000x000x000x000x000x010x02 0x020x030x040x050x060x070x080x090x0a0x0b0x0d0x0e0x100x110x130x15

0x160x180x1a0x1c0x1e0x200x220x250x270x290x2b0x2e0x300x330x350x380x3a0x3d0x400x430x450x480x4c0x4e 

0x510x550x570x5a0x5d0x600x630x66 0x690x6c0x6f0x720x760x790x7c0x80 };

uchar fun=1b=0c=0d=0e=0tlth;


sbit  P3_0=P3^0;
sbit  P3_1=P3^1;
sbit  P3_2=P3^2;


void key1(void);

void key2(void);

void key3(void);

void key4(void);

void judge(void);


void main(void)

{

TMOD=0X01;

th=0xff;

tl=0x00;

TH0=th;

TL0=tl;

ET0=1;

EA=1;

TR0=1;

while(1)

  {

   judge();

  }

}


void judge(void)

{
   uchar linede1de2keym;

P2=0xff;

keym=P2;

if(keym==0xff)return;

for(de1=0;de1<200;de1++)

     for(de2=0;de2<125;de2++){;}

P2=0xff;

keym=P2;

if(keym==0xff)return;

P2=0xff;

line=P2;



   if(P2==0xfe) key1();

   if(P2==0xfd) key2();

   if(P2==0xfb) key3();

   if(P2==0xf7) key4();


}


void key1(void)             //1键选择发波类型1为正弦波2为三角波3为方波

{

fun++;

if(fun==5)fun=0x01;


}


void key2(void)            //2键加大频率

{

if(th<0xff)th++;

}

void key3(void)           //3键减小频率

{

if(th>0x00)th--;

}


void key4(void)           //4键显示频率

{

double t;

int f;

TR0=0;//ET0的区别

while (P2==0xf7)

{

t=(65535-th*256-tl)*0.5;

f=(int)(15625/(t*4));

P3_0=0; P3_1=0;  P3_2=0;

P1=tab[f%10];

f=f/10;

P3_0=1; P3_1=0;  P3_2=0;

P1=tab[f%10];

f=f/10;

P3_0=0; P3_1=1;  P3_2=0;

P1=tab[f%10];

f=f/10;

P3_0=1; P3_1=1;  P3_2=0;

P1=tab[f];

}

TR0=1;


}


void time0_int(void) interrupt 1   //中断服务程序

{

TR0=0;

if(fun==1)

    {

    DA0832=tos

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      13194  2009-06-05 21:09  xinhao\bestsave.rte

     文件     172992  2009-06-16 14:36  xinhao\Last Loaded xinhao.DBK

     文件       3526  2009-06-01 22:03  xinhao\xinhao.c

     文件        132  2009-06-05 21:10  xinhao\xinhao.DO

     文件     179634  2009-06-19 13:08  xinhao\xinhao.DSN

     文件      27483  2009-06-05 21:10  xinhao\xinhao.EDF

     文件       2874  2009-06-16 14:27  xinhao\xinhao.hex

     文件        209  2009-06-05 21:10  xinhao\xinhao.log

     文件       1008  2009-06-23 15:29  xinhao\xinhao.PWI

     文件      11839  2009-06-05 21:10  xinhao\xinhao.sts

     文件       3653  2009-06-05 13:57  xinhao\xinhao.txt

     文件       3930  2009-06-16 14:27  xinhao\信号发生器程序文档.c

     目录          0  2009-06-23 15:29  xinhao

----------- ---------  ---------- -----  ----

               420474                    13


评论

共有 条评论