MPC5748C Re-initializes Flexcan

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MPC5748C Re-initializes Flexcan

ソリューションへジャンプ
2,267件の閲覧回数
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 件の賞賛
返信
1 解決策
2,240件の閲覧回数
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 件の賞賛
返信
4 返答(返信)
2,249件の閲覧回数
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 件の賞賛
返信
2,245件の閲覧回数
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 件の賞賛
返信
2,241件の閲覧回数
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 件の賞賛
返信
2,234件の閲覧回数
xiha
Contributor II

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

0 件の賞賛
返信