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.

PreProcessor<br />

SLOW<br />

RESTART_WDT<br />

FORCE_HW<br />

FORCE_SW<br />

NOFLOAT_HIGH<br />

SMBUS<br />

STREAM=id<br />

NO_STRETCH<br />

MASK=nn<br />

I2C1<br />

I2C2<br />

NOINIT<br />

Use the slow I2C specification<br />

Restart the WDT while waiting in I2C_READ<br />

Use hardware I2C functions.<br />

Use software I2C functions.<br />

Does not allow signals to float high, signals are<br />

driven from low to high<br />

Bus used is not I2C bus, but very similar<br />

Associates a stream identifier with this I2C port.<br />

The identifier may then be used in functions like<br />

i2c_read or i2c_write.<br />

Do not allow clock streaching<br />

Set an address mask for parts that support it<br />

Instead of SCL= and SDA= this sets the pins to<br />

the first module<br />

Instead of SCL= and SDA= this sets the pins to<br />

the second module<br />

No initialization of the I2C peripheral is performed.<br />

Use I2C_INIT() to initialize peripheral at run time.<br />

Only some chips allow the following:<br />

DATA_HOLD No ACK is sent until I2C_READ is called for data bytes (slave<br />

only)<br />

ADDRESS_HOLD No ACK is sent until I2C_read is called for the address byte<br />

(slave only)<br />

SDA_HOLD Min of 300ns holdtime on SDA a from SCL goes low<br />

Purpose:<br />

<strong>CCS</strong> offers support for the hardware-based I2C TM and a software-based master I2C TM<br />

device.(For more information on the hardware-based I2C module, please consult the<br />

datasheet for your target device; not all PICs support I2C TM .<br />

The I2C library contains functions to implement an I2C bus. The #USE I2C remains in<br />

effect for the I2C_START, I2C_STOP, I2C_READ, I2C_WRITE and I2C_POLL functions<br />

until another USE I2C is encountered. Software functions are generated unless the<br />

FORCE_HW is specified. The SLAVE mode should only be used with the built-in SSP.<br />

The functions created with this directive are exported when using multiple compilation<br />

units. To access the correct function use the stream identifier.<br />

Examples:<br />

#use I2C(master, sda=PIN_B0, scl=PIN_B1)<br />

#use I2C(slave,sda=PIN_C4,scl=PIN_C3<br />

address=0xa0,FORCE_HW)<br />

#use I2C(master, scl=PIN_B0, sda=PIN_B1, fast=450000)<br />

//sets the target speed to 450 KBSP<br />

Example<br />

Files:<br />

Also See:<br />

ex_extee.c with 16c74.h<br />

i2c_poll, i2c_speed, i2c_start, i2c_stop, i2c_slaveaddr, i2c_isr_state,<br />

i2c_write, i2c_read, I2C Overview<br />

137

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

Saved successfully!

Ooh no, something went wrong!