30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

char CAN2IsTXReady(char);<br />

Arguments: buffno The value of buffno indicates the transmit buffer whose<br />

status is required.<br />

Return Value: If TXREQ is ‘1’, it returns ‘0’ indicating that the transmit buffer<br />

is not<br />

empty.<br />

If TXREQ is ‘0’, it returns ‘1’ indicating that the transmit buffer is empty<br />

and the transmitter is ready for next transmission.<br />

Remarks: This function returns the complimentof the TXREQ Status bit in the<br />

Transmit Control register.<br />

Source File: CAN1IsTXReady.c<br />

CAN2IsTXReady.c<br />

Code Example: char tx_2_status;<br />

tx_2_status = CAN1IsTXReady(2);<br />

CAN1ReceiveMessage<br />

CAN2ReceiveMessage<br />

Description: This function read the data from the receive buffer.<br />

Include: can.h<br />

Prototype: void CAN1ReceiveMessage(unsigned char *<br />

data, unsigned char datalen, char MsgFlag);<br />

datalen Số lượng các byte dữ liệu được truyền đi.<br />

MsgFlag Số lượng bộ đệm ("0", "1" hoặc "2") từ nơi dữ liệu có<br />

truyền đi.<br />

Nếu "1", dữ liệu được wriiten vào CiTX1B1 để CiTX1B4.<br />

Nếu '2', dữ liệu được wriiten vào CiTX2B1 để CiTX2B4.<br />

Nếu "0" hay nói cách khác, các dữ liệu được ghi vào CiTX0B1 để<br />

CiTX0B4.<br />

Trở lại giá trị: Không<br />

Ghi chú: Chức năng này ghi các giá trị định danh vào SID và EID đăng ký,<br />

dữ liệu được truyền vào TX reg, thiết lập chiều dài dữ liệu và tu<br />

truyền bằng cách thiết lập TXREQ bit.<br />

Source File: CAN1SendMessage.c<br />

CAN2SendMessage.c<br />

Mã số Ví dụ: CAN1SendMessage ((CAN_TX_SID (1920)) và<br />

(CAN_TX_EID_EN) & (CAN_SUB_NOR_TX_REQ),<br />

(CAN_TX_EID (12.344)) & (CAN_NOR_TX_REQ),<br />

Txdata, datalen, tx_rx_no);<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

void CAN2ReceiveMessage(unsigned char *<br />

data, unsigned char datalen,char MsgFlag);<br />

Arguments: data The pointer to the location where received data is to be<br />

DS51456B trang 86<br />

CAN1SetFilter<br />

CAN2SetFilter<br />

2004 Microchip Technology Inc<br />

stored from.<br />

datalen The number of bytes of data expected.<br />

MsgFlag The buffer number where data is received.<br />

If ‘1’, the data from CiRX1B1 to CiRX1B4 is read.<br />

If ‘0’ or otherwise, the data from CiRX0B1 to CiRX0B4 is<br />

read.<br />

Remarks: This function reads the received data into the locations pointed by<br />

input<br />

parameter data.<br />

Return Value: None.<br />

Source File: CAN1ReceiveMessage.c<br />

CAN2ReceiveMessage.c<br />

Code Example: unsigned char*rx_data;<br />

CAN1ReceiveMessage(rx_data, 5, 0);<br />

dsPIC Peripheral Libraries<br />

2004 Microchip Technology Inc. DS51456B-page 85<br />

CAN1SendMessage<br />

Mô tả: Chức năng này đặt giá trị bộ lọc chấp nhận (SID và EID) cho<br />

bộ lọc quy định.<br />

Bao gồm: can.h<br />

Prototype: void CAN1SetFilter (char filter_no, int sid,<br />

unsigned eid dài);<br />

khoảng trống CAN2SetFilter (char filter_no, int sid,<br />

unsigned eid dài);<br />

Đối số: filter_no Các bộ lọc (0, 1, 2, 3, 4 hoặc 5) mà giá trị bộ lọc mới<br />

phải được cấu hình.<br />

sid giá trị 16-bit được ghi vào sổ đăng ký CiRXFnSID.<br />

CAN_FILTER_SID (x) XIS giá trị SID yêu cầu.<br />

Loại tin nhắn được nhận<br />

CAN_RX_EID_EN<br />

CAN_RX_EID_DIS<br />

Eid giá trị 32-bit được ghi vào CiRXFnEIDH và<br />

CiRXFnEIDL đăng ký.

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

Saved successfully!

Ooh no, something went wrong!