How can I receive all IDs from CAN Bus with MCP5748G?

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

How can I receive all IDs from CAN Bus with MCP5748G?

823 Views
xierxiaofeng
Contributor I

    I can reveive data from CAN Bus with MPC5748G, but ID is appointed. Now I want to receive all IDs from CAN Bus, how to config CAN module?

Below is my code:

void can_init(void)
{
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM2, &canCom2_State, &canCom2_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM3, &canCom3_State, &canCom3_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM4, &canCom4_State, &canCom4_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM5, &canCom5_State, &canCom5_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM6, &canCom6_State, &canCom6_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM7, &canCom7_State, &canCom7_InitConfig0);
FLEXCAN_DRV_Init(INST_CANCOM8, &canCom8_State, &canCom8_InitConfig0);

can_cfg_rx_mb(0, 1, CAN_ID_RX_1);
can_cfg_rx_mb(1, 1, CAN_ID_RX_2);
can_cfg_rx_mb(2, 1, CAN_ID_RX_3);
can_cfg_rx_mb(3, 1, CAN_ID_RX_4);
can_cfg_rx_mb(4, 1, CAN_ID_RX_5);
can_cfg_rx_mb(5, 1, CAN_ID_RX_6);
can_cfg_rx_mb(6, 1, CAN_ID_RX_7);
can_cfg_rx_mb(7, 1, CAN_ID_RX_8);

FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM2, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM3, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM4, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM5, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM6, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM7, flexcan_callback, ((void *)0));
FLEXCAN_DRV_InstallEventCallback(INST_CANCOM8, flexcan_callback, ((void *)0));

FLEXCAN_DRV_Receive(INST_CANCOM1, 1, &recv_buff[0]);
FLEXCAN_DRV_Receive(INST_CANCOM2, 1, &recv_buff[1]);
FLEXCAN_DRV_Receive(INST_CANCOM3, 1, &recv_buff[2]);
FLEXCAN_DRV_Receive(INST_CANCOM4, 1, &recv_buff[3]);
FLEXCAN_DRV_Receive(INST_CANCOM5, 1, &recv_buff[4]);
FLEXCAN_DRV_Receive(INST_CANCOM6, 1, &recv_buff[5]);
FLEXCAN_DRV_Receive(INST_CANCOM7, 1, &recv_buff[6]);
FLEXCAN_DRV_Receive(INST_CANCOM8, 1, &recv_buff[7]);
}
/**
* use same data_info struct for assume that all the point in the same net
*/
void can_cfg_rx_mb(uint8_t instance, uint8_t mb_idx, uint32_t msgid)
{
flexcan_data_info_t rx_info =
{
.data_length = 8U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U
};

FLEXCAN_DRV_ConfigRxMb(instance, mb_idx, &rx_info, msgid);
}

0 Kudos
2 Replies

734 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can clear mask register to allow receiving all IDs into single MB. You can follow info given in https://community.nxp.com/message/993067 

BR, Petr

0 Kudos

734 Views
xierxiaofeng
Contributor I

Hi Petr Stancik,

     I got your feedback and resolved this question according to the information.

Thanks!

0 Kudos