CAN总线硬件连接及程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

0x0F
//IF1 Data A1
Register
52.
#define IF1DATA2
0x10
//IF1 Data A2
Register
53.
#define IF1DATB1
0x11
//IF1 Data B1
Register
54.
#define IF1DATB2
// CAN Protocol Register Index for CAN0ADR, from TABLE 18.1 of the C8051F040
32.
// datasheet
33.
////////////////////////////////////////////////////////////////////////////////
26.
// Includes
27.
////////////////////////////////////////////////////////////////////////////////
28.
29.
#include <c8051f040.h>
// SFR declarations
30.
31.
18.
// received data and will turn on/off the target board's LED. When one target
19.
// is loaded with CAN2.c and the other is loaded with CAN1.c, one target
.
资料.
.
..
45.
#define IF1CMDMSK
0x09
//IF1 Command Mask Register
46.
#define IF1MSK1
0x0A
//IF1 Mask1
Register
47.
#define IF1MSK2
0x0B
//IF1 Mask2
Register
48.
#define IF1ARB1
16.
// to indicate the button is pushed, and 0x00 when released. Each node also has
17.
// a message object configured to receive messages. The C8051 tests the
0x0C
//IF1 Arbitration 1 Register
49.
#define IF1ARB2
0x0D
//IF1 Arbitration 2 Register
50.
#define IF1MSGC
0x0E
//IF1 Message Control Register
51.
#define IF1DATA1
42.
//IF1 Interface Registers
43.
////////////////////////////////////////////////////////////////////////////////
44.
#define IF1CMDRQST
0x08
//IF1 Command Rest Register
.
..
.
.
资料.
.
..
.
1.
// F04x_CAN1.c
2.
//------------------------------------------------------------------------------
3.
//
4.
//
5.
// DEVICE: C8051F040
6.
//
7.
// AUTHOR: LS
38.
#define INTREG
0x04
//Interrupt Low Byte Register
39.
#define CANTSTR
0x05
//Test register
40.
#define BRPEXT
0x06
//BRP Extension Register
41.
////////////////////////////////////////////////////////////////////////////////
20.
// board's push-button will control the other target board's LED, establishing
Biblioteka Baidu
21.
// a simple control link via the CAN bus and can be observed directly on the
8.
//
9.
// TOOLS: Keil C-compiler and Silicon Labs IDE
10.
//
11.
//
12.
// CAN1.c and CAN2.c are a simple example of configuring a CAN network to
13.
// transmit and receive data on a CAN network, and how to move information to
14.
// and from CAN RAM message objects. Each C8051F040-TB CAN node is configured
15.
// to send a message when it's P3.7 button is depressed/released, with a 0x11
22.
// target boards.
23.
////////////////////////////////////////////////////////////////////////////////
24.
25.
////////////////////////////////////////////////////////////////////////////////
34.
#define CANCTRL
0x00
//Control Register
35.
#define CANSTAT
0x01
//Status register
36.
#define ERRCNT
0x02
//Error Counter Register
37.
#define BITREG
0x03
//Bit Timing Register
相关文档
最新文档