sCan
is a framework designed to simplify CAN-FD communication. It is easy to configure and provides simple send/receive functions with a defined data transmission format.
It includes predefined commands such as reset, data transmission, OTA, IO control and allows users to extend commands as needed.
- Configures FlexCAN FD hardware
- Sets up message buffers for RX/TX
- Provides APIs for sending segmented messages
- Supports low-power wakeup
- Initializes CAN task and message queues
- Buffers incoming CAN FD frames
- Reassembles multi-frame messages
- Dispatches complete messages to registered handlers
sCan_app.c
osa_status_t SCAN_InitTask(scan_config_t* pConfig, uint32_t configLen);
scan_status_t SCAN_SendMsg(scan_ext_id_t extId, uint8_t * pPkt, uint16_t length);
scan_status_t SCAN_RegisterProcessHandler(pfScanTaskProcessRcvMsg_t handler)
flexcanConfig.baudRate = 1000000U; // 1M baudrate for FlexCan 2.0 and 2M baudrate FlexCan FD
flexcanConfig.baudRateFD = 2000000U;
flexcanConfig.enableIndividMask = true; // if enable individ mask, global MB mask will has no effect on MB
flexcanConfig.maxMbNum = 7; //
flexcanConfig.disableSelfReception = true;
/* Enable Flexcan Self Wake Up mechanism */
flexcanConfig.enableSelfWakeup = true;
static scan_config_t s_scanConfBases[] =
{
{
.mbId = kScanMbNum0_c,
.individMask = FLEXCAN_ID_EXT(NODE_TYPE_MASK), //msg ID Bits to be filtered,
.rxId = ((kNodeTypeBle_c << NODE_TYPE_SHIFT) ), //msg ID value that expect
.isRX = true,
},
...
/* at least one tx mb*/
{
.mbId = kScanMbNum6_c,
.isRX = false,
}
};
- Connect EVK and PCAN.
- Run the script. The PC will send data to EVK, EVK sends back the data.
- Multiple EVKs are supported.
Script path:
\sCan\tools\python-script\testcase\Test0_1_ScanCommunication.py
- Connect 2 EVKs via CAN.
- Power on both EVKs simultaneously using a 12V power supply.
- Data will be transferred between the two EVKs until a failure occurs.
- spsdk: 3.1.0
- Python: 3.13+
- PCAN-View: 5.3.2
- KW47 SDK: 25.06.00
- KW47-EVK
- PCAN-USB FD / PCAN-USB Pro FD
-
Install PCAN-View PCAN-View
-
Download PCAN-Basic PCAN-Basic
Copy
PCANBasic.py
from\PCAN-Basic\Include
to\tools\sCan-script\src
PCAN-2
<-->J10-2
of KW47-EVKPCAN-7
<-->J10-1
of KW47-EVK
- Supply 12V power to J9 of KW47-EVK
- Connect USB port J14 of KW47-EVK to PC
- Connect PCAN-USB to PC
Refer to the demo project: dm-loc-apps-kw47
The binary can be programmed via J-Link initially, and subsequent firmware updates can be performed via CAN OTA.
When testing CAN OTA, KW47's keys are required, if KW47-EVK is used, put \dm-kw45-secure-boot-scripts\how to import keys to SPSDK or SPT\kw45evk_keys
to \dm-kw45-secure-boot-scripts\workspace
and change the folder name to keys
, then run the script 1.generate_keys.cmd
.
- Run
Test0_1_ListDeviceId.py
to get CAN ID, then update the fileconfig\config_param.yaml
- Run
Test0_0_ScanOta.py
to perform CAN OTA for updating KW47 firmware. - Run
Test0_3_ScanCommunication.py
to test CAN-FD communication between PCAN and KW47. - Run
Test0_4_ScanGpio.py
to test IO control, check the LED1 on KW47-EVK. - Add your own test cases to the
testcase
folder as needed.
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
Version | Description / Update | Date |
---|---|---|
1.0 | Initial release on Application Code Hub | August 19th 2025 |