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

論壇索引


Board index » All Posts (shong)




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


嗚嗚 .....
我是參考spec上的寫法
先寫 while( !BusyADC12() );
再寫 while( BusyADC12() );

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

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



發表於: 2005/9/16 17:19
頂部


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


我在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
頂部


請問要如何確定UART有接收到資料呢??
#3
新會員
新會員


我用的方法是在Rx的interrupt裡寫一段程式如下:
void __attribute__((__interrupt__)) _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0; // clear interrupt flag
TxIndex=0;
while (Txdata[TxIndex]) // do until NULL char is reached
{
WriteUART2((int)Txdata[TxIndex++]); //Call C peripheral library to transmit a character
while(BusyUART2()); // wait if transmitter is busy
}
}

就是當UART1接收到資料時,就用UART2在傳送出去另外一筆資料,
UART2傳送的程式也是驗證沒問題的,
但驗證結果卻是失敗的,
請問這表示我沒有收到資料嗎??
還是我的寫法不可行呢??

請高手們給個提示吧,
謝謝.....^^


發表於: 2005/8/3 22:20
頂部






:::

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... ]

教育訓練中心

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