17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example Code:<br />

setup_timer_A(TA_OFF);<br />

or<br />

setup_timer_A<br />

(TA_INTERNAL | TA_DIV_8);<br />

//disable timerA<br />

//sets the internal clock as source<br />

//and prescale as 8. At 20MHz timerA will increment<br />

//every 1.6us in this setup and overflows every<br />

//409.6us<br />

set_timerA(0); //this sets timerA register to 0<br />

time=get_timerA();<br />

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

TimerB<br />

These options lets the user configure and use timerB. It is available on devices with TimerB<br />

hardware. The clock/counter is 8 bit. It counts up and also provides interrupt on overflow. The<br />

options available are listed in the device's header file.<br />

Relevant Functions:<br />

setup_timer_B(mode)<br />

set_timerB(value)<br />

value=get_timerB()<br />

Relevant Preprocessor:<br />

None<br />

Disable or sets the source and prescale for timerB<br />

Initializes the timerB clock/counter<br />

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

Relevant Interrupts :<br />

INT_TIMERB<br />

Relevant Include Files:<br />

Interrupt fires when timerB overflows<br />

None, all functions built-in<br />

Relevant getenv() parameters:<br />

TIMERB<br />

Returns 1 if the device has timerB<br />

Example Code:<br />

setup_timer_B(TB_OFF);<br />

or<br />

setup_timer_B<br />

(TB_INTERNAL | TB_DIV_8);<br />

//disable timerB<br />

//sets the internal clock as source<br />

//and prescale as 8. At 20MHz timerB will increment<br />

//every 1.6us in this setup and overflows every<br />

//409.6us<br />

set_timerB(0); //this sets timerB register to 0<br />

time=get_timerB();<br />

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

74

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

Saved successfully!

Ooh no, something went wrong!