MCUXpresso_MIMXRT1021xxxxx/boards/evkmimxrt1020/driver_examples/flexcan/interrupt_transfer
Yilin Sun 763d32be90
Updated SDK to v2.15.000
Signed-off-by: Yilin Sun <imi415@imi.moe>
2024-03-15 22:23:36 +08:00
..
armgcc Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
board.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
board.h Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
clock_config.c Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
clock_config.h Updated to SDK v2.14.0 2023-08-31 23:30:31 +08:00
dcd.c Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
dcd.h Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
evkmimxrt1020_sdram_init.jlinkscript Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
flexcan_interrupt_transfer_v3_14.xml Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
flexcan_interrupt_transfer.c Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00
pin_mux.c Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
pin_mux.h Initial SDK v2.12.0 2022-08-23 23:00:33 +08:00
readme.md Updated SDK to v2.15.000 2024-03-15 22:23:36 +08:00

Overview

The flexcan_interrupt example shows how to use FlexCAN driver in none-blocking interrupt way:

In this example, 2 boards are connected through CAN bus. Endpoint A(board A) send a CAN Message to Endpoint B(board B) when user press space key in terminal. Endpoint B receive the message, print the message content to terminal and echo back the message. Endpoint A will increase the received message and waiting for the next transmission of the user initiated.

For self wake up from STOP mode, since steps which MCU enters STOP mode differs on different MCUs, take flexcan_interrupt_transfer of twrke18f for example, user should do like this:

#include "fsl_smc.h"
...
...
flexcanConfig.enableSelfWakeup = true;
FLEXCAN_Init();
...
...
SMC_SetPowerModeStop(SMC, kSMC_PartialStop1);
if (wakenUp)
{
    PRINTF("B has been waken up!\r\n\r\n");
}
...
...

SDK version

  • Version: 2.15.000

Toolchain supported

  • IAR embedded Workbench 9.40.1
  • Keil MDK 5.38.1
  • GCC ARM Embedded 12.2
  • MCUXpresso 11.8.0

Hardware requirements

  • Mini/micro USB cable
  • EVK-MIMXRT1020 board
  • Personal Computer

Board settings

The example requires 2 sets of boards, each of them are mounted with the base board. Using a male to male CAN cable to connect the CAN2 instance (J10) between the 2 base boards.

Prepare the Demo

  1. Connect a USB cable between the PC host and the OpenSDA USB on the board.
  2. Open a serial terminal on PC for OpenSDA serial device with these settings:
    • 115200 baud rate
    • 8 data bits
    • No parity
    • One stop bit
    • No flow control
  3. Download the program to the target board.
  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the example.

Running the demo

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. (Note: Node B should start first) Data is sent continuously between the node A and the node B.

Consider special errata 005829 feature, the 1st valid MB should be used as reserved one.
The TX MB number will change from 8 to 9, while RX MB number will change from 9 to 10 
This message displays on the node A terminal:


********* FLEXCAN Interrupt EXAMPLE *********

    Message format: Standard (11 bit id)

    Message buffer 10 used for Rx.

    Message buffer 9 used for Tx.

    Interrupt Mode: Enabled

    Operation Mode: TX and RX --> Normal

*********************************************

Please select local node as A or B:

Note: Node B should start first.

Node:a

Press any key to trigger one-shot transmission

Rx MB ID: 0x123, Rx MB data: 0x0, Time stamp: 8877

Press any key to trigger the next transmission!

Rx MB ID: 0x123, Rx MB data: 0x1, Time stamp: 32459

Press any key to trigger the next transmission!

This message displays on the node B terminal:

********* FLEXCAN Interrupt EXAMPLE *********

Message format: Standard (11 bit id)

Message buffer 10 used for Rx.

Message buffer 9 used for Tx.

Interrupt Mode: Enabled

Operation Mode: TX and RX --> Normal

Please select local node as A or B:

Note: Node B should start first.

Node:b

Start to Wait data from Node A

Rx MB ID: 0x321, Rx MB data: 0x0, Time stamp: 5759

Wait Node A to trigger the next transmission!

Rx MB ID: 0x321, Rx MB data: 0x1, Time stamp: 57276

Wait Node A to trigger the next transmission!


Note:
To debug in qspiflash, following steps are needed:
1. Select the flash target and compile.
2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.
3. Start debugging in IDE.
   - Keil: Click "Download (F8)" to program the image to qspiflash first then clicking "Start/Stop Debug Session (Ctrl+F5)" to start debugging.