欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機實現簡易波形發生器
[打印本頁]
作者:
陸小鳳111
時間:
2018-6-20 19:17
標題:
單片機實現簡易波形發生器
單片機實現簡易波形發生器
0.png
(21.81 KB, 下載次數: 40)
下載附件
2018-7-1 01:35 上傳
單片機源程序如下:
#include<reg51.h>
#include<absacc.h>
#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] = { 0x7f,0x82,0x85,0x88,0x8b,0x8f,0x92,0x95,0x98,0x9b,0x9e,0xa1,0xa4,0xa7,0xaa,
0xad,0xb0,0xb3,0xb6,0xb8,0xbb,0xbe,0xc1,0xc3,0xc6,0xc8,0xcb,0xcd,0xd0,
0xd2,0xd5,0xd7,0xd9,0xdb,0xdd,0xe0,0xe2,0xe4,0xe5,0xe7,0xe9,0xeb,0xec,
0xee,0xef,0xf1,0xf2,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfb,0xfc,0xfd,0xfd,
0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfd,0xfd,0xfc,0xfb,0xfb,
0xfa,0xf9,0xf8,0xf7,0xf6,0xf5,0xf4,0xf2,0xf1,0xef,0xee,0xec,0xeb,0xe9,0xe7,
0xe5,0xe4,0xe2,0xe0,0xdd,0xdb,0xd9,0xd7,0xd5,0xd2,0xd0,0xcd,0xcb,0xc8,0xc6,0xc3,
0xc1,0xbe,0xbb,0xb8,0xb6,0xb3,0xb0,0xad,0xaa,0xa7,0xa4,0xa1,0x9e,0x9b,0x98,0x95,
0x92,0x8f,0x8b,0x88,0x85,0x82,0x7f,0x7c,0x79,0x76,0x73,0x6f,0x6c,0x69,0x66,0x63,
0x60,0x5d,0x5a,0x57,0x54,0x51,0x4e,0x4b,0x48,0x46,0x43,0x40,0x3d,0x3b,0x38,0x36,
0x33,0x31,0x2e,0x2c,0x29,0x27,0x25,0x23,0x21,0x1e,0x1c,0x1a,0x19,0x17,0x15,0x13,
0x12,0x10,0x0f,0x0d,0x0c,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x03,0x02,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x05,
0x06,0x07,0x08,0x09,0x0a,0x0c,0x0d,0x0f,0x10,0x12,0x13,0x15,0x17,0x19,0x1a,0x1c,
0x1e,0x21,0x23,0x25,0x27,0x29,0x2c,0x2e,0x31,0x33,0x36,0x38,0x3b,0x3d,0x40,0x43,0x46,
0x48,0x4b,0x4e,0x51,0x54,0x57,0x5a,0x5d,0x60,0x63,0x66,0x69,0x6c,0x6f,0x73,0x76,
0x79,0x7c
};
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 == 0x04)
{
DAC0832 = sin[num];
if(num > 255)
{
num = 0;
}
}
num++;
TR0 =1;
TH0 = th;
TL0 = tl;
}
void main()
{
TMOD = 0x01;
TH0 = 0xff;
TL0 = 0xe0;
ET0= 1;
TR0 = 1;
TF0= 1;
PX0 =1;
EX0 =1;
EA =1;
while(1)
{
;
}
}
復制代碼
所有資料51hei提供下載:
簡易波形發生器.rar
(24.19 KB, 下載次數: 32)
2018-6-20 19:16 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1