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.

ex_usb_serial.c The CDC virtual RS232 library is demonstrated with this RS232 < - ><br />

USB example.<br />

ex_usb_serial2.c<br />

Another CDC virtual RS232 library example, this time a port of the<br />

ex_intee.c example to use USB instead of RS232.<br />

Voltage Reference<br />

These functions configure the votlage reference module. These are available only in the<br />

supported chips.<br />

Relevant Functions:<br />

setup_vref(mode | value)<br />

Relevant Preprocesser:<br />

none<br />

Enables and sets up the internal voltage reference value.<br />

Constants are defined in the device's .h file.<br />

Relevant Interrupts:<br />

none<br />

Relevant Include Files:<br />

none, all functions built-in<br />

Relevant getenv() parameters:<br />

VREF<br />

Returns 1 if the device has VREF<br />

Example code:<br />

for PIC12F675<br />

#INT_COMP //comparator interrupt handler<br />

void isr() {<br />

safe_conditions = FALSE;<br />

printf("WARNING!!!! Voltage level is above<br />

3.6V. \r\n");<br />

}<br />

setup_comparator(A1_VR_OUT_ON_A2)//sets 2<br />

comparators(A1 and VR and A2 as output)<br />

{<br />

setup_vref(VREF_HIGH | 15);//sets 3.6(vdd *<br />

value/32 + vdd/4) if vdd is 5.0V<br />

enable_interrupts(INT_COMP); // enable the<br />

comparator interrupt<br />

enable_interrupts(GLOBAL); //enable global<br />

interrupts<br />

}<br />

78

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

Saved successfully!

Ooh no, something went wrong!