• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: C30 adc.h 10bit 函數庫
#2
管理員
管理員


查看用戶資訊
你好,

因為在 dsPIC33FJ & PIC24H 裡面的 ADC 為 10/12 bit configurable. 所以函數就只有一個共用啦. 在安裝完 MPLAB C30 之後 , 在桌面上會有一個 HTML 檔. 叫做 MPLAB C30 Documentation.html. 這個檔案就包括了所有 Peripheral library 的說明.

以下為 dsPIC33FJ 的 Peripheral Library 裡有關 OpenADCx() 的說明及使用範例, 其中就有一參數可以是 "ADC_AD12B_12BIT" 或 "ADC_AD12B_10BIT" 用來選要用的 AD 解析度.

你只要 include <adc.h> 就好了 :)

3.6         OpenADCx
 

Function Prototype
 void OpenADC1
(unsigned int config1,

   
unsigned int config2,

   
unsigned int config3,

   
unsigned int config4,

   
unsigned int configport_l,

   
unsigned int configport_h,

   
unsigned int configscan_h,

   
unsigned int configscan_l)

void OpenADC2(unsigned int config1,

   
unsigned int config2,

   
unsigned int config3,

   
unsigned int config4,

   
unsigned int configport_l,

   
unsigned int configport_h,

   
unsigned int configscan_h,

   
unsigned int configscan_l)
 
Include
 
adc.h
 
Description
 This 
function configures the ADC.
 
Arguments
 config1 
This contains the parameters to be configured in the ADxCON1 register as defined below:

Module On/Off

   ADC_MODULE_ON

   ADC_MODULE_OFF

Idle mode operation

   ADC_IDLE_CONTINUE

   ADC_IDLE_STOP

DMA Buffers Write Mode

   ADC_ADDMABM_ORDER

   ADC_ADDMABM_SCATTR

ADC Module Operation Mode

   ADC_AD12B_12BIT

   ADC_AD12B_10BIT

Result output format

   ADC_FORMAT_SIGN_FRACT

   ADC_FORMAT_FRACT

   ADC_FORMAT_SIGN_INT

   ADC_FORMAT_INTG

Conversion trigger source

   ADC_CLK_AUTO

   ADC_CLK_MPWM

   ADC_CLK_TMR

   ADC_CLK_INT0

   ADC_CLK_MANUAL

Auto sampling select

   ADC_AUTO_SAMPLING_ON

   ADC_AUTO_SAMPLING_OFF

Sampling Mode Control

   ADC_SIMULTANEOUS

   ADC_MULTIPLE

Sample enable

   ADC_SAMP_ON

   ADC_SAMP_OFF

 

config2 
This contains the parameters to be configured in the ADCON2 register as defined below:

Voltage Reference

   ADC_VREF_AVDD_AVSS

   ADC_VREF_EXT_AVSS

   ADC_VREF_AVDD_EXT

   ADC_VREF_EXT_EXT

Scan selection

   ADC_SCAN_ON

   ADC_SCAN_OFF

A
/D channels utilized

   ADC_CONVERT_CH0123

   ADC_CONVERT_CH01

   ADC_CONVERT_CH0

DMA Address Increment Rate

   ADC_DMA_ADD_INC_1

   ADC_DMA_ADD_INC_2

   
.....

   
ADC_DMA_ADD_INC_15

   ADC_DMA_ADD_INC_16

Buffer mode select

   ADC_ALT_BUF_ON

   ADC_ALT_BUF_OFF

Alternate Input Sample mode select

   ADC_ALT_INPUT_ON

   ADC_ALT_INPUT_OFF

 

config3 
This contains the parameters to be configured in the ADCON3 register as defined below:

Auto Sample Time bits

   ADC_SAMPLE_TIME_0

   ADC_SAMPLE_TIME_1

   
.....

   
ADC_SAMPLE_TIME_30

   ADC_SAMPLE_TIME_31

Conversion Clock Source select

   ADC_CONV_CLK_INTERNAL_RC

   ADC_CONV_CLK_SYSTEM

