• 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: 發現ADC.h的內容有誤
#3
高級會員
高級會員


查看用戶資訊
#include <p18cxxx.h>
#include <adc.h>

#elif defined (ADC_V4) || defined (ADC_V5) || defined (ADC_V6)
void OpenADC ( unsigned char config,
unsigned char config2,
unsigned char portconfig)
{
ADCON0 = 0;
ADCON2 = 0;

ADCON0 = (config2 >>1) & 0b00111100; // GET CHANNELS
ADCON1 = portconfig | // GET CONFIG
((config2 << 4) & 0b00110000); // GET Vref
ADCON2 = (config & 0b10000000) | // RESULT
((config >> 4) & 0b00000111) | // CONV CLK
((config << 2) & 0b00111000); // ACQ TIME

if( config2 & 0b10000000 ) // ADC INT.
{
PIR1bits.ADIF = 0;
PIE1bits.ADIE = 1;
INTCONbits.PEIE = 1;
}
ADCON0bits.ADON = 1;
}
------------------------------------------------------------
如上為原始檔
我已經測試過
發現錯誤
所以才上來請教
Microchip公司會發生這種錯誤嗎?

發表於: 2009/12/17 9:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 發現ADC.h的內容有誤
#2
資深會員
資深會員


查看用戶資訊
參照:

shiue 寫道:

例如: #define ADC_1ANA 0b11111110 應該是0b00001110



LSB 4 bit 是沒錯 , 至於 4 , 5 bit ( VCFG0 & VCFG1 ) 可能還須要與其他參數 作運算 ( 例 : .AND. ) 才會得到正確參數 ...

要追蹤整個 HEAD 檔 LOADING 太重 , 我想較簡單的方式是寫個小程式來驗證結果是否正確 應該是比較可行的方法

Attach file:



jpg  (0.00 KB)


發表於: 2009/12/17 4:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


發現ADC.h的內容有誤
#1
高級會員
高級會員


查看用戶資訊
我是用PIC18F4520
MPLAB-C18-Std-Eval-v3_33
ADC.h內的OpenADC ()


以下參數有誤
#elif defined (ADC_V2) || defined (ADC_V5) || defined (ADC_V6) || defined (ADC_V12)

#ifndef USE_OR_MASKS
//***************A/D Port Configuration Control *******************************
#define ADC_0ANA 0b11111111 // All channels are digital
#define ADC_1ANA 0b11111110 // analog: AN0 and remaining channels are digital
#define ADC_2ANA 0b11111101 // analog: AN0->1 and remaining channels are digital
#define ADC_3ANA 0b11111100 // analog: AN0->2 and remaining channels are digital
#define ADC_4ANA 0b11111011 // analog: AN0->3 and remaining channels are digital
#define ADC_5ANA 0b11111010 // analog: AN0->4 and remaining channels are digital
#define ADC_6ANA 0b11111001 // analog: AN0->5 and remaining channels are digital
#define ADC_7ANA 0b11111000 // analog: AN0->6 and remaining channels are digital
#define ADC_8ANA 0b11110111 // analog: AN0->7 and remaining channels are digital
#define ADC_9ANA 0b11110110 // analog: AN0->8 and remaining channels are digital
#define ADC_10ANA 0b11110101 // analog: AN0->9 and remaining channels are digital
#define ADC_11ANA 0b11110100 // analog: AN0->10 and remaining channels are digital
#ifndef ADC_V12
#define ADC_12ANA 0b11110011 // analog: AN0->11 and remaining channels are digital
#define ADC_13ANA 0b11110010 // analog: AN0->12 and remaining channels are digital
#define ADC_14ANA 0b11110001 // analog: AN0->13 and remaining channels are digital
#define ADC_15ANA 0b11110000 // All channels are analog
#endif

例如: #define ADC_1ANA 0b11111110 應該是0b00001110






#if defined ( ADC_V2 ) || defined (ADC_V3) || defined (ADC_V4 ) ||\
defined ( ADC_V5 ) || defined ( ADC_V6 ) || defined (ADC_V7) ||\
defined (ADC_V7_1) || defined ( ADC_V8 ) || defined (ADC_V9) ||\
defined (ADC_V11) || defined (ADC_V12)

#define ADC_VREFPLUS_VDD ADC_REF_VDD_VREFMINUS // VREF+ = AVDD
#define ADC_VREFPLUS_EXT ADC_REF_VREFPLUS_VREFMINUS // VREF+ = external..
#define ADC_VREFMINUS_VSS ADC_REF_VREFPLUS_VSS // VREF- = AVSS
#define ADC_VREFMINUS_EXT ADC_REF_VREFPLUS_VREFMINUS // VREF- = external


其中ADC_VREFPLUS_EXT和ADC_VREFMINUS_EXT的定義一樣?

----------------------------------------------------------------------

如果是我看錯, 請指教! 謝謝!

發表於: 2009/12/16 14:07
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... ]

教育訓練中心

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