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.

value=get_timer0<br />

Relevant Preprocessor:<br />

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

None<br />

Relevant Interrupts :<br />

INT_TIMER0 or INT_RTCC<br />

Interrupt fires when timer0 overflows<br />

Relevant Include Files:<br />

None, all functions built-in<br />

Relevant getenv() parameters:<br />

TIMER0<br />

Returns 1 if the device has timer0<br />

Example Code:<br />

For PIC18F452<br />

setup_timer_0(RTCC_INTERNAL //sets the internal clock as source<br />

|RTCC_DIV_2|RTCC_8_BIT); //and prescale 2. At 20Mhz timer0<br />

//will increment every 0.4us in this<br />

//setup and overflows every<br />

//102.4us<br />

set_timer0(0); //this sets timer0 register to 0<br />

time=get_timer0();<br />

//this will read the timer0 register<br />

//value<br />

Timer1<br />

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

pic18s. It counts up and also provides interrupt on overflow. The options available differ and are<br />

listed in the device header file.<br />

Relevant Functions:<br />

setup_timer_1(mode)<br />

set_timer1(value)<br />

value=get_timer1<br />

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

timer1<br />

Initializes the timer1 clock/counter<br />

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

Relevant Preprocessor:<br />

None<br />

70

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

Saved successfully!

Ooh no, something went wrong!