Blhost with CAN Bus Interface

Blhost with CAN Bus Interface#

This example demonstrates how to use the blhost tool to communicate with NXP microcontrollers over a CAN (Controller Area Network) bus interface.

1. Prerequisites#

  • SPSDK is needed with examples extension. pip install spsdk[examples] (Please refer to the installation documentation.)

  • Install the CAN extension for CAN bus communication: pip install spsdk[can]

  • Ensure CAN adapter drivers (e.g., PCAN-USB) are properly installed and configured on your system

  • Connect your target board via CAN interface. In this example, we will be using a KW45xx-EVK board connected with a PCAN-USB adapter.

2. CAN bus connection#

Use the blhost command with the -cb or --can parameter to communicate with devices connected via the CAN bus. This example uses the chip’s default configuration. The arbitration ID and other CAN bus settings can be modified using the pfr command (refer to pfr --help and your chip’s reference manual for details).

Note: Refer to the python-can library documentation for more information about supported interfaces.

CAN_INTERFACE = "pcan"
%! blhost --can $CAN_INTERFACE get-property 1
blhost --can pcan get-property 1 
Response status = 0 (0x0) Success.
Response word 1 = 1258488064 (0x4b030100)
Current Version = K3.1.0
uptime library not available, timestamps are relative to boot time and not to Epoch UTC