金湖長(zhǎng)通測(cè)控儀表廠
閱讀:2625發(fā)布時(shí)間:2015-6-20
壓力校驗(yàn)儀開(kāi)發(fā)工程師依照demo編寫(xiě)了如下代碼,卻打不開(kāi)AD轉(zhuǎn)換(顯示的轉(zhuǎn)換結(jié)果亂七八糟,沒(méi)有任何規(guī)律),其中displaystring()是用LCD顯示字符串的函數(shù),已經(jīng)調(diào)試成功。編寫(xiě)程序如下:
#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/
主營(yíng)產(chǎn)品:壓力校驗(yàn)儀,精密數(shù)字壓力計(jì),高低壓力泵,壓力變送器,電阻電偶校驗(yàn)儀,綜合信號(hào)校驗(yàn)儀,自動(dòng)壓力校驗(yàn)系統(tǒng),自動(dòng)溫度校驗(yàn)系統(tǒng),差壓/壓力變送器,溫度變送器,雙金屬溫度計(jì),壓力表,熱電阻,熱電偶,數(shù)字顯示儀,流量?jī)x表,物位儀表,電線電纜
儀表網(wǎng) 設(shè)計(jì)制作,未經(jīng)允許翻錄必究 .? ? ?
請(qǐng)輸入賬號(hào)
請(qǐng)輸入密碼
請(qǐng)輸驗(yàn)證碼
請(qǐng)輸入你感興趣的產(chǎn)品
請(qǐng)簡(jiǎn)單描述您的需求
請(qǐng)選擇省份