MPC5748C Re-initializes Flexcan

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

MPC5748C Re-initializes Flexcan

Jump to solution
1,779 Views
xiha
Contributor II

My projects are based on Flexcan and ETHERNET.Now I'm going to re-initialize Flexcan after receiving the command over the network,but I can't restart FlexCan successfully.The driver isn't normal.CANFD communication is error.The log of CANFD sender, printf ErrorFrame.The code is as follows:

flexcan_user_config_t my_canCom1_InitConfig0 = {
    .fd_enable = true,
    .pe_clock = FLEXCAN_CLK_SOURCE_OSC,
    .max_num_mb = 16,
    .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
    .is_rx_fifo_needed = false,
    .flexcanMode = FLEXCAN_NORMAL_MODE,
    .payload = FLEXCAN_PAYLOAD_SIZE_64,
    .bitrate = {
        .propSeg = 7,
        .phaseSeg1 = 5,
        .phaseSeg2 = 4,
        .preDivider = 1,
        .rJumpwidth = 1
    },
    .bitrate_cbt = {
        .propSeg = 11,
        .phaseSeg1 = 3,
        .phaseSeg2 = 3,
        .preDivider = 0,
        .rJumpwidth = 1
    },
    .transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
    .rxFifoDMAChannel = 0U
};
flexcan_data_info_t dataInfo =
{
  	.data_length = 64U,
  	.msg_id_type = FLEXCAN_MSG_ID_STD,
//	.msg_id_type = FLEXCAN_MSG_ID_EXT,
  	.enable_brs  = true,
  	.fd_enable   = true,
  	.fd_padding  = 0U
};

FLEXCAN_DRV_Deinit(INST_CANCOM1);
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);

FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1,my_callback_event,NULL);
/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &dataInfo, 0u);
FLEXCAN_DRV_SetRxMbGlobalMask(INST_CANCOM1,FLEXCAN_MSG_ID_STD,0);

 If anyone can help to solve this problem?Thanks you very much!

0 Kudos
Reply
1 Solution
1,752 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can use FLEXCAN_DRV_SetBitrate and FLEXCAN_DRV_SetBitrateCbt for that, but changing bitrate requires all nodes on bus follow that too, otherwise you get error for further communications.

BR, Petr

View solution in original post

0 Kudos
Reply
4 Replies
1,761 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

why is the deinit/init needed in fact? What kind of error is detected on sender side?
You can inspect FlexCAN module registers to know if Normal mode is entered and no errors are detected during message reception. Not sure if module also transmit anything.

BR, Petr

0 Kudos
Reply
1,757 Views
xiha
Contributor II

Because I wanted to send commands to the MCU over the network and then change the baud rate of its CANFD communication, I used DeInit and Init to change the CANFD baud rate.

Thanks for your advice. I'll try.

0 Kudos
Reply
1,753 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can use FLEXCAN_DRV_SetBitrate and FLEXCAN_DRV_SetBitrateCbt for that, but changing bitrate requires all nodes on bus follow that too, otherwise you get error for further communications.

BR, Petr

0 Kudos
Reply
1,746 Views
xiha
Contributor II

Your advice is very useful, thank you!!! \ ^_^ / \ ^_^ / \ ^_^ /

0 Kudos
Reply