Silicon Laboratories C8051F04X-DK User Manual Download Page 5

C8051F04x-DK

Rev. 0.6

5

5.3.  Controller Area Network (CAN) Application Example

Configuration and use of the CAN controller is documented in the Bosch CAN User’s Guide, located in the “

Documen-

tation

” directory on the CD-ROM. Accessing the CAN controller (i.e., accessing the CAN RAM, CAN registers, and

moving data to and from the CAN controller) is documented in Silicon Laboratories’ C8051F04x data sheet.

An example CAN application is included in the “

Examples\C8051F04x

” directory. Each C8051F040 target board fea-

tures a push button (labeled P3.7) and a LED (labeled P1.6). After the two target boards are connected together via
the provided CAN bus physical layer (i.e. cable, connectors, and CAN transceiver), the example application sends
CAN messages between the two target boards containing the state of the push buttons. In this example, each CAN
controller has two of the 32 message objects configured: one to send a control signal based on the state of its target
board push button, and one to receive a control signal from the other target to see if it should turn on/off its own LED.
When a target board receives a message that the push button on the other target board is depressed, it lights its own
LED. When a target board receives a message that the push button on the other target board is not depressed, it
turns off its own LED. In this way, the push button on one target board controls the LED on the other target board as
a virtual control link via a CAN bus. 

5.3.1. Setting-up the Application

1. Connect the target boards together at the CAN DB-9 connectors using the CAN cable provided in the

development kit, as shown in Figure 2 on page 6. The correct cable has a male connector on both ends.
Take care not to connect the CAN cable to the RS232 DB-9 connector. See Figure 3 on page 7 for the
location of the CAN DB-9 connector. 

2. Compile and link the can1.c example located in the “

Examples\C8051F04x

” directory on the CD-ROM.

Choose one of the target boards as Target Board #1. Connect to Target Board #1 and download the can1
project to the C8051F040, following the steps outlined in Section 4.4 on page 2. Once downloaded, close
this project in the IDE and disconnect the Debug Adapter from Target Board #1. 

3. Connect the Debug Adapter to the other target board, Target Board #2. Open a new project in the IDE and

load can2.c into the C8051F040 device, just as was done in step 2 for Target Board #1. Take care not to
load can1.c into both devices. Disconnect the Debug Adapter from this board.

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. 

Summary of Contents for C8051F04X-DK

Page 1: ...he Silicon Laboratories IDE via the USB Debug Adapter as shown in Figure 1 1 Connect the USB Debug Adapter to the JTAG connector on the target board with the 10 pin ribbon cable 2 Connect one end of the USB cable to the USB connector on the USB Debug Adapter 3 Connect the other end of the USB cable to a USB Port on the PC 4 Connect the ac dc power adapter to power jack P1 on the target board Notes...

Page 2: ...pment kit and is installed during IDE installation The evaluation version of the C51 compiler is the same as the full professional version except code size is limited to 4 kB and the floating point library is not included The C51 compiler reference manual can be found under the Help menu in the IDE or in the SiLabs MCU hlp directory C51 pdf 4 4 Using the Keil Software 8051 Tools with the Silicon L...

Page 3: ...n the Build Make Project button in the toolbar or selecting Project Build Make Project from the menu Note After the project has been built the first time the Build Make Project command will only build the files that have been changed since the previous build To rebuild all files and project dependencies click on the Rebuild All button in the toolbar or select Project Rebuild All from the menu 2 Be...

Page 4: ...ctory during IDE installation The register and bit names are identical to those used in the C8051F04x data sheet Both register definition files are also installed in the default search path used by the Keil Software 8051 tools Therefore when using the Keil 8051 tools included with the development kit A51 C51 it is not necessary to copy a register definition file to each project s file directory 5 ...

Page 5: ...ector See Figure 3 on page 7 for the location of the CAN DB 9 connector 2 Compile and link the can1 c example located in the Examples C8051F04x directory on the CD ROM Choose one of the target boards as Target Board 1 Connect to Target Board 1 and download the can1 project to the C8051F040 following the steps outlined in Section 4 4 on page 2 Once downloaded close this project in the IDE and disco...

