• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 關於溫度計程式的問題
#4
版主
版主


查看用戶資訊
你的程式是卡在檢查DONE位元,因為轉換沒有啟動所以它就不會被清為零。轉換的方式有手動與自動模式,請參考底下的範例修改:
手動取樣、手動轉換:

ADCON1bits
.ADON=1;        //啟動AD轉換器
While(1)
{
  
ADCON1bits.SAMP=1;        //開啟取樣
  
DelayNuSec(100);         //延遲100us,取樣電容充電
  
ADCON1BITS.SAMP=0;        //取樣結束,開始轉換
  
while(!ADCON1bits.DONE);     //轉換完成了嗎 ?
  
ADCvalueADCBUF0;        //儲存AD轉換結果
}


自動取樣,手動轉換:

ADCON1bits
.ADON=1;        //啟動AD轉換器
ADCON1bits.ASAM=1;        //啟動自動取樣,SAMP位元自動設為 1
While(1)
{
  
DelayNuSec(100);         //延遲100us,取樣電容充電
  
ADCON1BITS.SAMP=0;        //取樣結束,開始轉換
  
while(!ADCON1bits.DONE);     //轉換完成了嗎 ?
  
ADCvalueADCBUF0;        //儲存AD轉換結果,SAMP位元自動設為 1
}

發表於: 2005/9/19 18:13
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於溫度計程式的問題
#3
新會員
新會員


查看用戶資訊
嗚嗚 .....
我是參考spec上的寫法
先寫 while( !BusyADC12() );
再寫 while( BusyADC12() );

所以應該不是寫2次while的問題喔....
我試著把第一個while拿掉過...
還是卡在 while( BusyADC12() ) 上

我想說是不是連訊號都沒有進來
所以不能轉換....



發表於: 2005/9/16 17:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於溫度計程式的問題
#2
初級會員
初級會員


查看用戶資訊
Hi! Shong:

您用了兩次 "while(BusyADC12()); ", 測試一次即可.

發表於: 2005/9/15 13:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於溫度計程式的問題
#1
新會員
新會員


查看用戶資訊
我在dsPICDEM1.1上使用的是 TC1047A 這個chip做溫度的sensor

然後我寫了一個副程式從AN8去讀取電壓值做A/D convert
程式碼如下:

int Read_TC1047A_Temperature(void)
{
int AD_Temp;
unsigned int Channel, Adcon1_reg, Adcon2_reg, Adcon3_reg,
PinConfig, Scanselect;
ADCON1bits.ADON = 0; // Close the A/D sampling
Channel = ADC_CH0_POS_SAMPLEA_AN8 &
ADC_CH0_NEG_SAMPLEA_NVREF;
SetChanADC12(Channel); // Configure the inputs for sample
ConfigIntADC12(ADC_INT_DISABLE); // Disable the interrupt
PinConfig = ENABLE_AN8_ANA;
Scanselect = SKIP_SCAN_AN0 & SKIP_SCAN_AN1 & SKIP_SCAN_AN2 &
SKIP_SCAN_AN3 & SKIP_SCAN_AN4 & SKIP_SCAN_AN5 &
SKIP_SCAN_AN6 & SKIP_SCAN_AN7 & SKIP_SCAN_AN9 &
SKIP_SCAN_AN10 & SKIP_SCAN_AN11 & SKIP_SCAN_AN12 &
SKIP_SCAN_AN13 & SKIP_SCAN_AN14 & SKIP_SCAN_AN15;

Adcon1_reg = ADC_MODULE_ON &
ADC_IDLE_CONTINUE &
ADC_FORMAT_INTG &
ADC_CLK_AUTO &
ADC_AUTO_SAMPLING_OFF;

Adcon2_reg = ADC_VREF_AVDD_AVSS &
ADC_SCAN_OFF &
ADC_ALT_BUF_OFF &
ADC_ALT_INPUT_OFF;

Adcon3_reg = ADC_SAMPLE_TIME_10 &
ADC_CONV_CLK_SYSTEM &
ADC_CONV_CLK_13Tcy;

OpenADC12(Adcon1_reg, Adcon2_reg, Adcon3_reg,
PinConfig, Scanselect);

ADCON1bits.SAMP = 1; // Start to sampling the A/D
while(!ADCON1bits.SAMP);
ConvertADC12(); // Start to convert the A/D
while(ADCON1bits.SAMP);
while(!BusyADC12());
while(BusyADC12()); // Waiting A/D until done
AD_Temp = ReadADC12(8); // Get 12 bits A/D result

return AD_Temp;
}

但是程式始終卡在 while(BusyADC12()); // Waiting A/D until done 這一行,

請問各位高手,問題可能出在哪邊呢??
是sensor的訊號沒有進來呢???
還是我程式的設定有問題???

謝謝.....

發表於: 2005/9/14 12:11
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------