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.

None, all functions built-in<br />

Relevant getenv() parameters:<br />

TIMER2<br />

Returns 1 if the device has timer2<br />

Example Code:<br />

For PIC18F452<br />

setup_timer_2(T2_DISABLED); //disables timer2<br />

or<br />

setup_timer_2(T2_DIV_BY_4,0xc0,2); //sets the prescale as 4, period as 0xc0 and<br />

//postscales as 2.<br />

//At 20Mhz timer2 will increment every .8us in this<br />

//setup overflows every 154.4us and interrupt every<br />

308.2us<br />

set_timer2(0); //this sets timer2 register to 0<br />

time=get_timer2();<br />

//this will read the timer1 register value<br />

Timer3<br />

Timer3 is very similar to timer1. So please refer to the Timer1 section for more details.<br />

Timer4<br />

Timer4 is very similar to Timer2. So please refer to the Timer2 section for more details.<br />

Timer5<br />

These options lets the user configure and use timer5. The clock/counter is 16-bit and is<br />

available only on 18Fxx31 devices. It counts up and also provides interrupt on overflow. The<br />

options available differ and are listed in the device header file.<br />

Relevant Functions:<br />

setup_timer_5(mode)<br />

set_timer5(value)<br />

value=get_timer5<br />

Disables or sets the source and prescale for<br />

imer5<br />

Initializes the timer5 clock/counter<br />

Returns the value of the timer51 clock/counter<br />

Relevant Preprocessor:<br />

72

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

Saved successfully!

Ooh no, something went wrong!