基于51单片机的函数信号发生器刘志强内容摘要:

,0x0f ,0x10,0x11,0x13,0x15,0x16,0x18,0x1a,0x1c,0x1e,0x20,0x22,0x25,0x27,0x29,0x2b,0x2e,0x30,0x33,0x35,0x38,0x3a,0x3d,0x40,0x43 ,0x45,0x48,0x4c,0x4e,0x51,0x55,0x57,0x5a,0x5d,0x60,0x63,0x66 ,0x69,0x6c,0x6f,0x72,0x76,0x79,0x7c,0x80}。 uchar code sanjiao[]={0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66, 68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134, 136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194, 196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,244,246,248,250,252,254, 255,254,252,250,248,246,244,242,240,238,236,234,232,230,228,226,224,222,220,218,216,214,212,210,208,206,204,202,200,198, 196,194,192,190,188,186,184,182,180,178,176,174,172,170,168,166,164,162,160,158,156,154,152,150,148,146,144,142,140,138, 136,134,132,130,128,126,124,122,120,118,116,114,112,110,108,106,104,102,100,98,96,94,92,90,88,86,84,82,80,78,76,74,72,70, 68,66,64,62,60,58,56,54,52,50,48,46,44,42,40,38,36,34,32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2}。 void key_gongneng()。 uint key_sub_mul(uint movedate)。 void display()。 void control()。 uint T0_chuzhi,an_cishu,gedian,quzhi,fangbo_fre=250,fre=250,t0_aa,fangbo_quzhi,fangbo_fre_show,fre_show,flag,t0_cishu,t0_zhuangzhi。 void delay(uint xms)//延时函数; { uint i,j。 for(i=xms。 i0。 i) for(j=25。 j0。 j)。 } void write_(uint )//LCD 写命令; { lcdrs=0。 P0=。 delay(5)。 lcden=1。 delay(5)。 lcden=0。 } void write_date(uint date)//LCD 写数据; { lcdrs=1。 P0=date。 delay(5)。 lcden=1。 delay(5)。 lcden=0。 } /* init()程序为各部分功能初始化设置。 */ void init() { uint i。 TMOD=0x22。 //定时 0 工作方式为 2,定时器 1 工作方式为 2。 EA=1。 //开总中断。 EX0=1。 //开外部中断。 ET0=1。 ET1=1。 //开定时器 0 和定时器 1 中 断。 TH0=0。 TL0=0。 //定时器 0 装初值。 TH1=0。 TL1=0。 //定时器 1 装初值。 da_cs=0。 da_wr=0。 //开 DA 片选。 write_(0x38)。 write_(0x0c)。 write_(0x06)。 write_(0x01)。 //LCD 初始设置。 write_(0x80)。 for(i=0。 i17。 i++) { write_date(to_start[i])。 } } void main() { init()。 while(1) { if(flag==0) control()。 } } /* key_gongneng()为功能按键设置。 an_cishu==0 时表示什么也不输出。 an_cishu==1 表示输出方波。 an_cishu==2 时表示输出三角波。 an_cishu==3 时表示输出正弦波。 当 an_cishu==4 时 ,将其置 0。 */ void key_gongneng() { if(key2==0) { delay(10)。 if(key2==0) { an_cishu++。 if(an_cishu==4) { an_cishu=0。 } while(!key2)。 flag=0。 P1=0xff。 } } } /* key_sub_mul()此子程序用作频率加减。 */ uint key_sub_mul(uint movedate) { if(key1==0) { delay(5)。 //消抖。 if(key1==0) { if(movedate=500) movedate+=125。 if(movedate=50amp。 amp。 movedate500) movedate+=50。 if(movedate50) movedate+=5。 if(movedate5000) movedate=5000。 while(!key1)。 flag=0。 } } if(key0==0) { delay(5)。 //消抖。 if(key0==0) { if(movedate=50) movedate=5。 if(movedate50amp。 amp。 movedate=500) movedate=50。 if(movedate500) movedate=125。 if(movedate5) movedate=5。 while(!key0)。 flag=0。 } } return movedate。 } /* contr。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。