欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
ad7705驅動子程序 項目上實踐過得
[打印本頁]
作者:
電子極客迷
時間:
2017-12-3 12:52
標題:
ad7705驅動子程序 項目上實踐過得
#include "AD7705.h"
/************************************************
功能:延時
參數:循環次數
返回:無
************************************************/
void adc_delay(unsigned char NUM)
{
for(;NUM>0;NUM--);
}
/************************************************
功能:寫入AD芯片一個字節
參數:要寫入的命令或參數
返回:無
************************************************/
void write_adc_byte(unsigned char chr)
{
unsigned char i;
for(i=0;i<8;i++)
{
ADC_CLK= 0;
chr=chr<<1;
ADC_DI= CY;
ADC_CLK= 1;
}
ADC_CLK = 1;
}
/************************************************
功能:從AD芯片讀取一個字(16位)
參數:無
返回:讀取的字(16位)
************************************************/
unsigned int read_adc_word()
{
unsigned char i;
unsigned int coder = 0;
for(i=0;i<16;i++)
{
ADC_CLK = 0;
coder = coder<<1;
if(ADC_DO)coder+=1;
ADC_CLK = 1;
}
ADC_CLK = 1;
return(coder);
}
/************************************************
功能:AD芯片復位
參數:無
返回:無
************************************************/
void adc_rest()
{
unsigned char i,j;
ADC_DI = 1;
ADC_CLK = 1;
ADC1_CS = 1;
// ADC2_CS = 1;
ADC_RESET = 0;
for(i=300;i>0;i--)
for(j=300;j>0;j--);
ADC_RESET = 1;
}
/************************************************
功能:AD芯片初始化
參數:calmode 工作模式選擇(如:ADC_SELF ……)
gainsetting 輸入增益選擇(如:ADC_GAIN_128 ……)
operation 單極性/雙極性(如:ADC_BIPOLAR ……)
rate 輸出更新率(如:ADC_50 ……)
返回:無
************************************************/
void adc1_init(unsigned char calmode, unsigned char gainsetting, unsigned char operation, unsigned char rate)
{
ADC1_CS = 0;
write_adc_byte(0xFF);
write_adc_byte(0xFF);
write_adc_byte(0xFF);
write_adc_byte(0xFF);
ADC1_CS = 1;
adc_delay(100);
ADC1_CS = 0;
write_adc_byte( 0x20 );//
ADC1_CS = 1;
adc_delay(100);
ADC1_CS = 0;
write_adc_byte( rate );//
ADC1_CS = 1;
adc_delay(100);
ADC1_CS = 0;
write_adc_byte( 0x10 );//
ADC1_CS = 1;
adc_delay(100);
ADC1_CS = 0;
write_adc_byte( calmode|gainsetting|operation);//
ADC1_CS = 1;
adc_delay(100);
}
/************************************************
功能:讀取AD轉換碼
參數:通道號 如:1、2
返回:讀取的AD轉換結果(如果等于零表示正忙)
************************************************/
unsigned int adc1_read_value(unsigned char ch)
{
unsigned int value;
if(!ADC1_DRDY)
{
ADC1_CS = 0;
if(ch == 1)
write_adc_byte(0x38);//
else if(ch == 2)
write_adc_byte(0x39);//
else {ADC1_CS = 1;return 0;}
ADC1_CS = 1;
adc_delay(1);
ADC1_CS = 0;
value = read_adc_word();
ADC1_CS = 1;
return value;
}
else
{
return 0;
}
}
作者:
stephen126
時間:
2019-8-4 10:43
你好,能發一下頭文件嗎,我想看看初始化是怎么定義的
功能:AD芯片初始化
參數:calmode 工作模式選擇(如:ADC_SELF ……)
gainsetting 輸入增益選擇(如:ADC_GAIN_128 ……)
operation 單極性/雙極性(如:ADC_BIPOLAR ……)
rate 輸出更新率(如:ADC_50 ……)
返回:無
作者:
stephen126
時間:
2019-8-4 15:43
感謝樓主,調出來了
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1