金湖長通測控儀表廠
閱讀:2639發(fā)布時間:2015-6-20
壓力校驗儀開發(fā)工程師依照demo編寫了如下代碼,卻打不開AD轉(zhuǎn)換(顯示的轉(zhuǎn)換結(jié)果亂七八糟,沒有任何規(guī)律),其中displaystring()是用LCD顯示字符串的函數(shù),已經(jīng)調(diào)試成功。編寫程序如下:
#Include <REG1210.H> // The header file with the MSC register definitions
#Include <stdio.h> // Standard I/O so we can use the printf function
extern signed long bipolar(void);
#define LSB 298e-9
#Ifndef XTAL // if no XTAL compiler variable defined use:
#define XTAL 11059200 // XTAL frequency 11.0592 MHz
#Endif
Main(void) {
char i,j;
float result;
PDCON = 0x75; // Turn on the A/D
ACLK = XTAL/1000000; // ACLK freq. = XTAL Freq./(ACLK +1) = 0.9216 MHz
// 0.9216 Mhz/64 = 14,400 Hz
DECIMATION = 1440; // Data Rate = 14,400/1,440 = 10 Hz
ADMUX = 0x08; // AINP = AIN0, AINN = AINCOM
ADCON0 = 0x30; // Vref On, 2.5V, Buffer Off, PGA=1
ADCON1 = 0x01; // bipolar, auto, self calibration, offset, gain
//wait for the calibration to take place
for (i=0;i<3;i++){ // dump 3 conversions
while(!(AIE&0x20)) {}
j=ADRESL;
}
j=1;
while(1){
while(!(AIE&0x20)) {} // Waiting for conversion
result=bipolar(); // Save Results
sprintf (szBuffer, "%10.8f", result*LSB);
DisplayString(0x80, szBuffer); // Display ADResult on the first line of LCD
}
}
商鋪:http://caturday.cn/st31230/
主營產(chǎn)品:壓力校驗儀,精密數(shù)字壓力計,高低壓力泵,壓力變送器,電阻電偶校驗儀,綜合信號校驗儀,自動壓力校驗系統(tǒng),自動溫度校驗系統(tǒng),差壓/壓力變送器,溫度變送器,雙金屬溫度計,壓力表,熱電阻,熱電偶,數(shù)字顯示儀,流量儀表,物位儀表,電線電纜
儀表網(wǎng) 設(shè)計制作,未經(jīng)允許翻錄必究 .? ? ?
請輸入賬號
請輸入密碼
請輸驗證碼
請輸入你感興趣的產(chǎn)品
請簡單描述您的需求
請選擇省份