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 getenv() parameters:<br />

UART<br />

AUART<br />

UART_RX<br />

UART_TX<br />

UART2_RX<br />

UART2_TX<br />

Returns the number of UARTs on this PIC<br />

Returns true if this UART is an advanced UART<br />

Returns the receive pin for the first UART on this PIC (see<br />

PIN_XX)<br />

Returns the transmit pin for the first UART on this PIC<br />

Returns the receive pin for the second UART on this PIC<br />

TX – Returns the transmit pin for the second UART on this<br />

PIC<br />

Example Code:<br />

/* configure and enable uart, use first hardware UART on PIC */<br />

#use rs232(uart1, baud=9600)<br />

/* print a string */<br />

printf(“enter a character”);<br />

/* get a character */<br />

if (kbhit())<br />

c = getc();<br />

//check if a character has been received<br />

//read character from UART<br />

RTOS<br />

These functions control the operation of the <strong>CCS</strong> Real Time Operating System (RTOS). This<br />

operating system is cooperatively multitasking and allows for tasks to be scheduled to run at<br />

specified time intervals. Because the RTOS does not use interrupts, the user must be careful to<br />

make use of the rtos_yield() function in every task so that no one task is allowed to run forever.<br />

Relevant Functions:<br />

rtos_run()<br />

rtos_terminate()<br />

rtos_enable(task)<br />

Begins the operation of the RTOS. All task management<br />

tasks are implemented by this function.<br />

This function terminates the operation of the RTOS and<br />

returns operation to the original program. Works as a<br />

return from the rtos_run()function.<br />

Enables one of the RTOS tasks. Once a task is enabled,<br />

the rtos_run() function will call the task when its time<br />

occurs. The parameter to this function is the name of task<br />

66

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

Saved successfully!

Ooh no, something went wrong!