world leader in high performance signal processing
Trace: » can_module

Blackfin CAN (Controller Area Network) Driver

The driver based on CAN4Linux described in this page is deprecated, and will not be supported, and is removed from the newer (2010R1 and newer kernels). The new SocketCAN driver replaces it.

The Controller Area Network (CAN) specification describes a networking stack aimed at a specific environment: embedded, realtime controller networks. At the physical layer, it uses a differential serial technology which is intended to be highly resistant to electrical noise. The higher-level protocols use short datagrams (eight bytes maximum payload) and extensive checksumming to minimize the effect of errors. The protocols are simple in the extreme, placing the smallest possible demand on embedded controllers. CAN will be found in relatively small and hostile environments - inside automobiles, for example.

The CAN module is a low bit rate serial interface intended for use in applications where bit rates are typically up to 1Mbit/s. The interface to the CAN bus is a simple two-wire line. The Blackfin processor’s CANTX output and CANRX input pins are connected to an external CAN transceiver’s TX and RX pins (respectively).

There are two frameworks for CAN drivers in Linux now. CAN4LINUX provides read/write/ioctl interfaces based on the framework of Linux character device drivers, but SocketCAN provides an API for CAN devices based on BSD sockets.

The Blackfin CAN driver currently support only one hard coded baud rate, which is in sync when SCLK = 125 MHz. For further informations on how to calculate and change the baud rate read this forum thread here: Forum

Test Blackfin CAN driver on BF537 STAMP

Here we test transmit/receive message between two STAMP boards via CAN.

Setup Board

To use CAN, the switch SW2 of BF537 STAMP need to be switched on. Connect two BF537 STAMP boards with a telephone cable, using either of the two CAN sockets. The TX/RX lines of telephone cable need to be crossover.

CAN4LINUX Framework Driver

Configure Kernel
 Character devices --->
    CAN, the car bus and industrial fieldbus  --->
     [*] can4linux support, the car bus and industrial fieldbus
     <M>   Analog Devices BlackFin CAN Controller
Configure Applications
 Miscellaneous Applications  --->
   [*] can4linux examples

can4linux examples

On the receiver side, start receive and wait:

root:/> modprobe can                                                            
ISA-BlackFin-CAN CAN Driver 3.4.6_AD_BLACKFIN (c) Jul  8 2008                   
 BlackFin port by H.J. Oertel (oe@port.de) 
root:/> receive                                                                 

On another STAMP, send message:

root:/> modprobe can                                                            
ISA-BlackFin-CAN CAN Driver 3.4.6_AD_BLACKFIN (c) Jul  8 2008                   
 BlackFin port by H.J. Oertel (oe@port.de)
root:/> can_send 10 01 02 03 04 05 06 07 08

The receiver is expected to receive message like:

Received with ret=1:         6166.286776 id=10                                  
        len=8 msg= 01 02 03 04 05 06 07 00 flags=0x00     

Test Blackfin CAN driver on BF548 EZKIT

The ADSP-BF544, ADSP-BF548, and ADSP-BF549 processors have two separate and identical CAN modules, referred to as CAN0 and CAN1. The CAN1 module is not present on ADSP-BF542 derivatives. By default on BF548-EZkit, we use CAN0.

Setup Board

If using CAN0, please set SW6 to 1-2 off, 3-4 on.