资源简介
51单片机通过AD7708完成电压采集 可采集单端电压,差分电压
代码片段和文件信息
#include
#include
#include
sbit CS=P2^0;
sbit Dout=P2^1;
sbit Din=P2^2;
sbit RDY=P2^3;
sbit SCK=P2^4;
sbit RESET=P2^6;
void spi_sendbyte(unsigned char ch);
unsigned char spi_readbyte(void);
unsigned int spi_readchar(void);
void AD7708_int(unsigned char chal);
void delay(unsigned int x);
void main()
{
unsigned int ad7708value;
// unsigned char i;
unsigned char statvalue;
float advolt;
SCON=0x57;
TMOD=0x21;
TH1=0xFD;
TL1=0xFD;
EA=1;
TR1=1;
CS=0;
RESET=1;
delay(500);
RESET=0;
delay(500);
RESET=1;
spi_sendbyte(0x01); //配置MOD寄存器
spi_sendbyte(0x53);
delay(100);
AD7708_int(8);
CS=1;
while(1)
{
// for(i=0;i<2;i++)
// {
CS=0;
AD7708_int(8);
- 上一篇:矩阵论习题答案方保镕编著
- 下一篇:Nginx实战配置
评论
共有 条评论