CAN
The phyCORE-i.MX7 SOM supports up to 2x CAN interfaces. The development kit breaks out the CAN1 interface to the X1 header for general use and the CAN2 interface to the PEB-D-RPI Expansion Board. This guide will walk-through the basic usage of the CAN1 interface by transferring data to and from a host PC. In order to follow this guide you will need a CAN-USB adapter cable, the necessary driver for this adapter, and software for your host machine to display the received messages. This guide was tested and written using the following product and software:
Requirements
Tip
See the end of this guide for further information regarding advanced CAN configurations.
Setup the CAN Interface
Connect the D-sub 9 ribbon cable to the connector X1 (red line indicates Pin 1).
Connect the PCAN-USB adapter between the host PC (USB port) and the CAN1 interface (X1) on the development kit.
Set up the Host PC with PCAN-View
Open PCAN-View on your host PC and select the device from the available hardware. Set the Bit rate field to 1 MBit/s and click OK.
Tip
If you cannot find your device in the listed hardware, ensure that you have the correct driver installed on your host PC. You can obtain the driver HERE.
Using the phyCORE-i.MX7 Linux console, use the following commands to set up the CAN interface and configure the bit rate. For this example 1 MBit/s is used.
ip link set can0 down ip link set can0 up type can bitrate 1000000 ip link set can0 up
Send CAN messages
In this example you will test data transfers from the phyCORE-i.MX7 to the host PC.
Make sure PCAN View is open on your host PC
Enter the following on the phyCORE-i.MX7 console to send data on the CAN bus.
cansend can0 000#DE.AD.BE.EF.CA.FE.BA.BE
In PCAN-View verify that the data is correct in the “Receive” window.
Receive CAN messages
In this example you will test data travelling in the opposite direction, from the host PC to the phyCORE-i.MX7.
Enter the following command on the phyCORE-i.MX7 console to put the CAN interface into listening mode:
candump can0
On your host PC in PCAN-View, create a new transmit message. Enter DEADBEEDCAFEBABE as the data (hex).
Select the message. You can press the space-bar a few times to send the message more than once.
On the phyCORE-i.MX7 you should see that the message has been received.
root@phyboard-zeta-imx7d-1:~# candump can0 can0 000 [8] DE AD BE ED CA FE BA BE
To exit listening mode on the phyCORE-i.MX7 enter Ctrl + C to stop candump
Advanced CAN References
CAN Jumper Configurations
The phyBOARD-Zeta provides one removable solderless jumper (JP) at JP1 for CAN termination configuration.
Reference Designator |
Jumper Setting |
Description |
---|---|---|
JP1 |
Open |
Remove 120Ω termination between X_CAN1H and X_CAN1L |
Closed (Default) |
Add 120Ω termination between X_CAN1H and X_CAN1L |
Warning
The D-sub 9 adapter cable included with the phyCORE-i.MX7 development kit does not have the same numbering scheme as the pins at the header X1.