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

资源简介

题目六、简易波形发生器(基于单片机的设计——实验箱或Proteus仿真) 设计要求: 通过开关或按钮有选择地输出四种波形——正弦波、三角波、方波和梯形波 四种波形的频率可通过输入电位器在一定范围内调节

资源截图

代码片段和文件信息

#include
#include
#define DAC0832 XBYTE[0xfeff]
#define uchar unsigned char

uchar  num = 0;
uchar  tl = 0xe0;
uchar  th = 0xff;
uchar  interrupt_flagl = 0x00;

uchar code sin[256] = {  0x7f0x820x850x880x8b0x8f0x920x950x980x9b0x9e0xa10xa40xa70xaa
 0xad0xb00xb30xb60xb80xbb0xbe0xc10xc30xc60xc80xcb0xcd0xd0
 0xd20xd50xd70xd90xdb0xdd0xe00xe20xe40xe50xe70xe90xeb0xec
 0xee0xef0xf10xf20xf40xf50xf60xf70xf80xf90xfa0xfb0xfb0xfc0xfd0xfd
 0xfe0xfe0xfe0xfe0xfe0xfe0xfe0xfe0xfe0xfe0xfe0xfd0xfd0xfc0xfb0xfb
 0xfa0xf90xf80xf70xf60xf50xf40xf20xf10xef0xee0xec0xeb0xe90xe7
 0xe50xe40xe20xe00xdd0xdb0xd90xd70xd50xd20xd00xcd0xcb0xc80xc60xc3
 0xc10xbe0xbb0xb80xb60xb30xb00xad0xaa0xa70xa40xa10x9e0x9b0x980x95
 0x920x8f0x8b0x880x850x820x7f0x7c0x790x760x730x6f0x6c0x690x660x63
 0x600x5d0x5a0x570x540x510x4e0x4b0x480x460x430x400x3d0x3b0x380x36
 0x330x310x2e0x2c0x290x270x250x230x210x1e0x1c0x1a0x190x170x150x13
 0x120x100x0f0x0d0x0c0x0a0x090x080x070x060x050x040x030x030x020x010x010x000x00
 0x000x000x000x000x000x000x000x000x000x010x010x020x030x030x040x05
 0x060x070x080x090x0a0x0c0x0d0x0f0x100x120x130x150x170x190x1a0x1c
 0x1e0x210x230x250x270x290x2c0x2e0x310x330x360x380x3b0x3d0x400x430x46
 0x480x4b0x4e0x510x540x570x5a0x5d0x600x630x660x690x6c0x6f0x730x76
 0x790x7c
 
};

void case1(void)
{
tl -= 0x05;

if(tl <= 0xb0)
{
tl = 0xe0;
}
}
 
void case2(void)
{
tl += 0x05;

if(tl >= 0xff)
{
tl = 0xe0;
}
}

void case3(void)
{
   interrupt_flagl= interrupt_flagl + 0x01;

if(interrupt_flagl > 0x04)
{
interrupt_flagl = 0x01;
}
}

int0_key() interrupt 0
{
if(P2 == 0xdf)
{
case1();
}
else if(P2 == 0xbf)
{
case2();
}
else if(P2 == 0x7f)
{
case3();
}
}

timer0_int(void) interrupt 1
{
TR0 = 0;
if(interrupt_flagl == 0x01)
{
if(num < 64)
{
DAC0832 = 0x00;
}
else if((num >= 64) && (num <= 128))
{
DAC0832 = 0x85;
}
else if((num > 128) &&(num <= 255))
{
DAC0832 = 0;
}
else if(num >255)
{
num =0;
}
}
else if(interrupt_flagl == 0x02)
{
  if( num <= 85)
  {
    DAC0832  = num;
  
  }
  else if(num > 85 && num < 170)
  {
   DAC0832 = 85;

  }
  else if((num >= 170) &&(num < 255 ))
  {
 DAC0832 = 255 - num;
  
  }
  else if(num >= 255)
  {
   num = 0;
  }
}

else if(interrupt_flagl == 0x03)
{
   if( num <= 0x128)
   {
    DAC0832 = num;
   }
   else if((num >= 0x128) && (num < 0x255))
   {
DAC0832 = 255 - num;
   }
   else if(num >= 255)
   {
num = 0;
   }
}

else if(interrupt_flagl == 0x0

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

     文件       6363  2012-11-11 17:47  简易波形发生器\wave2

     文件     119132  2012-11-15 07:54  简易波形发生器\wave2.DSN

     文件        792  2012-11-15 08:00  简易波形发生器\wave2.PWI

     文件       2732  2012-11-05 22:09  简易波形发生器\wavesource2.hex

     文件       3289  2012-11-11 17:47  简易波形发生器\程序.c

     目录          0  2012-11-15 08:00  简易波形发生器

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

               132308                    6


评论

共有 条评论