Datasheet

Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
21
Getting a CAN Network to work on the Discovery board: with Serial Wire Viewer…
Below is a real two node CAN network using a STMicroelectronics STM32F4 Discovery board. You can substitute other
boards as long as you have at least two CAN nodes. The Discovery board contains two separate CAN nodes but no
transceiver chips. You will need to add three parts to create a simple network. We will then make one node talk to the other.
The Discovery has a ST-Link V2 debug adapter on board which supports JTAG, Serial Wire Debug (SWD) and Serial Wire
Viewer (SWV. We will use this to connect to the target. Other boards may need a JTAG/SWD adapter such as a ULINK2,
ULINK-ME, ULINKpro or a J-Link. ULINKpro, also provides ETM (Embedded Trace Macrocell) support.
Modifying the STM32F4 Discovery:
In order to connect the two CAN controllers together, you must add two
signal diodes (1N914, 1N4148 or similar) and one 3.3 K resistor as
shown on this schematic. The connections are easily accessible.
1. Add the three parts as shown on the schematic and in the photo.
2. Connect the resistor to the 3 volt supply as shown.
3. Add a jumper wire (not shown) from PB5 to PB8.
4. Note: I used a 2.7K resistor and it seems to work well.
5. I soldered the components to the board.
6. Note: you will need to open the resistor for a step later.
You cannot connect this to a real CAN network as the voltages are wrong and it is not differential. It is suitable for small
experiments.
TIP: To view CAN frames on an oscilloscope: connect to the low side of the resistor. This will give a clean waveform.
Configuring the ST-Link V2: Note: ST-Link V1 does not support SWV and can’t be updated to V2.
The ST-Link is selected as the default debug adapter for the Keil examples for the Discovery board. Detailed instructions for
configuring µVision with various debug adapters including ST-Link see this: www.keil.com/appnotes/docs/apnt_230.asp
Installing the ST-Link USB Drivers: (you need to do only this the first time)
1. Do not have the Discovery board USB port connected to your PC at this time.
2. The USB drivers must be installed manually by executing ST-Link_V2_USBdriver.exe. This file is found in
C:\Keil\ARM\STLink\USBDriver. Find this file and double click on it.
3. Plug in the Discovery board to USB CN1. The USB drivers will now finish installing in the normal fashion.
Super TIP: The ST-Link V2 firmware update files are located here: C:\Keil\ARM\STLink. This updates the Discovery ST-
Link firmware by executing ST-LinkUpgrade.exe. Find this file and double click on it. It will check and report the current
firmware version. It is important you are using firmware V2.J16.S0 or later for proper SWV operation.
To confirm you are connected to the Cortex-M4 Processor:
1. Connect the Discovery board CN1 USB to your PC. PWR LD2 must illuminate. Start µVision.
2. Select Project/Open Project. Open the file C:\Keil\ARM\Boards\ST\STM32F4-Discovery\CAN\CAN.uvproj.
3. Select the Click on the Target Options icon.
Select the Debug tab.
4. ST-Link Debugger must be visible. Do not use ST-Link (deprecated version). Select Settings:
5. In the SW Device box: ARM CoreSight SW-DP MUST be displayed as shown below. This confirms you are
connected to the target processor. If there is an error displayed or it is blank this must be fixed before you can
continue. Check the target power supply. Cycle the power to the board. To refresh SWD, select JTAG and then
back to SW. JTAG is not a valid operation with this configuration and will normally show an error. This is OK.
6. Click on OK once. Click on Utilities. Confirm ST-Link Debugger is selected.
7. Click on Settings. STM32F4xx Flash must be selected.
8. Click on OK twice to return to the main µVision menu.