MIMXRT1170-EVKB CANBUS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MIMXRT1170-EVKB CANBUS

Jump to solution
1,415 Views
PaoloRB
Contributor II

Good morning,
I'm using the MIMXRT1170-EVKB starter kit and trying to get the CAN bus working. I loaded the "evkbmimxrt1170_canfd_loopback_transfer_cm7" example, but I need to be able to receive any CAN frame on the bus (both standard and extended frames) without loopback or filtering. Can someone explain how to modify the example to achieve this? I tried setting the global mask to 0 and same for the RX message buffer slot id, but nothing is being received. 

Some other option I tried:

flexcanConfig.bitRate = 250000U;

flexcanConfig.bitRateFD = 250000U;

flexcanConfig.disableSelfReception = true;

flexcanConfig.enableSupervisorMode = false;

flexcanConfig.enableLoopBack = false;


Thanks in advance for any clarification.

0 Kudos
Reply
1 Solution
1,309 Views
mayliu1
NXP Employee
NXP Employee

Hi @PaoloRB,

 

Thank you for your updated information.

I advise you not to use the “evkbmimxrt1170_canfd_loopback_transfer_cm7” SDK demo, this example is about send a CAN Message from the Tx Message Buffer to the Rx Message Buffer through internal loopback interconnect.

I use MIMXRT1050-EVKB board and MIMXRT1070-EVKB board.

I import SDK demo "evkbimxrt1050_flexcan_interrupt_transfer"  and "evkbmimxrt1170_canfd_interrupt_transfer_cm7".

I modify some code, the result is that MIMXRT1170-EVKB can receive any CAN ID send from MIMXRT1050-EVKB board.

1:  flexcanConfig.enableIndividMask = false;

2: FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, 0);

 

If you use MIMXRT1170-EVKB board CAN3 J47, Please Remove J102 and J103 jumpers. It is very import.

Please connect Two CAN interface correctly.

mayliu1_1-1729503298198.png

Wish it helps you.
If you still have question about it, please kindly let me know.

Wish you a nice day!

Best Regards

mayliu

View solution in original post

5 Replies
1,388 Views
mayliu1
NXP Employee
NXP Employee

Hi @PaoloRB ,

 

Thank you so much for your interest in our products and for using our community.

The next SDK function to set RX Masking mechanism,  the second param mask set as 0 to allow receive all ID CAN frame.

For example: FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, 0); 

Please also pay attention to  that "The configuration is only effective when the Rx individual mask is disabled in the FLEXCAN_Init()."

mayliu1_1-1729248685866.png

 

Wish it helps you.
If you still have question about it, please kindly let me know.

 

Best Regards

mayliu

0 Kudos
Reply
1,355 Views
PaoloRB
Contributor II

Thanks for your quick response, 

My actual testing code:

flexcan_config_t flexcanConfig;
flexcan_rx_mb_config_t mbConfig;

/* Initialize board hardware. */
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();

/*Clock setting for FLEXCAN*/
clock_root_config_t rootCfg = {0};
rootCfg.mux = FLEXCAN_CLOCK_SOURCE_SELECT;
rootCfg.div = FLEXCAN_CLOCK_SOURCE_DIVIDER;
CLOCK_SetRootClock(kCLOCK_Root_Can3, &rootCfg);

LOG_INFO("\r\n==FlexCAN loopback example -- Start.==\r\n\r\n");

/* Init FlexCAN module. */
/*
* flexcanConfig.clksrc=kFLEXCAN_ClkSrc0;
* flexcanConfig.bitRate = 1000000U;
* flexcanConfig.bitRateFD = 2000000U;
* flexcanConfig.maxMbNum = 16;
* flexcanConfig.enableLoopBack = false;
* flexcanConfig.enableSelfWakeup = false;
* flexcanConfig.enableIndividMask = false;
* flexcanConfig.disableSelfReception = false;
* flexcanConfig.enableListenOnlyMode = false;
* flexcanConfig.enableDoze = false;
*/
FLEXCAN_GetDefaultConfig(&flexcanConfig);
flexcanConfig.bitRate = 250000U;
flexcanConfig.enableIndividMask = false;

