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.

setup_comparator(A4_A5_NC_NC);<br />

if(C1OUT)<br />

output_low(PIN_D0);<br />

else<br />

output_high(PIN_D1);<br />

CAN Bus<br />

These functions allow easy access to the Controller Area Network (CAN) features included with<br />

the MCP2515 CAN interface chip and the PIC18 MCU. These functions will only work with the<br />

MCP2515 CAN interface chip and PIC microcontroller units containing either a CAN or an<br />

ECAN module. Some functions are only available for the ECAN module and are specified by the<br />

work ECAN at the end of the description. The listed interrupts are no available to the MCP2515<br />

interface chip.<br />

Relevant Functions:<br />

Initializes the CAN module and clears all the filters<br />

and masks so that all messages can be received<br />

can_init(void);<br />

from any ID.<br />

can_set_baud(void);<br />

Initializes the baud rate of the CAN bus to125kHz, if<br />

using a 20 MHz clock and the default CAN-BRG<br />

defines, it is called inside the can_init() function so<br />

there is no need to call it.<br />

can_set_mode<br />

(CAN_OP_MODE mode);<br />

can_set_functional_mode<br />

(CAN_FUN_OP_MODE mode);<br />

Allows the mode of the CAN module to be changed<br />

to configuration mode, listen mode, loop back mode,<br />

disabled mode, or normal mode.<br />

Allows the functional mode of ECAN modules to be<br />

changed to legacy mode, enhanced legacy mode,<br />

or first in firstout (fifo) mode. ECAN<br />

can_set_id(int* addr, int32 id, int1 ext);<br />

can_get_id(int * addr, int1 ext);<br />

can_putd<br />

(int32 id, int * data, int len,<br />

int priority, int1 ext, int1 rtr);<br />

can_getd<br />

(int32 & id, int * data, int & len,<br />

struct rx_stat & stat);<br />

Can be used to set the filter and mask ID's to the<br />

value specified by addr. It is also used to set the ID<br />

of the message to be sent.<br />

Returns the ID of a received message.<br />

Constructs a CAN packet using the given<br />

arguments and places it in one of the available<br />

transmit buffers.<br />

Retrieves a received message from one of the CAN<br />

buffers and stores the relevant data in the<br />

referenced function parameters.<br />

44

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

Saved successfully!

Ooh no, something went wrong!