1、1.// F04x_CAN1.c 2.//------------------------------------------------------------------------------ 3.// 4.// 5.// DEVICE: C8051F040 6.// 7.// AUTHOR: LS 8.// 9.// TOOLS: Keil C-compiler and Silicon Labs IDE 10.// 11.// 12.// CAN1.c and CAN2.c are a
2、 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 depres
3、sed/released, with a 0x11 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 18.// received data and will turn on/off the target board's LED. When one target
4、 19.// is loaded with CAN2.c and the other is loaded with CAN1.c, one target 20.// board's push-button will control the other target board's LED, establishing 21.// a simple control link via the CAN bus and can be observed directly on the 22.// target boards. 23./
5、/////////////////////////////////////////////////////////////////////////////// 24. 25.//////////////////////////////////////////////////////////////////////////////// 26.// Includes 27.//////////////////////////////////////////////////////////////////////////////
6、// 28. 29.#include // SFR declarations 30. 31.// CAN Protocol Register Index for CAN0ADR, from TABLE 18.1 of the C8051F040 32.// datasheet 33.///////////////////////////////////////////////////////////////////////////////