下面提供一个完整版本的ad7799程序,Keil C写的ADI的24位A/DAD7799使用SPI接口程序:(VRS51L3074单片机 是一颗基于8051内核集成了多种模块并可多 范围的在嵌入式设计中应用的芯片,完整的工程文件及hex下载地址:http://www.51hei.com/f/Keil_C_AD7799.rar )
ad7798,ad7799的详细中文资料请看: http://www.51hei.com/chip/4000.html
#pragma CODE DEBUG SYMBOLS OBJECTEXTEND //SRC 当与汇编混合编译时需要
#include"VRS51L3074_keil.h"
#include
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
typedef union{ //无符号字符型,整形,长整形数据联合体
uchar uc[2];
uint ui;
}UCI;
typedef union{ //无符号字符型,整形,长整形数据联合体
uchar uc[4];
uint ui[2];
ulong ul;
}UCIL;
#define DELAY5 delay() //_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_()
sbit P1_5 = P1^5; //1
sbit P1_6 = P1^6; //2
sbit P1_7 = P1^7; //3
sbit P4_5 = P4^5; //6 pin
sbit P5_0 = P5^0; //7
sbit P5_1 = P5^1; //8
sbit P5_2 = P5^2; //9
sbit P5_3 = P5^3; //10
sbit P5_4 = P5^4; //20
sbit P5_5 = P5^5; //21
sbit P5_6 = P5^6; //22
sbit P5_7 = P5^7; //23
#define AD7799_CS P4_5 //输出 6pin
#define AD7799_SCLK P5_1 //输出 8pin
#define AD7799_DOUT P5_2 //输入 9pin
#define AD7799_RDY P5_2 //输入 9pin 同上是一个引脚
#define AD7799_DIN P5_0 //输出 7pin
UCIL MainData,demoul;
ulong xdata XMainData,xdemoul;
void Ad7799_Ini();
#define DELAYS10 _nop_();_nop_();_nop_();_nop