CAN Bus EXT ID

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

CAN Bus EXT ID

447 Views
Ayhan14
Contributor II

Hello,

When I configured as standart ID's, I received CAN messages.

But When I set  CAN ID as extended, I do not received CAN messages.

Do I miss a any configuration that I need? 

 

Here is CAN2_init function:

 

 

void CAN2_Init(void)

{

GPIO_PinInit(GPIO10, 1U, &pinConfig); // CAN2 STANDBY PIN INIT

GPIO_PinInit(GPIO4, 6U, &pinConfig); // CAN2 ENABLE PIN INIT

GPIO_PinWrite(GPIO10, 1U, 1U); // CAN2 STANDBY HIGH

GPIO_PinWrite(GPIO4, 6U, 1U); // CAN2 ENABLE HIGH



flexcan_config_t flexcanConfig;

flexcan_rx_mb_config_t mbConfig;

flexcan_rx_mb_config_t mbConfig1;

flexcan_rx_mb_config_t mbConfig2;

flexcan_rx_mb_config_t mbConfig3;



clock_root_config_t rootCfg = {0};

rootCfg.mux = FLEXCAN_CLOCK_SOURCE_SELECT;

rootCfg.div = FLEXCAN_CLOCK_SOURCE_DIVIDER;

CLOCK_SetRootClock(kCLOCK_Root_Can2, &rootCfg);



FLEXCAN_GetDefaultConfig(&flexcanConfig);



flexcan_timing_config_t timing_config;

memset(&timing_config, 0, sizeof(flexcan_timing_config_t));



if (FLEXCAN_CalculateImprovedTimingValues(CAN2, 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");

}





FLEXCAN_Init(CAN2, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ);



/* Create FlexCAN handle structure and set call back function. */

FLEXCAN_TransferCreateHandle(CAN2, &flexcanHandle, flexcan_callback, NULL);



/* Set Rx Masking mechanism. */

FLEXCAN_SetRxMbGlobalMask(CAN2, FLEXCAN_RX_MB_EXT_MASK(0x1FFFFFFF, 0, 0)); //0x18DAFFF9 0x625



/* Setup Rx Message Buffer. */

mbConfig3.format = kFLEXCAN_FrameFormatExtend;

mbConfig3.type = kFLEXCAN_FrameTypeData;

mbConfig3.id = FLEXCAN_ID_EXT(0x18DAFFF9);

FLEXCAN_SetRxMbConfig(CAN2, RX_MESSAGE_BUFFER_NUM3, &mbConfig3, true);



/* Setup Tx Message Buffer. */

FLEXCAN_SetTxMbConfig(CAN2, TX_MESSAGE_BUFFER_NUM3, true);

/* Start receive data through Rx Message Buffer. */

rxXfer.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM;

rxXfer.frame = &rxFrame1;

(void)FLEXCAN_TransferReceiveNonBlocking(CAN2, &flexcanHandle, &rxXfer);



rxXfer1.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM1;

rxXfer1.frame = &rxFrame2;

(void)FLEXCAN_TransferReceiveNonBlocking(CAN2, &flexcanHandle, &rxXfer1);



rxXfer2.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM2;

rxXfer2.frame = &rxFrame3;

(void)FLEXCAN_TransferReceiveNonBlocking(CAN2, &flexcanHandle, &rxXfer2);



rxXfer3.mbIdx = (uint8_t)RX_MESSAGE_BUFFER_NUM3;

rxXfer3.frame = &rxFrame4;

(void)FLEXCAN_TransferReceiveNonBlocking(CAN2, &flexcanHandle, &rxXfer3);



CAN2_BSI4_frame.length = (8U);

CAN2_BSI4_frame.format = kFLEXCAN_FrameFormatExtend;

CAN2_BSI4_frame.type = kFLEXCAN_FrameTypeData;



/* Start receive data through Tx Message Buffer. */

txXfer3.mbIdx = (uint8_t)TX_MESSAGE_BUFFER_NUM3;

txXfer3.frame = &CAN2_BSI4_frame;

}

 

 

Tags (1)
0 Kudos
Reply
5 Replies

418 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Can you tell us the part number you are using? the IP of CAN module is different for different family.

BR

XiangJun Rong

0 Kudos
Reply

403 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The customer use  imxRT1170 Processor

BR

XiangJun Rong

0 Kudos
Reply

392 Views
Ayhan14
Contributor II

Hi,

Can you share an example of CAN extended ID?

 

Regards,

Oğuzhan Ayhan

0 Kudos
Reply

258 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

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

There are CAN examples in the SDK, but they are configured for standard messages. An apology for the inconvenience.

Hope it helps you.

Have a nice day!

0 Kudos
Reply

407 Views
Ayhan14
Contributor II

I am using imxRT1170 Processor

0 Kudos
Reply