Page 6: ...w 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 Mes...

Page 7: ...3 to P1 6 pin J4 JTAG connector for Debug Adapter interface J5 DB 9 connector for UART0 RS232 interface J6 Connector for UART0 TX P0 0 J8 Connector for UART0 RTS P4 0 J9 Connector for UART0 RX P0 1 J10 Connector for UART0 CTS P4 1 J11 Analog loopback connector J12 J19 Port 0 7 connectors J20 Analog I O terminal block J22 VREF connector J23 VDD Monitor Disable J24 96 pin Expansion I O connector J25...

Page 8: ...lock from the header to disconnect SW2 from the port pins The port pin signal is also routed to a pin on the J24 I O connector See Table 1 for the port pins and headers corresponding to each switch Two LEDs are also provided on the target board The red LED labeled PWR is used to indicate a power connection to the target board The green LED labeled with a port pin name is connected to the C8051F040...

Page 9: ...to transceiver J10 Install shorting block to connect UART0 CTS P4 1 to transceiver 6 5 Analog I O J11 J20 Several C8051F040 analog signals are routed to the J20 terminal block and the J11 header The J11 connector provides the ability to connect DAC0 and DAC1 outputs to several different analog inputs by installing a shorting block between a DAC output and an analog input on adjacent pins of J11 Re...

Page 10: ...nals being routed to the 96 pin expansion connector each of the eight parallel ports of the C8051F040 has its own 10 pin header connector Each connector provides a pin for the corresponding port pins 0 7 3 3VDC and digital ground Table 6 defines the pins for the port connectors The same pin out order is used for all of the port connectors 6 8 VDD Monitor Disable J23 The VDD Monitor of the C8051F04...

Page 11: ...3 VD2 3 3 VDC B 1 DGND Digital Gnd C 1 XTAL1 A 2 MONEN B 2 P1 7 C 2 P1 6 A 3 P1 5 B 3 P1 4 C 3 P1 3 A 4 P1 2 B 4 P1 1 C 4 P1 0 A 5 P2 7 B 5 P2 6 C 5 P2 5 A 6 P2 4 B 6 P2 3 C 6 P2 2 A 7 P2 1 B 7 P2 0 C 7 P3 7 A 8 P3 6 B 8 P3 5 C 8 P3 4 A 9 P3 3 B 9 P3 2 C 9 P3 1 A 10 P3 0 B 10 P0 7 C 10 P0 6 A 11 P0 5 B 11 P0 4 C 11 P0 3 A 12 P0 2 B 12 P0 1 C 12 P0 0 A 13 P7 7 B 13 P7 6 C 13 P7 5 A 14 P7 4 B 14 P7 ...

Page 12: ...r J22 can be used to connect the VREF Voltage Reference output of the C8051F040 to any or all of its voltage reference inputs Install shorting blocks on J22 in the following manner 1 2 to connect VREF to VREFD 3 4 to connect VREF to VREF0 5 6 to connect VREF to VREF2 ...

Page 13: ...C8051F04x DK Rev 0 6 13 7 Schematic Figure 5 C8051F040 Target Board Schematic ...

Page 14: ... DEBUG Interface Section added USB Debug Adapter DEBUG Connector Pin Descriptions Table changed pin 4 to C2D Changed jumper to header EC2 Serial Adapter section added EC2 to the section title table title and figure title EC2 Serial Adapter section changed JTAG to DEBUG Added USB Debug Adapter section Added J8 and J10 to the connector list Revision 0 5 to Revision 0 6 Removed EC2 Serial Adapter fro...

Page 15: ...C8051F04x DK Rev 0 6 15 NOTES ...

Page 16: ...for the functioning of undescribed features or parameters Silicon Laboratories reserves the right to make changes without further notice Silicon Laboratories makes no warranty rep resentation or guarantee regarding the suitability of its products for any particular purpose nor does Silicon Laboratories assume any liability arising out of the application or use of any product or circuit and specifi...

Reviews: