C8051F04x-DK
Rev. 0.4
5
You should now have can1.c loaded into Target Board #1, and can2.c loaded into Target Board #2. The CAN cable
should be connected to both boards at the CAN DB-9 connectors.
5.3.2. Running the Application
1. Start the application by resetting the device on each target board. Do this by depressing the RESET push
button on each target board. As can1.c executes on Target Board #1, and can2.c runs on Target Board #2,
the devices are now nodes on a CAN bus.
2. Pressing the P3.7 push button on Target Board #1 will light the LED on Target Board #2. Likewise, when
the push button on Target Board #1 is released, the LED on Target Board #2 will turn off. This will work on
either target board.
Once this example is running, you have established a simple CAN network with two nodes. When one C8051F040
device senses the push button on its target board is pressed, it sends a “0x11” in the first byte of a CAN message
data field. When the button is released, the first byte of the CAN message data field is “0x00”. When a C8051F040
device receives a message, it checks whether this byte has a value of “0x11” or “0x00”. When the byte is “0x11”,
the device turns on its LED by setting P1.6 high. When the byte is “0x00”, the device turns off its LED by setting
P1.6 low.
You may run the example with the EC2 connected to view CAN registers, and CAN message objects in CAN RAM.
While connected to one target board, run the code. Depress the RESET button on the other target board. You may
use debug and view features of the Silicon Laboratories IDE and on-chip debug logic. To view the CAN SFRs, click
View->Debug Windows->SFRs->CAN0
. To view message objects in CAN RAM, click
View->Debug Windows-
>CAN0 Message Registers
. To view SFRs and message registers, the device must be in a halt state to update
the debug view windows.
Important Note: To view a Message Object in the CAN Message Registers window, you must set its Message Valid
bit to 1 in the Message Object's associated Message Arbitration 2 Register (Bit 15, ARBT2). This can be done in
code by configuring the IF1 and IF2 registers to set the associated Message Objects’ ARBT2 register. A second
method to set this bit is available while viewing the Message Object registers in the IDE CAN0 Message Registers
view. Click on, and change, the associated Message Objects’ ARBT2 register directly. Working in the background
the IDE will set the register for you via the IF1 and IF2 registers.
Serial Port
Serial
Adapter
Ribbon
Cable
Target Board
AC/DC
Adapter
PC
CA
N
JTAG
RS
23
2
Target Board
AC/DC
Adapter
RS
232
JTAG
CA
N
Serial
Cable
Serial
Cable
Figure 2. CAN Application Hardware Setup