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.

Source File: ReadADC12.c<br />

Code Example: unsigned int result;<br />

result = ReadADC12(5);<br />

StopSampADC12<br />

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

Source File: #defineto ConvertADC12in adc12.h<br />

SetChanADC12<br />

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

multiplexers A and B.<br />

Include: adc12.h<br />

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

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

into ADCHS register as defined below:<br />

A/D Channel 0 positive i/p select for SAMPLE A<br />

ADC_CH0_POS_SAMPLEA_AN0<br />

ADC_CH0_POS_SAMPLEA_AN1<br />

.....<br />

ADC_CH0_POS_SAMPLEA_AN15<br />

A/D Channel 0 negative i/p select for SAMPLE A<br />

ADC_CH0_NEG_SAMPLEA_AN1<br />

ADC_CH0_NEG_SAMPLEA_NVREF<br />

A/D Channel 0 positive i/p select for SAMPLE B<br />

ADC_CH0_POS_SAMPLEB_AN0<br />

ADC_CH0_POS_SAMPLEB_AN1<br />

.....<br />

ADC_CH0_POS_SAMPLEB_AN15<br />

A/D Channel 0 negative i/p select for SAMPLE B<br />

ADC_CH0_NEG_SAMPLEB_AN1<br />

ADC_CH0_NEG_SAMPLEB_NVREF<br />

Return Value: None<br />

Remarks: This function configures the inputs for the sample multiplexers A and<br />

B<br />

by writing to the ADCHS register.<br />

Source File: SetChanADC12.c<br />

Code Example: SetChanADC12(ADC_CH0_POS_SAMPLEA_AN4 &<br />

ADC_CH0_NEG_SAMPLEA_NVREF);<br />

dsPIC<br />

®<br />

Language Tools Libraries<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 />

SetChanADC12 (Channel);<br />

ConfigIntADC12 (ADC_INT_DISABLE);<br />

PinConfig = ENABLE_AN4_ANA;<br />

Scanselect = SKIP_SCAN_AN2 & SKIP_SCAN_AN5 &<br />

SKIP_SCAN_AN9 & SKIP_SCAN_AN10 &<br />

SKIP_SCAN_AN14 & SKIP_SCAN_AN15;<br />

Adcon3_reg = ADC_SAMPLE_TIME_10 &<br />

ADC_CONV_CLK_SYSTEM &<br />

ADC_CONV_CLK_13Tcy;<br />

Adcon2_reg = ADC_VREF_AVDD_AVSS &<br />

ADC_SCAN_OFF &<br />

ADC_ALT_BUF_OFF &<br />

ADC_ALT_INPUT_OFF &<br />

ADC_SAMPLES_PER_INT_16;<br />

Adcon1_reg = ADC_MODULE_ON &<br />

ADC_IDLE_CONTINUE &<br />

ADC_FORMAT_INTG &<br />

ADC_CLK_MANUAL &<br />

ADC_AUTO_SAMPLING_OFF;<br />

OpenADC12 (Adcon1_reg, Adcon2_reg,<br />

Adcon3_reg, PinConfig, Scanselect);<br />

i = 0;<br />

trong khi (i

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

Saved successfully!

Ooh no, something went wrong!