基于单片机正弦波波发生器仿真设计

【资源下载】下载地址如下1544:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl

#include<reg52.h>
#define  uchar unsigned char
#define  uint  unsigned int
//#define  Fosc  24000000/12000000  //12分频后的频率

#define DAdata  P0	//DA数据端口
sbit DA_S1= P2^0;   // 控制DAC0832的8位输入寄存器,仅当都为0时,可以输出数据(处于直通状态),否则,输出将被锁存
sbit DA_S2= P2^1;   // 控制DAC0832的8位DAC寄存器,仅当都为0时,可以输出数据(处于直通状态),否则,输出将被锁存
sbit key=   P3^2;
uchar wavecount;    //'抽点'计数
uchar THtemp,TLtemp;//传递频率的中间变量
//uint T_temp;
uchar judge=1;      //在输出函数中用于简单判别作用
uchar waveform;	    //波形标志位
uchar flag=0;

uchar code freq_unit[3]={10,10,10};    //增加或者减少10倍频
uchar idata wavefreq[3]={1,1,1}; 	  //给波定义一个数组单元,用于存放单位频率的个数
uchar code  lcd_hang1[]={"Sine Wave       " "Triangle Wave   " "Square Wave     " "Select Wave:    " "press No.1 key! "};
uchar idata lcd_hang2[16]={"f=    Hz        "};



/***********这两组数组很重要,需要根据波形来调试,选择合适的值,使输出波形达到频率要求************/
uchar code waveTH[]={
    0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xec,0xf6,0xf9,0xfb,0xfc,0xfc,0xfd,0xfd,0xfd,0xfe};
uchar code waveTL[]={ 
    0x06,0x8a,0x10,0x4e,0x78,0x93,0xa8,0xb3,0xbe,0xc6, //频率调整中间值
	0xac,0xde,0x48,0x7a,0x99,0xaf,0xbb,0xc8,0xd0,0xde,	//频率调整中间值
	0x88,0x50,0x90,0x32,0x34,0xbe,0x4a,0xa3,0xe5,0x2c}; 

posted @ 2021-03-27 09:05  roadroad  阅读(116)  评论(0编辑  收藏  举报
电设屋
上千套电子毕设课设方案