📄 boxing.c
字号:
//包含所需头文件
#include <ioM16v.h>
#include <macros.h>
#include "delay.h"
/*------宏定义------*/
#define uchar unsigned char
#define uint unsigned int
#define BYTE unsigned char
#define DAC_DATA PORTB
#define DAC_DDR DDRB
extern uchar dec_to_bin(uchar data);
const BYTE Sin[]={0x00,0x02,0x04,0x06,0x08,0x0a,0x0c,
0x0e,0x10,0x12,0x14,0x16,0x18,0x1a,
0x1c,0x1e,0x20,0x22,0x24,0x26,0x28,
0x2a,0x2c,0x2e,0x30,0x32,0x34,0x36,
0x38,0x3a,0x3c,0x3d,0x3f,0x41,0x43,
0x45,0x47,0x49,0x4b,0x4d,0x4f,0x51,
0x53,0x54,0x56,0x58,0x5a,0x5c,0x5e,
0x60,0x62,0x63,0x65,0x67,0x69,0x6b,
0x6d,0x6e,0x70,0x72,0x74,0x76,0x77,
0x79,0x7b,0x7d,0x7e,0x80,0x82,0x84,
0x85,0x87,0x89,0x8a,0x8c,0x8e,0x8f,
0x91,0x93,0x94,0x96,0x98,0x99,0x9b,
0x9c,0x9e,0x9f,0xa1,0xa3,0xa4,0xa6,
0xa7,0xa9,0xaa,0xac,0xad,0xaf,0xb0,
0xb1,0xb3,0xb4,0xb6,0xb7,0xb9,0xba,
0xbb,0xbd,0xbe,0xbf,0xc1,0xc2,0xc3,
0xc4,0xc6,0xc7,0xc8,0xc9,0xcb,0xcc,
0xcd,0xce,0xcf,0xd1,0xd2,0xd3,0xd4,
0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,
0xdd,0xde,0xde,0xdf,0xe0,0xe1,0xe2,
0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe8,
0xe9,0xea,0xeb,0xec,0xec,0xed,0xee,
0xef,0xef,0xf0,0xf1,0xf1,0xf2,0xf3,
0xf3,0xf4,0xf4,0xf5,0xf5,0xf6,0xf6,
0xf7,0xf7,0xf8,0xf8,0xf9,0xf9,0xfa,
0xfa,0xfa,0xfb,0xfb,0xfc,0xfc,0xfc,
0xfc,0xfd,0xfd,0xfd,0xfd,0xfe,0xfe,
0xfe,0xfe,0xfe,0xfe,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff};
void saw(void)//锯齿波发生函数
{
uchar i,data;
for(i=0;i<255;i++)
{
//data=dec_to_bin(i);
DAC_DATA=i;
}
}
void square(void)//方波发生函数
{
DAC_DATA=0x00;
delay_nms(5000);
DAC_DATA=0xff;
delay_nms(5000);
}
void SIN(void)
{
uchar i=0x00;
DAC_DATA=Sin[i];
i++;
if(i==200)
{
i=0x00;
}
delay_nms(5000);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -