Difference between revisions of "IoTGateway/BSP/Android/Gettingstarted/How to use CAN Bus"
From ESS-WIKI
(26 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == ROM- | + | i.MX6 uses the internal FlexCAN(Flexible Controller Area Network) module implementing the CAN protocol according to the CAN 2.0B. |
+ | |||
+ | === Pin Define === | ||
+ | |||
+ | ==== ROM-3420 ==== | ||
{| border="1" cellspacing="1" cellpadding="1" style="width:500px;" | {| border="1" cellspacing="1" cellpadding="1" style="width:500px;" | ||
|+ CAN0(CAN bus 0) CAN1(CAN bus 1) | |+ CAN0(CAN bus 0) CAN1(CAN bus 1) | ||
|- | |- | ||
− | | Pin | + | | Pin |
− | | Signal | + | | Signal |
− | | Pin | + | | Pin |
| Signal | | Signal | ||
|- | |- | ||
− | | 1 | + | | 1 |
| - | | - | ||
− | | 2 | + | | 2 |
| - | | - | ||
|- | |- | ||
− | | 3 | + | | 3 |
− | | CAN0_D- | + | | CAN0_D- |
− | | 4 | + | | 4 |
| - | | - | ||
|- | |- | ||
− | | 5 | + | | 5 |
− | | CAN0_D+ | + | | CAN0_D+ |
− | | 6 | + | | 6 |
| - | | - | ||
|- | |- | ||
− | | 7 | + | | 7 |
| - | | - | ||
− | | 8 | + | | 8 |
| - | | - | ||
|- | |- | ||
− | | 9 | + | | 9 |
| GND | | GND | ||
− | | 10 | + | | 10 |
| - | | - | ||
|} | |} | ||
+ | |||
+ | ==== ROM-7421 ==== | ||
+ | |||
+ | {| border="1" cellspacing="1" cellpadding="1" style="width:500px;" | ||
+ | |+ CAN0(CAN bus 0) | ||
+ | |- | ||
+ | | Pin | ||
+ | | Signal | ||
+ | | Pin | ||
+ | | Signal | ||
+ | |- | ||
+ | | 1 | ||
+ | | - | ||
+ | | 2 | ||
+ | | CAN0_D- | ||
+ | |- | ||
+ | | 3 | ||
+ | | <br/> | ||
+ | | 4 | ||
+ | | - | ||
+ | |- | ||
+ | | 5 | ||
+ | | GND<br/> | ||
+ | | 6 | ||
+ | | GND | ||
+ | |- | ||
+ | | 7 | ||
+ | | CAN0_D+ | ||
+ | | 8 | ||
+ | | - | ||
+ | |- | ||
+ | | 9 | ||
+ | | | ||
+ | | 10 | ||
+ | | - | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | === Configuration/Test === | ||
+ | |||
+ | ==== Configuration ==== | ||
+ | |||
+ | Connect CAN0 to CAN1 | ||
+ | |||
+ | <tt>CAN0_D+ </tt>connect to <tt>CAN1_D+</tt> | ||
+ | |||
+ | <tt>CAN0_D- </tt>connect to <tt>CAN1_D-</tt> | ||
+ | <pre># ip link set can0 up type can bitrate 125000 | ||
+ | # ip link set can1 up type can bitrate 125000</pre> | ||
− | |||
− | === Test === | + | ==== Test ==== |
*Test 1 | *Test 1 | ||
+ | <pre># candump can1 & | ||
+ | # cansend can0 12345678#123412341234 | ||
+ | </pre> | ||
+ | The following shows the result | ||
+ | <pre>can1 12345678 [6] 12 34 12 34 12 34 | ||
+ | </pre> | ||
+ | *Test 2 | ||
+ | <pre># cansend can0 133#ababdede | ||
+ | </pre> | ||
− | + | The following shows the result | |
+ | <pre>can1 133 [4] AB AB DE DE | ||
+ | </pre> |
Latest revision as of 08:18, 3 February 2017
i.MX6 uses the internal FlexCAN(Flexible Controller Area Network) module implementing the CAN protocol according to the CAN 2.0B.
Pin Define
ROM-3420
Pin | Signal | Pin | Signal |
1 | - | 2 | - |
3 | CAN0_D- | 4 | - |
5 | CAN0_D+ | 6 | - |
7 | - | 8 | - |
9 | GND | 10 | - |
ROM-7421
Pin | Signal | Pin | Signal |
1 | - | 2 | CAN0_D- |
3 | |
4 | - |
5 | GND |
6 | GND |
7 | CAN0_D+ | 8 | - |
9 | 10 | - |
Configuration/Test
Configuration
Connect CAN0 to CAN1
CAN0_D+ connect to CAN1_D+
CAN0_D- connect to CAN1_D-
# ip link set can0 up type can bitrate 125000 # ip link set can1 up type can bitrate 125000
Test
- Test 1
# candump can1 & # cansend can0 12345678#123412341234
The following shows the result
can1 12345678 [6] 12 34 12 34 12 34
- Test 2
# cansend can0 133#ababdede
The following shows the result
can1 133 [4] AB AB DE DE