#ifndef _AD7076_H_
#define _AD7076_H_
#include #include #include "other.h" /* sbit DB0 = P0^0 sbit DB1 = P0^1 sbit DB2 = P0^2 sbit DB3 = P0^3 sbit DB4 = P0^4 sbit DB5 = P0^5 sbit DB6 = P0^6 sbit DB7 = P0^7 sbit DB8 = P2^0 sbit DB9 = P2^1 sbit DB10 = P2^2 sbit DB11 = P2^3 sbit DB12 = P2^4 sbit DB13 = P2^5 sbit DB14 = P2^6 sbit DB15 = P2^7 */ #define sampling_0times #define sampling_2times #define sampling_4times #define sampling_8times #define sampling_16times #define sampling_32times #define sampling_times sbit OS0 = P1^0; sbit OS1 = P1^1; sbit OS2 = P1^2; sbit rage = P1^3; sbit convst = P1^4; sbit busy = P1^5; sbit rst = P1^6; sbit rd_and_cs = P1^7; sbit green_led = P3^6; sbit red_led = P3^7; struct DB_data_struct{ }; void AD7606_startconvst(void); //void AD7076_stopconvst(void); void AD7606_reset(void); void AD7606_setinputvoltage(uchar vol); void AD7606_setOS(uchar uCoS); struct DB_data_struct *AD7606_read_data(void); void AD7606_init(void); #endif Ad7606.c源码: #include "AD7076.h" /* * 名称:AD7606_startconvst() * 功能:启动转换 */ void AD7606_startconvst(void) { } /* * 名称:AD7606_reset() * 功能:复位模块 */ void AD7606_reset(void) { // } /* * 名称:AD7606_setinputvoltage() * 功能:设置测试电压范围 * rage=1为-10V~+10V * rage=0位-5V~+5V */ void AD7606_setinputvoltage(uchar vol) { } /* * 名称:AD7606_setOS() * 功能:设置过采样频率 */ void AD7606_setOS(uchar uCoS) { 无过采样 倍过采样 倍过采样 倍过采样 倍过采样 倍过采样 倍过采样 } /* * 名称:AD7606_read_data() * 功能:读取数据 * 返回值:返回一个结构体指针,该指针为指向结构体数组的首地址 */ struct DB_data_struct *AD7606_read_data(void) { // 申请一个结构体数组,用于存储8个通道的16位数据 在并行模式下,RD和CS同时置低,将使得数据更新在并行总线上 // } /* * 名称:AD7606_init() * 功能:初始化AD7606模块 初始化为无过采样,即采样频率为200ksps,采样电压范围为-5V~+5V */ void AD7606_init(void) { } Other.h源码: #ifndef _OTHER_H_ #define _OTHER_H_ #define uint unsigned int #define uchar unsigned char void delay_ms(uint timer); void delay_us(uchar timer); uchar binary_to_decimal(uchar binary); #endif Other.c源码: #include #include "other.h" void delay_ms(uint timer) 毫秒延时程序 { } void delay_us(uchar timer) 微妙延时程序 { } /* * 名称:binary_to_decimal() * 功能:二进制数据转换为十进制数据 */ /* uchar binary_to_decimal(uchar binary) { } */ Main.c源码: /* * This is a program for testing AD7606 * The line connecting AD7606 with STCC52RC is: * STCC52RC | AD7606 * * P2 | DB[8:15] * OS0 | P1^0 * OS1 | P1^1 * OS2 | P1^2 * rage | P1^3 * convst | P1^4 * busy | P1^5 * rst | P1^6 * rd_and_cs | P1^7 * green_led | P3^6 * red_led | P3^7 * * green_led | P3_6 * red_led | P3_7 * Author : jinming chen * Compang : Hongwei in dongguan * Date : Sep 1 */ #include #include #include #include "AD7076.h" #include "other.h" //uchar introduce1[] = "This is a program "; //uchar introduce2[] = "for testing AD7606\\r\\n"; uchar sampling[] = "The sampling data is : "; uchar newline[] = "\\r\\n"; uchar space[] = " "; uchar *DB_str[16] = {"0 /* uchar *data_to_string(uchar Data) { } */ void serial_init(void) { 为模式一,8位数据,允许接收 定时器1为模式二,8位自动重装 波特率为19200,晶振频率为11.0592MHz } /* //向串口发送一个函数 void serial_send_byte(uchar ch) { } */ //向串口发送一串字符数据 void serial_send_string(uchar *p) { } int main() { // // // 当busy为低电平时,数据转换完毕,此时可以读取数据 // // DB_data_cmp[3]>0x7D) 电压检测为预定值,则绿灯亮 电压检测为非预定值,则红灯亮 }