#if defined(EXAMPLE_CAN_CLK_SOURCE)
flexcanConfig.clksrc=EXAMPLE_CAN_CLK_SOURCE;
#endif

#if (defined(USE_IMPROVED_TIMING_CONFIG) && USE_IMPROVED_TIMING_CONFIG)
flexcan_timing_config_t timing_config;
memset(&timing_config, 0, sizeof(flexcan_timing_config_t));
#if (defined(USE_CANFD) && USE_CANFD)
if (FLEXCAN_FDCalculateImprovedTimingValues(EXAMPLE_CAN, flexcanConfig.bitRate, flexcanConfig.bitRateFD,
EXAMPLE_CAN_CLK_FREQ, &timing_config))
{
/* Update the improved timing configuration*/
memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t));
}
else
{
LOG_INFO("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
}
#else
if (FLEXCAN_CalculateImprovedTimingValues(EXAMPLE_CAN, flexcanConfig.bitRate, EXAMPLE_CAN_CLK_FREQ, &timing_config))
{
/* Update the improved timing configuration*/
memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t));
}
else
{
LOG_INFO("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
}
#endif
#endif

#if (defined(USE_CANFD) && USE_CANFD)
FLEXCAN_FDInit(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ, BYTES_IN_MB, true);
#else
FLEXCAN_Init(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ);
#endif

FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, 0);

/* Create FlexCAN handle structure and set call back function. */
FLEXCAN_TransferCreateHandle(EXAMPLE_CAN, &flexcanHandle, flexcan_callback, NULL);

/* Setup Rx Message Buffer. */
mbConfig.format = kFLEXCAN_FrameFormatStandard;
mbConfig.type = kFLEXCAN_FrameTypeData;
mbConfig.id = FLEXCAN_ID_STD(0x123);
#if (defined(USE_CANFD) && USE_CANFD)
FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
#else
FLEXCAN_SetRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
#endif

/* Start receive data through Rx Message Buffer. */
rxXfer.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM;
#if (defined(USE_CANFD) && USE_CANFD)
rxXfer.framefd = &rxFrame;
(void)FLEXCAN_TransferFDReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer);
#else
rxXfer.frame = &rxFrame;
(void)FLEXCAN_TransferReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &rxXfer);
#endif

FLEXCAN_SetTxMbConfig(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, true);
/* Waiting for Rx Message finish. */
while ((!rxComplete))
{
int test = 1 ;
};

but I'm still not receiving any frame. rxComplete never triggered.

Thanks again

 

0 Kudos
Reply
1,310 Views
mayliu1
NXP Employee
NXP Employee

Hi @PaoloRB,

 

Thank you for your updated information.

I advise you not to use the “evkbmimxrt1170_canfd_loopback_transfer_cm7” SDK demo, this example is about send a CAN Message from the Tx Message Buffer to the Rx Message Buffer through internal loopback interconnect.

I use MIMXRT1050-EVKB board and MIMXRT1070-EVKB board.

I import SDK demo "evkbimxrt1050_flexcan_interrupt_transfer"  and "evkbmimxrt1170_canfd_interrupt_transfer_cm7".

I modify some code, the result is that MIMXRT1170-EVKB can receive any CAN ID send from MIMXRT1050-EVKB board.

1:  flexcanConfig.enableIndividMask = false;

2: FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, 0);

 

If you use MIMXRT1170-EVKB board CAN3 J47, Please Remove J102 and J103 jumpers. It is very import.

Please connect Two CAN interface correctly.

mayliu1_1-1729503298198.png

Wish it helps you.
If you still have question about it, please kindly let me know.

Wish you a nice day!

Best Regards

mayliu

1,282 Views
PaoloRB
Contributor II

J102 and J103 jumpers were the issue. Really appreciated

0 Kudos
Reply
1,268 Views
mayliu1
NXP Employee
NXP Employee

Hi @PaoloRB 

 

I'm glad your problem was solved.

If your question is solved, please tell me to close this case, and help me to fill the feedback as resolved, thanks.

 

Best Regards

mayliu

0 Kudos
Reply