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.

Examples:<br />

while #use spi(MATER, SPI1, baud=1000000, mode=0, stream=SPI1_MODE0)<br />

spi_inspi_init(SPI1_MODE0, TRUE); //initialize and enable SPI1 to setting in #USE<br />

SPI<br />

spi_inspi_init(FALSE); //disable SPI1<br />

spi_inspi_init(250000);//initialize and enable SPI1 to a baud rate of 250K<br />

Example Files: None<br />

Also See:<br />

#USE SPI, spi_xfer(), spi_xfer_in(), spi_prewrite(), spi_speed()<br />

spi_prewrite(data);<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

spi_prewrite(data);<br />

spi_prewrite(stream, data);<br />

stream – is the SPI stream to use as defined in the STREAM=name<br />

option in #USE SPI.<br />

data- the variable or constant to transfer via SPI<br />

Nothing.<br />

Writes data into the SPI buffer without waiting for transfer to be<br />

completed. Can be used in conjunction with spi_xfer() with no<br />

parameters to transfer more then 8 bits for <strong>PCM</strong> and <strong>PCH</strong> device, or<br />

more then 8 bits or 16 bits (XFER16 option) for PCD. Function is useful<br />

when using the SSP or SSP2 interrupt service routines for <strong>PCM</strong> and <strong>PCH</strong><br />

device, or the SPIx interrupt service routines for PCD device.<br />

This function is only available on devices with SPI hardware.<br />

#USE SPI, and the option SLAVE is used in #USE SPI to setup PIC as a<br />

SPI slave device<br />

spi_prewrite(data_out);<br />

ex_spi_slave.c<br />

#USE SPI, spi_xfer(), spi_xfer_in(), spi_init(), spi_speed()<br />

spi_read( ) spi_read2( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

value = spi_read ([data])<br />

value = spi_read2 ([data])<br />

data – optional parameter and if included is an 8 bit int.<br />

An 8 bit int<br />

Return a value read by the SPI. If a value is passed to the spi_read() the data<br />

314

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

Saved successfully!

Ooh no, something went wrong!