Overview
This FlexCAN example application demonstrates the SDK Peripheral drivers working with different methods. FlexCAN network and FlexCAN loop-back are the two provided examples:
- CAN network: transfers data through the CAN interface. On node 1, the user inputs characters by using the UART debug terminal and sends the data with the FlexCAN interface. On the other node, the FlexCAN receives the data and prints it to the UART terminal.
- CAN loop-back: transfers data through the CAN loop-back interface. On one node, one 8-byte buffer stream transmitter output is internally sent back to the receiver input.
The board transfers and receives characters through the FlexCAN-UART interface. Type the characters on the keyboard and the board receives and displays them on the terminal screen. Look for instructions output to the terminal.
Supported Platforms
These Tower System modules are supported by the FlexCAN example:
- TWR-K21F120M
- TWR-K60D100M
- TWR-K64F120M
- TWR-K65F180M
System Requirement
Hardware requirements
- J-Link ARM
- P&E Micro Multi-link universal
- Mini/micro USB cable
- USB A to micro AB cable
- Hardware (tower/base board, ...) for specific device
- Personal Computer
Toolchain requirements
- IAR embedded Workbench version 7.30.4
- ARM GCC 4.8.3 2014q3
- Keil MDK 5.13
- Kinetis Design Studio IDE v.2.5.0
- Atollic TrueSTUDIO for ARM win32 v5.2.1
Software requirements
- The project files are in: <SDK_Install>/examples/<board>/driver_examples/flexcan/<use_case>/<toolchain>.
- Library dependencies: ksdk_platform_lib
Getting Started
Hardware settings
TWR-SER Tower System module configuration (only FlexCAN network example)
- Short J5(1-2), J5(3-4), J5(5-6), J5(7-8), and J5(9-10) to enable CAN connection.
- Connect the two TWR-SER modules through the CAN port (J7).
Although not required, the recommendation is to leave the development board jumper settings and configurations in default state when running this example.
Prepare the example
- Connect a USB cable between the PC host and the OpenSDA USB port on the board.
- Open a serial terminal with these settings:
- 115200 baud rate
- 8 data bits
- No parity
- One stop bit
- No flow control
- Download the program to the target board.
- Either press the reset button on your board or launch the debugger in your IDE to begin running the example.
Run the example
FlexCAN loopback
These instructions are displayed/shown on the terminal window:
Running the FlexCAN loopback example.
*********FLEXCAN LOOPBACK EXAMPLE*********
Message format: Standard (11 bit id)
Interrupt Mode: Enabled
Operation Mode: TX and RX --> Normal
Data transmit: 0a 0b 0c 0d 0e 0f 10 11
DLC=8, mb_idx=8
RX MB data: 0x0a 0b 0c 0d 0e 0f 10 11
ID: 0x123Press any key to run again!
FlexCAN network
After connecting the two boards, these instructions display on each terminal window. One board must be chosen as node A and the other board as node B. Data is sent continuously between the node A and the node B.
This message displays on the node A terminal:
*********FlexCAN : SCI2CAN demo *********
Message format: Standard (11 bit id)
OSJTAG Port used for Serial Console.
Interrupt Mode: Enabled
Operation Mode: TX and RX --> Normal
Please select local node as A or B:
Node:A
Data from Node B. Data from Node B. Data from Node B.
This message displays on the node B terminal:
*********FlexCAN : SCI2CAN demo *********
Message format: Standard (11 bit id)
OSJTAG Port used for Serial Console.
Interrupt Mode: Enabled
Operation Mode: TX and RX --> Normal
Please select local node as A or B:
Node:B
Data from Node B. Data from Node B. Data from Node B.