//-----------------------函数声明--------------------------------------------------------
#include "reg51.h"
#include "intrins.h"
//-----------------------管脚声明--------------------------------------------------------
sbit CS_max532=P1^0;
sbit CLK_max532=P1^1;
sbit DI_max532=P1^2;
sbit DO_max532=P1^3;
sbit LDAC=P1^4; //异步加载DAC输入,作为同步信号
//--------------------------------------------------------------------------------------------------
// 函数名称: delay
// 入口参数: N
// 函数功能:延时子程序,实现(16*N+24)us的延时
// 系统采用11.0592MHz的时钟时,延时满足要求,其它情况需要改动
//--------------------------------------------------------------------------------------------------
void delay(unsigned int N)
{
int i;
for(i=0;i<N;i++);
}
//--------------------------------------------------------------------------------------------------
// 函数名称: SEND_1
// 函数功能: 送1位数据"1"
//--------------------------------------------------------------------------------------------------
void SEND_1(void)
{
DI_max532=1;
CLK_max532=1;
_nop_();
CLK_max532=0;
_nop_();
}
//--------------------------------------------------------------------------------------------------
// 函数名称: SEND_0
// 函数功能: 送1位数据"0"
//--------------------------------------------------------------------------------------------------
void SEND_0(void)
{
DI_max532=0;
CLK_max532=1;
_nop_();
CLK_max532=0;
_nop_();
}
//--------------------------------------------------------------------------------------------------
// 函数名称: SEND_BYTE
// 入口参数: dd,待发送的数据
// 函数功能: 送1BYTE数据
//--------------------------------------------------------------------------------------------------
void SEND_BYTE(unsigned char dd)
{
unsigned char i;
for (i=0;i<8;i++)
{
if (dd>=0x80) SEND_1();
else SEND_0();
dd=dd<<1;
}
}
//--------------------------------------------------------------------------------------------------
// 函数名称: SEND_4bit
// 入口参数: dd,待发送的数据
// 函数功能: 送1BYTE数据
//--------------------------------------------------------------------------------------------------
void SEND_4bit(unsigned char dd)
{
unsigned char i;
dd=dd<<4;
f