您当前的位置:五五电子网电子知识单片机-工控设备综合-其它串行接口电压输出型DA转换器的控制 正文
串行接口电压输出型DA转换器的控制

串行接口电压输出型DA转换器的控制

点击数:7503 次   录入时间:03-04 12:03:00   整理:http://www.55dianzi.com   综合-其它

//-----------------------函数声明--------------------------------------------------------
#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

本文关键字:转换器  接口  综合-其它单片机-工控设备 - 综合-其它