17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

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

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

Built-in Functions<br />

· ADC_START_ONLY (starts conversion and returns)<br />

· ADC_READ_ONLY(reads conversion result)<br />

result – Pointer to return ADC conversion too. Parameter is optional, if<br />

not used the read_fast_adc() function can only perform a start.<br />

Returns:<br />

Undefined<br />

This function is used to start an analog to digital conversion<br />

and/or read the digital value when the conversion is complete.<br />

Calls to setup_high_speed_adc() and<br />

setup_high_speed_adc_pairs() should be made sometime<br />

before this function is called.<br />

When using this function to perform an individual start and<br />

read or individual start only, the function assumes that the<br />

pair's trigger source was set to<br />

INDIVIDUAL_SOFTWARE_TRIGGER.<br />

Function:<br />

When using this function to perform a global start and read,<br />

global start only, or global read only. The function will perform<br />

the following steps:<br />

1. Determine which ADC pairs are set for<br />

GLOBAL_SOFTWARE_TRIGGER.<br />

2. Clear the corresponding ready flags (if doing a<br />

start).<br />

3. Set the global software trigger (if doing a start).<br />

4. Read the corresponding ADC pairs in order<br />

from lowest to highest (if doing a read).<br />

5. Clear the corresponding ready flags (if doing a<br />

read).<br />

When using this function to perform a individual read only.<br />

The function can read the ADC result from any trigger<br />

source.<br />

Availability:<br />

Requires:<br />

Examples:<br />

Only on dsPIC33FJxxGSxxx devices.<br />

Constants are define in the device .h file.<br />

//Individual start and read<br />

int16 result[2];<br />

setup_high_speed_adc(ADC_CLOCK_DIV_4);<br />

setup_high_speed_adc_pair(0, INDIVIDUAL_SOFTWARE_TRIGGER);<br />

read_high_speed_adc(0, result); //starts conversion for AN0 and AN1 and<br />

stores<br />

//result in result[0] and result[1]<br />

//Global start and read<br />

int16 result[4];<br />

setup_high_speed_adc(ADC_CLOCK_DIV_4);<br />

249

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

Saved successfully!

Ooh no, something went wrong!