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.

Common Questions & Answers<br />

How does the PIC® connect to an I2C device?<br />

Two I/O lines are required for I2C. Both lines must have pullup registers. Often the I2C device<br />

will have a H/W selectable address. The address set must match the address in S/W. The<br />

example programs all assume the selectable address lines are grounded.<br />

How much time do math operations take?<br />

Unsigned 8 bit operations are quite fast and floating point is very slow. If possible consider fixed<br />

point instead of floating point. For example instead of "float cost_in_dollars;" do "long<br />

cost_in_cents;". For trig formulas consider a lookup table instead of real time calculations (see<br />

EX_SINE.C for an example). The following are some rough times on a 14-bit PIC®. Note times<br />

will vary depending on memory banks used.<br />

20 mhz PIC16<br />

int8 [us]<br />

int16 [us]<br />

int32<br />

[us]<br />

float<br />

[us]<br />

+ 0.6 1.4 3 111.<br />

- 0.6 1.4 3 113.<br />

* 11.1 47.2 132 178.<br />

/ 23.2 70.8 239.2 330.<br />

exp() * * * 1697.3<br />

ln() * * * 2017.7<br />

sin() * * * 2184.5<br />

40 mhz PIC18<br />

int8 [us] int16 [us] int32 [us] float [us]<br />

361

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

Saved successfully!

Ooh no, something went wrong!