#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
//NJU39610端口定义
#define DA_PORT P2
sbit DA_WR=P3^6; //NJU39610数据写入端;
sbit DA_A1=P3^5;
sbit DA_A0=P3^4;
sbit DA_CS=P3^3;
//全局变量定义
unsigned char data xf_step;
unsigned char xdata xf32_sin[30]={0,12,24,31,43,54,65,76,85,
94,102,109,115,120,124,126,
124,120,115,109,102,94,
85,76,65,54,43,31,24,12
};
unsigned char xdata xf32_cos[30]={126,124,120,115,109,102,94,
85,76,65,54,43,31,24,12,0,
12,24,31,43,54,65,76,85,
94,102,109,115,120,124,
};
void del(uint v)
{
while(v!=0)v--;
}
void main(void)
{
DA_CS=1;
xf_step=0;
while(1)
{
DA_A1=0;
DA_A0=0; //选DA通道0;
DA_CS=0;
DA_PORT=xf32_sin[xf_step]|0x80;
DA_WR=0; //DA数据写入;
del(10);
DA_WR=1;
DA_CS=1;
DA_A1=0;
DA_A0=1;
DA_CS=0;
DA_PORT=xf32_cos[xf_step]|0x80;
DA_WR=0;
del(10);
DA_WR=1;
del(10);
DA_CS=1;
del(400);
xf_step++;
if(xf_step>=64) xf_step=0;
}
} |