资源简介

预览网址:https://www.cnblogs.com/luxiaoguogege/p/9848078.html

资源截图

代码片段和文件信息

#include 
#include 
 
#define DA0832 P2
#define DATA 57          //定时器延时 
 
#define uchar unsigned char
#define uint unsigned int
 
sbit S1 = P1^0;
sbit S2 = P1^1;
//00锯齿波;01方波;10三角波;11正弦波
 
uchar code sin_tab[] =        //正弦波输出表
{
     0x800x830x860x890x8D0x900x930x960x990x9C0x9F0xA20xA50xA80xAB0xAE
     0xB10xB40xB70xBA0xBC0xBF0xC20xC50xC70xCA0xCC0xCF0xD10xD40xD60xD8
     0xDA0xDD0xDF0xE10xE30xE50xE70xE90xEA0xEC0xEE0xEF0xF10xF20xF40xF5
     0xF60xF70xF80xF90xFA0xFB0xFC0xFD0xFD0xFE0xFF0xFF0xFF0xFF0xFF0xFF
     0xFF0xFF0xFF0xFF0xFF0xFF0xFE0xFD0xFD0xFC0xFB0xFA0xF90xF80xF70xF6
     0xF50xF40xF20xF10xEF0xEE0xEC0xEA0xE90xE70xE50xE30xE10xDF0xDD0xDA
     0xD80xD60xD40xD10xCF0xCC0xCA0xC70xC50xC20xBF0xBC0xBA0xB70xB40xB1
     0xAE0xAB0xA80xA50xA20x9F0x9C0x990x960x930x900x8D0x890x860x830x80
     0x800x7C0x790x760x720x6F0x6C0x690x660x630x600x5D0x5A0x570x550x51
     0x4E0x4C0x480x450x430x400x3D0x3A0x380x350x330x300x2E0x2B0x290x27
     0x250x220x200x1E0x1C0x1A0x180x160x150x130x110x100x0E0x0D0x0B0x0A
     0x090x080x070x060x050x040x030x020x020x010x000x000x000x000x000x00
     0x000x000x000x000x000x000x010x020x020x030x040x050x060x070x080x09
     0x0A0x0B0x0D0x0E0x100x110x130x150x160x180x1A0x1C0x1E0x200x220x25
     0x270x290x2B0x2E0x300x330x350x380x3A0x3D0x400x430x450x480x4C0x4E
     0x510x550x570x5A0x5D0x600x630x660x690x6C0x6F0x720x760x790x7C0x7E
};
 
void stair(void);//锯齿波 
void square(void);//方波 
void trian();//三角波 
void sin();//正弦波 
void scan();//扫描函数 
void Timer0Init(void); //75微秒@11.0592MHz
uchar flag = 0;


void main()
{
P2 = 0xff;
Timer0Init();
while(1)
{
//逐个测试 
//stair(); /*锯齿波*/
// square();  /*方波*/
  // trian(); /*三角波*/
// sin();  /*正弦波*/
    scan();
}
}
 
void Timer0Init(void) //75微秒@11.0592MHz
{

TMOD = 0x01; //设置定时器模式
TH0  = (65536 - DATA) / 256; //设置定时初值
TL0  = (65536 - DATA) % 256; //设置定时初值
ET0  = 1;     //TF0标志
TR0  = 1;     //定时器0开始计时
EA   = 1;
}
void timer0_ISR(void) interrupt 1
{
TH0  = (65536 - DATA) / 256; //设置定时初值
TL0  = (65536 - DATA) % 256; //设置定时初值
TR0  = 0;
flag = 1;
}


void scan()
{
if((0 == S1) &&(0 == S2))
    stair();
else if((1 == S1) && (0 == S2))
square();
else if((0 == S1) && (1 == S2))
trian();
else
sin();

}


void stair(void)
{
uchar i;
for(i = 0 ;i < 255; i++)
{
  DA0832 = i;
TR0  = 1;
while(flag == 0);
flag = 0;
}
 
}
 
void square(void)
{
int i;
DA0832 = 0xff;
for(i = 0;i < 125;i++)
{
TR0  = 1;
while(flag == 0);
flag = 0;
}
DA0832 = 0x00;
for(i = 0;i < 125;i++)
{
TR0  = 1;
while(flag == 0);
flag = 0;
}
}
 
void trian(void)
{
uchar i;
for(i = 0 ;i < 1

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-25 10:12  DAC0832输出锯齿波\
     文件       16997  2018-10-24 20:55  DAC0832输出锯齿波\Backup Of DAC0832.pdsbak
     文件       14656  2018-10-24 22:30  DAC0832输出锯齿波\DAC0832.PDF
     文件         792  2012-05-11 14:07  DAC0832输出锯齿波\DAC0832.PWI
     文件       17525  2018-10-25 10:12  DAC0832输出锯齿波\DAC0832.pdsprj
     文件        2357  2018-10-25 10:12  DAC0832输出锯齿波\DAC0832.pdsprj.4RWCYNPKUR2JXTX.Administrator.workspace
     文件        6104  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波
     文件        6761  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.LST
     文件        8584  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.M51
     文件        6761  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.OBJ
     文件        1079  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.build_log.htm
     文件        3438  2018-10-24 22:26  DAC0832输出锯齿波\DAC0832输出锯齿波.c
     文件        1841  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.hex
     文件          51  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.lnp
     文件         668  2012-05-11 14:07  DAC0832输出锯齿波\DAC0832输出锯齿波.plg
     文件      137799  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.uvgui.Administrator
     文件        6250  2018-10-24 20:42  DAC0832输出锯齿波\DAC0832输出锯齿波.uvopt
     文件       13834  2018-10-25 10:11  DAC0832输出锯齿波\DAC0832输出锯齿波.uvproj
     文件        1412  2012-05-11 14:03  DAC0832输出锯齿波\DAC0832输出锯齿波_Opt.Bak
     文件        2192  2012-04-19 18:21  DAC0832输出锯齿波\DAC0832输出锯齿波_Uv2.Bak
     文件          19  2018-10-24 22:27  DAC0832输出锯齿波\ExtDll.iex
     文件       83832  2012-04-24 12:21  DAC0832输出锯齿波\Last Loaded DAC0832.DBK
     文件       17457  2018-10-24 22:30  DAC0832输出锯齿波\Last Loaded DAC0832.pdsbak

评论

共有 条评论