Datasheet

Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
1
Hands-on usin
g
the Keil Simulator or the STM32F4 Discover
y
Board
CAN Primer: Creating Your Own Network
ARM
®
Keil MDK toolkit featuring Simulator, Serial Wire Viewer and ETM Trace
For the STMicroelectronics STM32F4 Cortex-M4 V 2.0 Robert Boys bob.boys@arm.com
Introduction:
CAN is extensively used in automotive but it has found applications everywhere. There are many “application” layers
available for CAN such as ISO 15765 (cars), J1939 (trucks), DeviceNET and CANopen (both are for factory automation) but
it is very easy to develop your own protocol that will fit and simplify your needs. Modern CAN transceivers provide a stable
and reliable CAN physical environment without the need for expensive coaxial cables. Nearly all of the mystery of CAN has
dissipated over the years. There is plenty of example CAN software to help you develop your own network.
Many think CAN is just for automotive, but this is not true. CAN has become the standard for vehicle networks, but it has
been adopted in most other fields. As you find out in these pages, there are no attributes in the Bosch CAN specification that
are automotive related. It is completely generic. You can easily
implement your own protocol on top of CAN.
A CAN controller is a sophisticated device. Nearly all the features of
the CAN protocol described here are automatically handled by the
controller with almost no intervention by the host processor. All you
need to do in practice is to configure the controller by writing to its
registers, write data to the controller and the controller then does all
the housekeeping work to get your message on the bus.
The controller will read any frames it sees on the bus and hold them
in a small FIFO memory. It will notify the host processor that this
data is available which it then reads from the controller.
The controller also contains a hardware filter mechanism that can be
programmed to ignore and discard those CAN frames you do not
want passed to the processor. This saves on processor overhead. STMicroelectronics STM32F4 Discovery
MDK provides sample CAN examples for many ARM processors which you can practice with. This document provides
hands-on exercises with both the Keil simulator or with the Discovery board.
Modern bus transceiver chips have made the physical CAN bus much less “finicky” and easier to construct and maintain.
The techniques discussed can be applied to many other microprocessors. We use ARM Keil MDK toolkit for the examples.
There is no charge for the evaluation version: MDK-Lite™. You can use MDK-Lite for all the CAN examples used here.
There are many other CAN examples in MDK for many
boards using ARM processors.
Keil provides a CAN stack as part of MDK-Professional™.
Details are on www.keil.com/rl-arm/rl-can.asp
Keil products are listed on the last page of this document.
See forums.arm.com for more ARM information.
Evaluation boards using STM32 that support CAN:
This document uses the STM32F4 Discovery board but you
can adapt the source code to any board with a CAN node.
The latest version of this document is here: www.keil.com/appnotes/docs/apnt_236.asp
For a general lab on the STM32F4 Discovery: www.keil.com/appnotes/docs/apnt_230.asp

Summary of content (31 pages)