Re: PIC18F2553 AD參數設定的問題
|
||||
---|---|---|---|---|
新會員
|
至於delay時間,我再試試,謝謝您的意見。
發表於: 2009/8/4 11:02
|
|||
|
Re: PIC18F2553 AD參數設定的問題
|
||||
---|---|---|---|---|
資深會員
|
ADCON0=0x01; // AN0
Delay10KTCYx(50); // 這裡delay較好,時間則請再自行調整 ADCON0bits.GO=1; while(ADCON0bits.GO); AD[0]=(((unsigned int)ADRESH)<<8)|(ADRESL);
發表於: 2009/8/2 21:31
|
|||
|
PIC18F2553 AD參數設定的問題
|
||||
---|---|---|---|---|
新會員
|
在讀取AD暫存器的值時,需要預先delay 很長的一段時間,
否則AD讀到的值都是0或4087。 clock設定如下: OSC1/OSC2的Clock = 16MHz CPU CLOCK: Fosc = 96MHz/2 = 48MHz 程式如下: ADCON1=0b00001101; // 2 AD inputs ADCON2=0b10010110; // 4TAD, FOSC/64,此設定恰當嗎? while(1) { Delay10KTCYx(50); // delay 10k*50*Tcy ADCON0=0x01; // AN0 ADCON0bits.GO=1; while(ADCON0bits.GO); AD[0]=(((unsigned int)ADRESH)<<8)|(ADRESL); Delay10KTCYx(50); // delay 10k*50*Tcy ADCON0=0x05; // AN1 ADCON0bits.GO=1; while(ADCON0bits.GO); AD[1]=(((unsigned int)ADRESH)<<8)|(ADRESL); } 1. 當AD從AN0轉為AN1 (即設定ADCON0=0x05) 需等候多久的時間? (此處需等候10*50*Tcy的時間) 2. 如何計算Tcy = 1/Fosc = 1/48MHz (是否正確?) 3. 1Tcy = Nop(); 對嗎? 謝謝
發表於: 2009/8/1 15:57
|
|||
|