Conversion clock select

   ADC_CONV_CLK_Tcy2

   ADC_CONV_CLK_Tcy

   ADC_CONV_CLK_3Tcy2

   ADC_CONV_CLK_2Tcy

   
.....

   
ADC_CONV_CLK_32Tcy

 

config4 
This contains the parameters to be configure in ADxCON4 register as defined below:

DMA Buffer Locations per Analog Input

   ADC_DMA_BUF_LOC_128

   ADC_DMA_BUF_LOC_64

   ADC_DMA_BUF_LOC_32

   
.....

   
ADC_DMA_BUF_LOC_1

 

configport_h 
This contains the pin select to be configured into the ADPCFG register as defined below:

   
ENABLE_ALL_ANA_16_31

   ENABLE_ALL_DIG_16_31

   ENABLE_AN16_ANA

   ENABLE_AN17_ANA

   ENABLE_AN18_ANA

   
.....

   
ENABLE_AN31_ANA

 

configport_l 
This contains the pin select to be configured into the ADPCFG register as defined below:

   
ENABLE_ALL_ANA_0_15

   ENABLE_ALL_DIG_0_15

   ENABLE_AN0_ANA

   ENABLE_AN1_ANA

   ENABLE_AN2_ANA

   
.....

   
ENABLE_AN15_ANA

 

configscan_l 
This contains the scan select parameter to be configured into the ADxCSSL register as defined below:

   
SCAN_NONE

   SCAN_ALL

   SKIP_SCAN_AN0

   SKIP_SCAN_AN1

   
.....

   
SKIP_SCAN_AN15

 

configscan_h 
This contains the scan select parameter to be configured into the ADxCSSH register as defined below:

   
SCAN_NONE

   SCAN_ALL

   SKIP_SCAN_AN16

   SKIP_SCAN_AN1

   
.....

   
SKIP_SCAN_AN31
 
Return Value
 None
 
Remarks
:
 
This function configures the ADC for the following parameters:

Operating modeSleep mode behaviorDMA Buffer Write ModeData o/p formatADC Module ModeConversion trigger sourceSampling controlVREF sourceScan selectionDMA address increment rateBuffer Fill modeAlternate i/p sample modAuto sample timeConvclock sourceConv Clock Select bitsPort Config Control bits.
 
Source File:
 
OpenADC1.c

OpenADC2
.c
 
Code Example
 unsigned int config1
;

unsigned int config2;

unsigned int config3;

unsigned int config4;

unsigned int configport_h;

unsigned int configport_l;

unsigned int configscan_h;

unsigned int configscan_l;

 

config1 ADC_MODULE_ON ADC_IDLE_STOP 

ADC_ADDMABM_ORDER ADC_AD_12B_12BIT &

ADC_FORMAT_SIGN_INT ADC_CLK_TMR &

AUTO_SAMPLING_ON ADC_MULTIPLE ;

 

config2 ADC_VREF_AVDD_AVSS ADC_SCAN_ON &

ADC_CONVERT_CH0123 ADC_DMA_ADD_INC_1 ;

 

config3 =  ADC_CONV_CLK_SYSTEM ADC_SAMPLE_TIME_3 &

ADC_CONV_CLK_Tcy2;

 

config4 ADC_DMA_BUF_LOC_32;

 

configport_h ENABLE_ALL_ANA_16_31;

 

configport_l ENABLE_ALL_ANA_0_15;

 

configscan_l SCAN_ALL

configscan_l 
SCAN_ALL;

 

OpenADC1(config1,config2,config3,config4,configport_l,configport_hconfigscan_h,configscan_l);



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


C30 adc.h 10bit 函數庫
#1
初級會員
初級會員


查看用戶資訊
請問前輩們…C30編譯器是否有,支援dsPIC33FJ系列「 Header for 10 bit ADC module library functions 」,我找了許久發現好像只有12bit(adc.h =>12bit)(adc10.h => dsPIC30 使用),假使沒有要如何解決函數上的定義,目前使用的C30是microchip.com最新下載…謝謝

發表於: 2007/9/13 17:57
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... ]

教育訓練中心

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