beautypg.com

COMMELL MPX-2515 User Manual

Page 12

background image

Commell MPX-2515 User’s Guide Rev 0100

Taiwan Commate Computer Inc.

12

register locations can be read sequentially using this method. The read operation is
terminated by raising the CS# pin. The following figure shows the MCP2515 Read
instruction.

Figure 2 MCP2515 Read Instruction

#define CCP_CAN_SYSTEM_SERVICE 0X20 /* COMMAND: command code */
#define CAN_READ_INSTRUCT 0X86 /* DATA_0: sub-command code */
#define EP2 2 /* Endpoint 2 */
#define EP3 3 /* Endpoint 3 */

OFFSET

BULK OUT (EP2)

BULK IN (EP1)

SIZEOF_DATA

0X04

Number of bytes returned

COMMAND

0X20

Byte_0 (return byte 0)

ERROR

0X00

Byte_1 (return byte 1)

DATA_0

0X86

Byte_2 (return byte 2)

DATA_1

Number of bytes to read

...

DATA_2

0X03 (constant)

...

DATA_3

Starting register address

...

DATA_4

Checksum

...

...

DATA_n

Checksum

1.5.7 CAN_WRITE_INSTRUCT

The CAN_WRITE_INSTRUCT implements MCP2515 Write Instruction. The
Write instruction is started by lowering the CS# pin. The Write instruction is then
sent to the MCP2515 followed by the address and at least one byte of data.