30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ENABLE_AN1_ANA,<br />

SKIP_SCAN_AN0 &<br />

SKIP_SCAN_AN3 &<br />

SKIP_SCAN_AN4 &<br />

SKIP_SCAN_AN5);<br />

OpenADC10 (Continued)<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 106 2004 Microchip Technology Inc.<br />

ReadADC10<br />

Description: This function reads the ADC Bufferregister which contains the<br />

conversion value.<br />

Include: adc10.h<br />

Prototype: unsigned int ReadADC10(unsigned char bufIndex);<br />

Arguments: bufIndex This is the ADC buffer number which is to be read.<br />

Return Value: None<br />

Remarks: This function returns the contents of the ADC Buffer register. User<br />

should provide bufIndexvalue between ‘0’ to ‘15’ to ensure correct<br />

read of the ADCBUF0 to ADCBUFF.<br />

Source File: ReadADC10.c<br />

Code Example: unsigned int result;<br />

result = ReadADC10(3);<br />

StopSampADC10<br />

Description: This function is identical to ConvertADC10.<br />

Source File: #defineto ConvertADC10in adc10.h<br />

SetChanADC10<br />

Description: This function sets the positive and negative inputs for the sample<br />

multiplexers A and B.<br />

Include: adc10.h<br />

Prototype: void SetChanADC10(unsigned int channel);<br />

Arguments: channel This contains the input selectparameter to be configured<br />

into the ADCHS register as defined below:<br />

A/D Channel 1, 2, 3 Negative input for Sample A<br />

ADC_CHX_NEG_SAMPLEA_AN9AN10AN11<br />

ADC_CHX_NEG_SAMPLEA_AN6AN7AN8<br />

ADC_CHX_NEG_SAMPLEA_NVREF<br />

A/D Channel 1, 2, 3 Negative input for Sample B<br />

ADC_CHX_NEG_SAMPLEB_AN9AN10AN11<br />

Lập luận: Không<br />

Bình luận: Đây bộ vĩ mô ADC Interrupt Enable bit Interrupt Enable kiểm soát<br />

đăng ký.<br />

Mã số Ví dụ: EnableIntADC;<br />

DisableIntADC<br />

Mô tả: vĩ mô này vô hiệu hóa ADC gián đoạn.<br />

Bao gồm: adc10.h<br />

Lập luận: Không<br />

Bình luận: vĩ mô này xóa ADC ngắt Enablebit của Interrupt Enable kiểm soát<br />

đăng ký.<br />

Mã số Ví dụ: DisableIntADC;<br />

SetPriorityIntADC<br />

Mô tả: Điều này đặt ra ưu tiên vĩ mô cho ADC gián đoạn.<br />

Bao gồm: adc10.h<br />

Đối số: ưu tiên<br />

Bình luận: vĩ mô này đặt ADC ngắt bit ưu tiên của ngắt ưu tiên kiểm soát<br />

đăng ký.<br />

Mã số Ví dụ: SetPriorityIntADC (2);<br />

SetChanADC10 (Tiếp theo)<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 108 2004 Microchip Technology Inc<br />

3.6.3 Ví dụ về sử dụng<br />

# xác định __dsPIC30F6010__<br />

# include<br />

# include<br />

int Channel, PinConfig, Scanselect, Adcon3_reg, Adcon2_reg,<br />

Adcon1_reg;<br />

int main (void)<br />

{<br />

int kết quả [20], i;<br />

ADCON1bits.ADON = 0; / * Tắt ADC * /<br />

Kênh = ADC_CH0_POS_SAMPLEA_AN4 &<br />

ADC_CH0_NEG_SAMPLEA_NVREF &<br />

ADC_CH0_POS_SAMPLEB_AN2 &<br />

ADC_CH0_NEG_SAMPLEB_AN1;<br />

SetChanADC1 (Channel);<br />

ConfigIntADC10 (ADC_INT_DISABLE);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!