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.

Relevant Include Files:<br />

none all functions are built in<br />

Relevant getenv() Parameters:<br />

none<br />

Example Code:<br />

#USE<br />

// RTOS will use timer zero, minor cycle will be 20ms<br />

RTOS(timer=0,minor_cycle=20ms)<br />

...<br />

int sem;<br />

...<br />

#TASK(rate=1s,max=20ms,queue=5) // Task will run at a rate of once per second<br />

void task_name();<br />

// with a maximum running time of 20ms and<br />

// a 5 byte queue<br />

rtos_run();<br />

// begins the RTOS<br />

rtos_terminate();<br />

// ends the RTOS<br />

rtos_enable(task_name);<br />

rtos_disable(task_name);<br />

rtos_msg_send(task_name,5);<br />

rtos_yield();<br />

rtos_sigal(sem);<br />

// enables the previously declared task.<br />

// disables the previously declared task<br />

// places the value 5 in task_names queue.<br />

// yields control to the RTOS<br />

// signals that the resource represented by sem is<br />

available.<br />

For more information on the <strong>CCS</strong> RTOS please<br />

SPI<br />

SPI is a fluid standard for 3 or 4 wire, full duplex communications named by Motorola. Most<br />

PIC devices support most common SPI modes. <strong>CCS</strong> provides a support library for taking<br />

advantage of both hardware and software based SPI functionality. For software support, see<br />

#USE SPI.<br />

Relevant Functions:<br />

setup_spi(mode)<br />

setup_spi2(mode)<br />

setup_spi3 (mode)<br />

setup_spi4 (mode)<br />

Configure the hardware SPI to the specified mode. The mode<br />

configures setup_spi2(mode) thing such as master or slave<br />

mode, clock speed and clock/data trigger configuration.<br />

Note: for devices with dual SPI interfaces a second function, setup_spi2(), is provided to<br />

68

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

Saved successfully!

Ooh no, something went wrong!